blob: eab2e66b4b12f5485f6024129b37fbe0255a1190 (
plain)
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
|
# application.py
import wx
import sys
#from waxconfig import WaxConfig
#import font
class Application(wx.App):
def __init__(self, frameklass, *args, **kwargs):
# takes a frame *class* plus arbitrary options. these options will
# be passed to the frame constructor.
self.frameklass = frameklass
self.args = args
self.kwargs = kwargs
# when set, the app uses the stdout/stderr window; off by default
use_stdout_window = 0
if kwargs.has_key('use_stdout_window'):
use_stdout_window = kwargs['use_stdout_window']
del kwargs['use_stdout_window']
wx.App.__init__(self, use_stdout_window)
def OnInit(self):
if isinstance(WaxConfig.default_font, tuple):
WaxConfig.default_font = font.Font(*WaxConfig.default_font)
else:
print >> sys.stderr, "Warning: This construct will not work in future wxPython versions"
self.mainframe = self.frameklass(*self.args, **self.kwargs)
if hasattr(self.mainframe.__class__, "__ExceptHook__"):
sys.excepthook = self.mainframe.__ExceptHook__
self.mainframe.Show(True)
self.SetTopWindow(self.mainframe)
return True
def Run(self):
self.MainLoop()
|