I’m new to wxpython and so far finding it pretty good. Mainly because Glade (came with Stani’s Python Editor) makes GUI design and moding much easier than hand hacking tkinter code. I have some questions about idle time:
If an idle event causes a handler function to be invoked does the window freeze (ie not respond to mouse clicks etc) until the handler returns?
Assuming the window does not freeze (or unfrozen via a yield() call which I assume turns the function into a generator a la python) could the handler be re-entered in the following scenario:
a. idle event causes handler to be entered
b. while running some event happens, eg click on a button, which does something and then finishes putting the window into the idle state again and hence the issuing of another idle event.
c. this event propagates through the event tables as before and causes a second instance of the idle handler to be started.
So I now have two handler events running. This would not be what I want and would put an instance count into the handler class and return immediately if an instance was already running.
How would you advise using wxPython as a GUI front end to an app that needs continuous running. eg monitoring and responding to a serial port stream. I found tkinter far to slow to do everything in the idle loop. So I did the serial port stuff in a separate thread and queued messages for the GUI to/from an idle handler. No speed problems now and GUI update fast enough.
Hi all,
I'm new to wxpython and so far finding it pretty good. Mainly because Glade (came with Stani's Python Editor) makes GUI design and moding much easier than hand hacking tkinter code. I have some questions about idle time:
1. If an idle event causes a handler function to be invoked does the window freeze (ie not respond to mouse clicks etc) until the handler returns?
Yes. The idle event handlers are called in the same thread as any other event handler, and so just as in those cases the handler needs to return in order for more events to be sent.
2. Assuming the window does not freeze (or unfrozen via a yield() call which I assume turns the function into a generator a la python) could the handler be re-entered in the following scenario:
a. idle event causes handler to be entered
b. while running some event happens, eg click on a button, which does something and then finishes putting the window into the idle state again and hence the issuing of another idle event.
c. this event propagates through the event tables as before and causes a second instance of the idle handler to be started.
While any event handler is running no more events are dispatched unless you do something that allows them to be. For example, calling wx.Yield() (or any of the similar functions) will essentially run iterations of the MainLoop until there are no more pending events, and wx.Dialog.ShowModal will enter a nested event loop that restricts mouse and UI interaction to the dialog, but other kinds of events (paint, timers, idle, etc.) can still be sent to other windows.
So I now have two handler events running. This would not be what I want and would put an instance count into the handler class and return immediately if an instance was already running.
3. How would you advise using wxPython as a GUI front end to an app that needs continuous running. eg monitoring and responding to a serial port stream. I found tkinter far to slow to do everything in the idle loop. So I did the serial port stuff in a separate thread and queued messages for the GUI to/from an idle handler. No speed problems now and GUI update fast enough.