Determine state of control key (either down or up)
I am using a wxPython script as a front end to FastStone File Viewer. I am using an instance of AutoItX as the interface. I have a folder with a large number of images that are grouped in sets with names of the form
base name ####.jpg
In order to avoid cluttering up the display, all images are initially hidden. The wxPython script scans the folder and creates a vertical wx.ListBox along the right edge of the display showing one base name per line. Clicking on a base name will
- Hide the previously displayed group (if any)
- Unhide the newly selected group
- Refresh the FastStone Viewer file list display
- Show the first image in the list
Everything works just fine. Now I want to add some more functionality. I want to be able to select more than one group at a time. My plan was to allow the user to CTRL-Click on a list item. This would prevent any previously selected item(s) from being hidden.
My initial stab at this was to use
but this was causing the control key state to toggle leaving my keyboard in an unusable state.
My second stab was to use keyboard events in the panel to maintain my own keyboard state as
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) . . . def OnKeyDown(self, evt): self.control = evt.ControlDown() def OnKeyUp(self, evt): self.control = evt.ControlDown()
The problem with this approach is that at the time I click on a new list item FastStone has focus so pressing the control key causes that event to go to FastStone rather than my script.
My question (and I do have one) is, is there any way in wxPython to detect the state of the control key that
- Does not rely on detecting the event
- Does not leave the key in the “down” state