The Py module frame.py in wx.py has a good example how to use UPDATE_UI events. While running a couple of tests, we noticed that that these events are generated almost continuously. Even after the window is idle or minimized or looses focus.
Question: is this the expected behavior for UPDATE_UI events? If so, why?
Yes. They are sent as part of the app's idle processing, so they follow the same rules as idle events. In 2.5 there are some alternatives to reduce the overhead, you can specify that update events go only to the windows you specify, or you can reduce the frquency that they are sent.
PS) To reproduce the problem, just add a print statement at the top or end of the try-except block in the OnUpdateMenu() method, near the bottom of the wx.py.frame.py module and then run "pyshell" or "python PyShell.py".
In this case you will probably make them happen even more than normal as every time there is a print statement that outputs to the pyshell window there is a refresh and then the event queue becomes empty again and so idle events are sent, which causes another print...
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Interesting ... We had expected that an UPDATE_UI event would only be sent to a menu and its menu items when that menu was about to be popped up or pulled down. What is the point of keeping the menu up to date if it is not displayed?
Just curious, if we do not call wx.EVT_UPDATE_UI() would that result in less overhead in wxpython 2.4?
Also, the output of a regular print statement only shows up in the pyshell window if stdout is redirected explicitly. By default, stdout and stderr are not redirected.
/Jean Brouwers
Robin Dunn wrote:
···
Jean Brouwers wrote:
The Py module frame.py in wx.py has a good example how to use UPDATE_UI events. While running a couple of tests, we noticed that that these events are generated almost continuously. Even after the window is idle or minimized or looses focus.
Question: is this the expected behavior for UPDATE_UI events? If so, why?
Yes. They are sent as part of the app's idle processing, so they follow the same rules as idle events. In 2.5 there are some alternatives to reduce the overhead, you can specify that update events go only to the windows you specify, or you can reduce the frquency that they are sent.
PS) To reproduce the problem, just add a print statement at the top or end of the try-except block in the OnUpdateMenu() method, near the bottom of the wx.py.frame.py module and then run "pyshell" or "python PyShell.py".
In this case you will probably make them happen even more than normal as every time there is a print statement that outputs to the pyshell window there is a refresh and then the event queue becomes empty again and so idle events are sent, which causes another print...