-
Notifications
You must be signed in to change notification settings - Fork 1
/
textreport.py
45 lines (32 loc) · 1.09 KB
/
textreport.py
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
import textreport_ui_support as support
def setupSupport():
"""Replace the globals in textreport_ui_support with globals from this module
so that ui_support can be freely regenerated."""
support.closeWindow = closeWindowCb
support.init = onInit
def onInit(top, gui, *args, **kwargs):
# global w, top_level, root
support.w = gui
support.top_level = top
support.root = top
gui.top_level = top
prepareTextReport(gui)
def prepareTextReport(gui):
pass
def getOrCreateTextReport(root, *args, **kwargs):
"""Return an exisiting window or create a new window."""
import textreport_ui
try:
# return an existing window if it was already created
if support.w is not None:
gui = support.w
return (gui.top_level, gui)
except: pass
# create a new window
(frame, gui) = textreport_ui.create_Report(root, *args, **kwargs)
frame.protocol("WM_DELETE_WINDOW", lambda: closeWindowCb(gui))
return (frame, gui)
def closeWindowCb(gui):
support.w = None
support.top_level = None
gui.top_level.destroy()