Hi,
I am a newbie at wxPython GUI programming, so please excuse my ignorance.
I have created a frame with two controls on it: a ListCtrl and an Editor control. I would like the two controls to 'interact'. For instance, when I double-click on an item in the ListCtrl, I would like the entry text to appear in the Editor control.
I am currently using the following to capture this event in the main frame code:
Is this binding [self.Bind(wx.EVT_*)] the usual way to capture events in constituent controls? Is there a better way? Any ideas as to why the second form of the command doesn't work?
Hi,
I am a newbie at wxPython GUI programming, so please excuse my ignorance.
I have created a frame with two controls on it: a ListCtrl and an Editor control. I would like the two controls to 'interact'. For instance, when I double-click on an item in the ListCtrl, I would like the entry text to appear in the Editor control.
I am currently using the following to capture this event in the main frame code:
Hmmm... It should still work, unless the code sending the event is not setting the ID in the event or something like that...
Is this binding [self.Bind(wx.EVT_*)] the usual way to capture events in constituent controls? Is there a better way?
You could bind the event directly to the listctrl by using self.mylistcontrol.Bind(...), or you could catch the lower level mouse event (wx.EVT_LEFT_DLCICK) before it even gets to the control. Or you could bind the listctrl's EVT_LIST_ITEM_ACTIVATED event which should be sent when an item is either double clicked or the user presses either space or enter (depending on platform) on an item.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
You could bind the event directly to the listctrl by using
self.mylistcontrol.Bind(...), or you could catch the lower level mouse
event (wx.EVT_LEFT_DLCICK) before it even gets to the control. Or you
could bind the listctrl's EVT_LIST_ITEM_ACTIVATED event which should be
sent when an item is either double clicked or the user presses either
space or enter (depending on platform) on an item.
Hi Robin,
I tried to 'self.mylistcontrol.Bind(...)' form and that seems to work.
I am not familiar with how to catch the lower level mouse event before it
reaches the control. Can anyone share some light?
Also, when using barcode reader as an input to a Frame/Dialog,
I would like to receive and process the key events no matter where the
current focus is at. Currently my frame has only a listCtrl and a few
buttons. I need to register handler with listCtrl for the key events. Is
there a better way to catch the key events on the frame level, instead of a
particular control?
Lastly, anyone know about a python module to work with UBS port? In the
previous scenario, I have the barcode reader hooked up with my keyboard
port. However, I suspect that I can't have ant other text controls which
also accept keyboard input. I wouldn't be able to distinguish whether it is
from keyboard or barcode reader.
Thanks in advance of any advice.
-JC
Robin Dunn wrote:
<snip>
You could bind the event directly to the listctrl by using
self.mylistcontrol.Bind(...), or you could catch the lower level mouse
event (wx.EVT_LEFT_DLCICK) before it even gets to the control. Or you
could bind the listctrl's EVT_LIST_ITEM_ACTIVATED event which should be
sent when an item is either double clicked or the user presses either
space or enter (depending on platform) on an item.
Hi Robin,
I tried to 'self.mylistcontrol.Bind(...)' form and that seems to work.
Thanks!
-g
···
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Also, when using barcode reader as an input to a Frame/Dialog,
I would like to receive and process the key events no matter where the
current focus is at. Currently my frame has only a listCtrl and a few
buttons. I need to register handler with listCtrl for the key events. Is
there a better way to catch the key events on the frame level, instead of a
particular control?
Key and char events are only delivered to the window that has the keyboard focus. You can use keyboard accelerators to catch keys at the frame level like menuitem shortcuts, but it is not really suited for what you want.
What would work is to create a new class derived from wx.EvtHandler that binds a method to wx.EVT_CHAR (or wx.EVT_KEY_DOWN if that is what you need) and that method can just reflect the event to the method in the frame where you want to handle the key events. Then you "push" and instance of this class onto every control tha can have the focus with control.PushEventHandler. Then wherever the focus is at the key events will be delivered to a method of the frame.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!