wx.EventLoop is now implemented for wxMac.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36857 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,6 +20,7 @@ The following deprecated items have been removed:
|
|||||||
|
|
||||||
* wx.FontMapper SetConfig method
|
* wx.FontMapper SetConfig method
|
||||||
|
|
||||||
|
wx.EventLoop is now implemented for wxMac.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -67,44 +67,39 @@ class MyFrame(wx.Frame):
|
|||||||
class MyApp(wx.App):
|
class MyApp(wx.App):
|
||||||
def MainLoop(self):
|
def MainLoop(self):
|
||||||
|
|
||||||
if "wxMac" in wx.PlatformInfo:
|
# Create an event loop and make it active. If you are
|
||||||
# TODO: Does wxMac implement wxEventLoop yet???
|
# only going to temporarily have a nested event loop then
|
||||||
wx.App.MainLoop()
|
# you should get a reference to the old one and set it as
|
||||||
|
# the active event loop when you are done with this one...
|
||||||
|
evtloop = wx.EventLoop()
|
||||||
|
old = wx.EventLoop.GetActive()
|
||||||
|
wx.EventLoop.SetActive(evtloop)
|
||||||
|
|
||||||
else:
|
# This outer loop determines when to exit the application,
|
||||||
# Create an event loop and make it active. If you are
|
# for this example we let the main frame reset this flag
|
||||||
# only going to temporarily have a nested event loop then
|
# when it closes.
|
||||||
# you should get a reference to the old one and set it as
|
while self.keepGoing:
|
||||||
# the active event loop when you are done with this one...
|
# At this point in the outer loop you could do
|
||||||
evtloop = wx.EventLoop()
|
# whatever you implemented your own MainLoop for. It
|
||||||
old = wx.EventLoop.GetActive()
|
# should be quick and non-blocking, otherwise your GUI
|
||||||
wx.EventLoop.SetActive(evtloop)
|
# will freeze.
|
||||||
|
|
||||||
# This outer loop determines when to exit the application,
|
# call_your_code_here()
|
||||||
# for this example we let the main frame reset this flag
|
|
||||||
# when it closes.
|
|
||||||
while self.keepGoing:
|
|
||||||
# At this point in the outer loop you could do
|
|
||||||
# whatever you implemented your own MainLoop for. It
|
|
||||||
# should be quick and non-blocking, otherwise your GUI
|
|
||||||
# will freeze.
|
|
||||||
|
|
||||||
# call_your_code_here()
|
|
||||||
|
|
||||||
|
|
||||||
# This inner loop will process any GUI events
|
# This inner loop will process any GUI events
|
||||||
# until there are no more waiting.
|
# until there are no more waiting.
|
||||||
while evtloop.Pending():
|
while evtloop.Pending():
|
||||||
evtloop.Dispatch()
|
evtloop.Dispatch()
|
||||||
|
|
||||||
# Send idle events to idle handlers. You may want to
|
# Send idle events to idle handlers. You may want to
|
||||||
# throttle this back a bit somehow so there is not too
|
# throttle this back a bit somehow so there is not too
|
||||||
# much CPU time spent in the idle handlers. For this
|
# much CPU time spent in the idle handlers. For this
|
||||||
# example, I'll just snooze a little...
|
# example, I'll just snooze a little...
|
||||||
time.sleep(0.10)
|
time.sleep(0.10)
|
||||||
self.ProcessIdle()
|
self.ProcessIdle()
|
||||||
|
|
||||||
wx.EventLoop.SetActive(old)
|
wx.EventLoop.SetActive(old)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
%newgroup
|
%newgroup
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#ifdef __WXMAC__
|
#if 0 // #ifdef __WXMAC__
|
||||||
|
|
||||||
// A dummy class that raises an exception if used...
|
// A dummy class that raises an exception if used...
|
||||||
class wxEventLoop
|
class wxEventLoop
|
||||||
@@ -72,4 +72,17 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// This object sets the wxEventLoop given to the ctor as the currently active
|
||||||
|
// one and unsets it in its dtor, this is especially useful in presence of
|
||||||
|
// exceptions but is more tidy even when we don't use them
|
||||||
|
class wxEventLoopActivator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxEventLoopActivator(wxEventLoop *evtLoop);
|
||||||
|
~wxEventLoopActivator();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user