MCPcopy Create free account
hub / github.com/ActiveState/code / main

Function main

recipes/Python/576959_Boids_20_for_Python_31/recipe-576959.py:50–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48################################################################################
49
50def main():
51 # Create the opening window for the program.
52 NoDefaultRoot()
53 root = Tk()
54 assert not (USE_WINDOW and FULLSCREEN), \
55 'Only Window or Fullscreen may be used.'
56 # Define the closing event handler.
57 if COME_BACK < 0:
58 def close(event=None):
59 root.destroy()
60 else:
61 def close(event=None):
62 if COME_BACK:
63 root.withdraw()
64 sleep(COME_BACK)
65 for child in root.children.values():
66 if isinstance(child, BoidGUI):
67 child.last_time += COME_BACK
68 root.deiconify()
69 # Create window based on settings.
70 if USE_WINDOW:
71 root.resizable(False, False)
72 root.title(TITLE)
73 width = WIDTH
74 height = HEIGHT
75 position = ''
76 elif FULLSCREEN:
77 root.overrideredirect(True)
78 if not SCR_SAVER:
79 root.bind_all('<Escape>', close)
80 width = root.winfo_screenwidth()
81 height = root.winfo_screenheight()
82 position = '+0+0'
83 else:
84 raise ValueError('Cannot determine window type to use.')
85 # Configure the root window as needed.
86 root.protocol('WM_DELETE_WINDOW', close)
87 if SCR_SAVER:
88 assert COME_BACK, 'Screen may not be locked as screensaver.'
89 root.bind_all('<Motion>', close)
90 root.bind_all('<Key>', close)
91 root.geometry('{0}x{1}{2}'.format(width, height, position))
92 # Create the application object that handles the GUI.
93 app = BoidGUI(root, width, height, BACKGROUND, BOIDS)
94 app.grid()
95 root.mainloop()
96
97################################################################################
98

Callers 1

recipe-576959.pyFile · 0.70

Calls 6

BoidGUIClass · 0.85
mainloopMethod · 0.80
TkClass · 0.50
titleMethod · 0.45
formatMethod · 0.45
gridMethod · 0.45

Tested by

no test coverage detected