I have a searchctrl that feeds the user's search into a separate thread for
processing. The search history (a menu that drops down from the searchctrl, like
in the demo code) is updated using feedback from this second thread, because I
only want to populate it with values that produce a useful search. However, this
means that updating of the search history can occur when the user has the menu
open, which seems to cause the application to crash - or when the application
survives, at the very least the search history dies.
I'm looking for a way of locking the search history when the user has the menu
open, but I can't find the methods that handle it. My theory was that I could
simply set menu_locked to True when the user opens the menu, and False when they
close it, but I can't work out how to detect when the user has opened/closed the
menu.
If anyone can help me out it would be enormously appreciated.
I have a searchctrl that feeds the user's search into a separate thread for
processing. The search history (a menu that drops down from the searchctrl, like
in the demo code) is updated using feedback from this second thread, because I
only want to populate it with values that produce a useful search. However, this
means that updating of the search history can occur when the user has the menu
open, which seems to cause the application to crash - or when the application
survives, at the very least the search history dies.
I'm looking for a way of locking the search history when the user has the menu
open, but I can't find the methods that handle it. My theory was that I could
simply set menu_locked to True when the user opens the menu, and False when they
close it, but I can't work out how to detect when the user has opened/closed the
menu.
There's EVT_MENU_OPEN and EVT_MENU_CLOSED, but I think those are only sent when a menu bar opens a submenu... Instead you could probably just change when you update the menu to times when you know it's safe to do so, such as just after a previoius menu item has been selected, or when you get text events from the search ctrl.
ยทยทยท
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!