X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..93b663b8ccc9f82dd32d492c8a6081a8c75e8419:/wxPython/demo/demoMainLoop.py diff --git a/wxPython/demo/demoMainLoop.py b/wxPython/demo/demoMainLoop.py index e671c5c179..53aefda9be 100755 --- a/wxPython/demo/demoMainLoop.py +++ b/wxPython/demo/demoMainLoop.py @@ -1,5 +1,11 @@ #!/usr/bin/env python #--------------------------------------------------------------------------- +# 11/9/2003 - Jeff Grimmett (grimmtooth@softhome.net +# +# o Updated for V2.5 +# o Mainloop is freezing up app. +# + """ This demo attempts to override the C++ MainLoop and implement it in Python. This is not part of the demo framework. @@ -8,53 +14,51 @@ in Python. This is not part of the demo framework. THIS FEATURE IS STILL EXPERIMENTAL... """ - -from wxPython.wx import * import time - +import wx #--------------------------------------------------------------------------- -class MyFrame(wxFrame): +class MyFrame(wx.Frame): def __init__(self, parent, id, title): - wxFrame.__init__(self, parent, id, title, - wxPoint(100, 100), wxSize(160, 150)) + wx.Frame.__init__(self, parent, id, title, + (100, 100), (160, 150)) - EVT_SIZE(self, self.OnSize) - EVT_MOVE(self, self.OnMove) - EVT_CLOSE(self, self.OnCloseWindow) - EVT_IDLE(self, self.OnIdle) + self.Bind(wx.EVT_SIZE, self.OnSize) + self.Bind(wx.EVT_MOVE, self.OnMove) + self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) + self.Bind(wx.EVT_IDLE, self.OnIdle) self.count = 0 - panel = wxPanel(self, -1) - wxStaticText(panel, -1, "Size:", - wxDLG_PNT(panel, wxPoint(4, 4)), wxDefaultSize) - wxStaticText(panel, -1, "Pos:", - wxDLG_PNT(panel, wxPoint(4, 16)), wxDefaultSize) + panel = wx.Panel(self, -1) + wx.StaticText(panel, -1, "Size:", + wx.DLG_PNT(panel, (4, 4)), wx.DefaultSize) + wx.StaticText(panel, -1, "Pos:", + wx.DLG_PNT(panel, (4, 16)), wx.DefaultSize) - wxStaticText(panel, -1, "Idle:", - wxDLG_PNT(panel, wxPoint(4, 28)), wxDefaultSize) + wx.StaticText(panel, -1, "Idle:", + wx.DLG_PNT(panel, (4, 28)), wx.DefaultSize) - self.sizeCtrl = wxTextCtrl(panel, -1, "", - wxDLG_PNT(panel, wxPoint(24, 4)), - wxDLG_SZE(panel, wxSize(36, -1)), - wxTE_READONLY) + self.sizeCtrl = wx.TextCtrl(panel, -1, "", + wx.DLG_PNT(panel, (24, 4)), + wx.DLG_SZE(panel, (36, -1)), + wx.TE_READONLY) - self.posCtrl = wxTextCtrl(panel, -1, "", - wxDLG_PNT(panel, wxPoint(24, 16)), - wxDLG_SZE(panel, wxSize(36, -1)), - wxTE_READONLY) + self.posCtrl = wx.TextCtrl(panel, -1, "", + wx.DLG_PNT(panel, (24, 16)), + wx.DLG_SZE(panel, (36, -1)), + wx.TE_READONLY) - self.idleCtrl = wxTextCtrl(panel, -1, "", - wxDLG_PNT(panel, wxPoint(24, 28)), - wxDLG_SZE(panel, wxSize(36, -1)), - wxTE_READONLY) + self.idleCtrl = wx.TextCtrl(panel, -1, "", + wx.DLG_PNT(panel, (24, 28)), + wx.DLG_SZE(panel, (36, -1)), + wx.TE_READONLY) def OnCloseWindow(self, event): - app.keepGoing = false + app.keepGoing = False self.Destroy() def OnIdle(self, event): @@ -74,7 +78,7 @@ class MyFrame(wxFrame): #--------------------------------------------------------------------------- -class MyApp(wxApp): +class MyApp(wx.App): def MainLoop(self): # This outer loop determines when to exit the application, for # this example we let the main frame reset this flag when it @@ -93,7 +97,7 @@ class MyApp(wxApp): while self.Pending(): self.Dispatch() - # Send idle events to idle handlers. You may want to throtle + # Send idle events to idle handlers. You may want to throttle # this back a bit so there is not too much CPU time spent in # the idle handlers. For this example, I'll just snooze a # little... @@ -103,16 +107,16 @@ class MyApp(wxApp): def OnInit(self): - frame = MyFrame(NULL, -1, "This is a test") - frame.Show(true) + frame = MyFrame(None, -1, "This is a test") + frame.Show(True) self.SetTopWindow(frame) - self.keepGoing = true + self.keepGoing = True - return true + return True -app = MyApp(0) +app = MyApp(False) app.MainLoop()