I want to be able to perform a specific action with a selected item in a
Combobox, for instance when double clicking it.
The related event, EVT_LEFT_DCLICK , seems not to work in the
combobox. Actually, the only event that seems to work in the combobox
text field is EVT_MOTION, but only when I get into it or out of it.
I need some way to click on a selected item of a combobox in a special
way (right click, double click or whatever) and perform a special
action.
I have been working on this for some days with no avail.
I would appreciate a solution to this issue.
I provide a small sample code to verify what I say above.
thanks
antonio
sample code:
from wxPython.wx import *
class MainFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, "EVT_MOTION Test")
self.SetSize(wxSize(400, 380))
self.panel = wxPanel (self, -1)
EVT_CLOSE(self, self.OnCloseWindow)
EVT_MOTION (self.panel, self.panel_motion)
EVT_LEFT_DOWN (self.panel, self.panel_left_down)
EVT_LEFT_DCLICK (self.panel, self.panel_left_dclick)
EVT_LEFT_UP (self.panel, self.panel_left_up)
self.button = wxButton (self.panel, -1, 'A Button',
pos=(100,100))
EVT_MOTION (self.button, self.button_motion)
EVT_LEFT_DOWN (self.button, self.button_left_down)
EVT_LEFT_DCLICK (self.button, self.button_left_dclick)
EVT_LEFT_UP (self.button, self.button_left_up)
EVT_BUTTON (self.button, self.button.GetId (),
self.button_clicked)
self.cb= wxComboBox(self.panel, -1,
"",
choices=["aaaaa","bbbbb","cccc"],
pos=(-1,-1),# default
size=(-1,-1),# default
style=wxCB_SIMPLE # creates a combobox with
a drom-down list
)
EVT_MOTION (self.cb, self.cb_motion)
EVT_LEFT_DOWN (self.cb, self.cb_left_down)
EVT_LEFT_DCLICK (self.cb, self.cb_left_dclick)
EVT_LEFT_UP (self.cb, self.cb_left_up)
EVT_BUTTON (self.cb, self.cb.GetId (), self.cb_clicked)
EVT_LEFT_DCLICK (self.cb, self.cb_left_dclick)
def OnCloseWindow(self, event):
self.Destroy()
def panel_motion (self, event):
print 'Panel motion'
def panel_left_down (self, event):
print 'Panel left down'
def panel_left_dclick (self, event):
print 'Panel left dclick'
def panel_left_up (self, event):
print 'Panel left up'
def button_motion (self, event):
print 'Button motion'
def button_left_down (self, event):
print 'Button left down'
def button_left_dclick (self, event):
print 'Button left dclick'
def button_left_up (self, event):
print 'Button left up'
def button_clicked (self, event):
print 'Button clicked'
def cb_clicked (self, event):
print 'CB clicked'
def cb_motion (self, event):
print 'CB motion'
def cb_left_down (self, event):
print 'CB left down'
def cb_left_dclick (self, event):
print 'CB left dclick'
def cb_left_up (self, event):
print 'CB left up'
def cb_clicked (self, event):
print 'CB clicked'
class TestApp(wxApp):
def OnInit(self):
self.frame = MainFrame()
self.frame.Show(True)
self.SetTopWindow(self.frame)
return True
app = TestApp(0)
app.MainLoop()
Antonio Aranda Germany