def CreateApplication(self):
if os.path.exists("BEREMIZ_DEBUG"):
__builtin__.__dict__["BMZ_DBG"] = True
else:
__builtin__.__dict__["BMZ_DBG"] = False
global wx
import wx
if wx.VERSION >= (3, 0, 0):
self.app = wx.App(redirect=BMZ_DBG)
else:
self.app = wx.PySimpleApp(redirect=BMZ_DBG)
self.app.SetAppName('beremiz')
if wx.VERSION < (3, 0, 0):
wx.InitAllImageHandlers()
self.ShowSplashScreen()
self.BackgroundInitialization()
self.app.MainLoop()
python类PySimpleApp()的实例源码
def __init__(self, items, label=None):
# app = wx.PySimpleApp(0)
app = wx.App()
dlg = ui_choice2Dialog(None, -1, "")
nItems = len(items)
for i in range(nItems):
dlg.numListBox.Insert(str(items[i]),i)
dlg.denListBox.Insert(str(items[i]),i)
# app.SetTopWindow(dialog_1)
app.SetTopWindow(dlg)
if dlg.ShowModal() == wx.ID_OK:
self.numIndex = dlg.numListBox.GetSelections()
# print ' numIndex = ', self.numIndex
self.denIndex = dlg.denListBox.GetSelections()
self.numText = []
self.denText = []
for one in self.numIndex:
# print ' one = ', one
# self.numText.append(items[self.numIndex[one]])
self.numText.append(items[one])
for one in self.denIndex:
# self.denText.append(items[self.denIndex[one]])
self.denText.append(items[one])
dlg.Destroy()
def _test():
class TestDialog(wxSpellCheckerDialog):
def __init__(self,*args):
wxSpellCheckerDialog.__init__(self,*args)
wx.EVT_CLOSE(self,self.OnClose)
def OnClose(self,evnt):
chkr = dlg.GetSpellChecker()
if chkr is not None:
printf(["AFTER:", chkr.get_text()])
self.Destroy()
from enchant.checker import SpellChecker
text = "This is sme text with a fw speling errors in it. Here are a fw more to tst it ut."
printf(["BEFORE:", text])
app = wx.PySimpleApp()
dlg = TestDialog()
chkr = SpellChecker("en_US",text)
dlg.SetSpellChecker(chkr)
dlg.Show()
app.MainLoop()
def __do_layout(self):
# begin wxGlade: ui_choice2Dialog.__do_layout
sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
sizer_3 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_2.Add(self.numListBox, 1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 20)
sizer_2.Add(self.button_ok, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
sizer_3.Add(self.denListBox, 1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 20)
sizer_3.Add(self.button_cancel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_1.Add(sizer_3, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
# end of class ui_choice2Dialog
#if __name__ == "__main__":
#app = wx.PySimpleApp(0)
#wx.InitAllImageHandlers()
#ChiantiPy = ui_choice2Dialog(None, -1, "")
#app.SetTopWindow(ChiantiPy)
#ChiantiPy.Show()
#app.MainLoop()
def send_sms(self):
print "sending",self.NO_MOBILE_LIST
if self.NO_MOBILE_LIST:
msg="The following Student(s) got no valid mobile numbers. Go to Student Profile to add/edit mobile numbers\n"
no=0
for pupil in self.NO_MOBILE_LIST:
no+=1
msg+=str(no)+". "+str(pupil)+"\n"
#app = wx.PySimpleApp(0)
dlg = wx.MessageDialog(None, msg,"No Mobile Number",wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def Failed_Report(self):
if len(self.Failed_List)==0:
msg="All Students Passed"
else:
msg="The following Student(s) detained\n"
no=0
for pupil in self.Failed_List:
no+=1
msg+=str(no)+". "+str(pupil)+"\n"
#app = wx.PySimpleApp(0)
dlg = wx.MessageDialog(None, msg,str(self.class_)+self.div,wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def do(self):
#app = wx.PySimpleApp(0)
wcd="Excel Files(*.xls)|*.xls|"
dir = "/home"
save_dlg = wx.FileDialog(self.parent, message='Choose File to be Imported', defaultDir=dir, defaultFile= '', wildcard=wcd, style=wx.OPEN)
if save_dlg.ShowModal() == wx.ID_OK:
path = save_dlg.GetPath()
self.book = open_workbook(path)
self.current_sheet=self.book.sheet_by_index(0)
self.rown=self.current_sheet.nrows
self.DB=db_operations()
self.write_to_db()
save_dlg.Destroy()
print "extd"
def insureWxApp():
"""Create an instance of PySimpleApp if there is no app already.
This is required by wxPython before creating any GUI objects.
"""
global _wxApp
_wxApp = wx.GetApp()
if not _wxApp:
_wxApp = wx.PySimpleApp()
return _wxApp
def get_app_wx(*args, **kwargs):
"""Create a new wx app or return an exiting one."""
import wx
app = wx.GetApp()
if app is None:
if 'redirect' not in kwargs:
kwargs['redirect'] = False
app = wx.PySimpleApp(*args, **kwargs)
return app
def get_app_wx(*args, **kwargs):
"""Create a new wx app or return an exiting one."""
import wx
app = wx.GetApp()
if app is None:
if 'redirect' not in kwargs:
kwargs['redirect'] = False
app = wx.PySimpleApp(*args, **kwargs)
return app
def getlanguageDict():
languageDict = {}
if wx.VERSION >= (3, 0, 0):
app = wx.App()
else:
app = wx.PySimpleApp()
for lang in [x for x in dir(wx) if x.startswith("LANGUAGE")]:
i = wx.Locale(wx.LANGUAGE_DEFAULT).GetLanguageInfo(getattr(wx, lang))
if i:
languageDict[i.CanonicalName] = i.Description
return languageDict
def __init__(self):
#self.app = wx.PySimpleApp()
self.app = wx.App(False)
def get_app_wx(*args, **kwargs):
"""Create a new wx app or return an exiting one."""
import wx
app = wx.GetApp()
if app is None:
if 'redirect' not in kwargs:
kwargs['redirect'] = False
app = wx.PySimpleApp(*args, **kwargs)
return app
def get_app_wx(*args, **kwargs):
"""Create a new wx app or return an exiting one."""
import wx
app = wx.GetApp()
if app is None:
if 'redirect' not in kwargs:
kwargs['redirect'] = False
app = wx.PySimpleApp(*args, **kwargs)
return app