Hi,
I'm new to Python and wx, so sorry if this question is naive. I am
using wx in combination with a package designed for presenting stimuli
for psychology presentations (psychopy). When I use the combobox
widget without importing psychopy, it works fine. But when I import
all the necessary psychopy modules, combobox no longer works.
Specifically, when I make a selection in combobox, it does not display
the selection - it is as if I never made the selection. (No error
messages are produced.) My best guess is that OnSelect is not working
properly, but I can't figure out how to fix this. Any help is greatly
appreciated!
Ben
Some sample code I am using is below:
import psychopy.visual
import wx
class MyDialog(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, size=(250, 270))
options = ['1', '2', '3' ]
self.cb=wx.ComboBox(self, -1, pos=(50, 170), size=(150, -1),
choices=options, style=wx.CB_READONLY)
wx.Button(self, 1, 'Close', (80, 220))
self.Bind(wx.EVT_BUTTON, self.OnClose, id=1)
self.Bind(wx.EVT_COMBOBOX, self.OnSelect)
self.Centre()
def OnClose(self, event):
self.Close()
print self.cb.GetCurrentSelection()
def OnSelect(self, event):
item = event.GetSelection()
class MyApp(wx.App):
def OnInit(self):
dlg = MyDialog(None, -1, 'combobox.py')
dlg.ShowModal()
dlg.Destroy()
return True
app = MyApp(0)
app.MainLoop()