forked from tdamdouni/Pythonista
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonista-background-check.py
More file actions
54 lines (40 loc) · 884 Bytes
/
pythonista-background-check.py
File metadata and controls
54 lines (40 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# coding: utf-8
# https://forum.omz-software.com/topic/992/check-if-pythonista-is-in-background
import webrowser
webrowser.open('safari-http://')
# I want the next line to execute only when returning back to Pythonista
print "Back here"
#==============================
import ui, scene
class scTest(scene.Scene):
def pause(self):
print 'pause'
def resume(self):
print 'resume'
if False:
scene.run(scTest())
else:
v = ui.View()
sv = scene.SceneView()
sv.scene = scTest()
#sv.hidden = True
v.add_subview(sv)
v.present('panel')
#==============================
import ui, scene
def AmIBack():
global gbGone
if gbGone and not sv.paused:
gbGone = False
print "Back here"
else:
if sv.paused:
gbGone = True
ui.delay(AmIBack, 1)
gbGone = False
v = ui.View()
sv = scene.SceneView()
sv.hidden = True
v.add_subview(sv)
v.present('panel')
AmIBack()