Combobox error

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()

I don’t see any easy answer to what is causing this. You could try importing the sub-packages one at a time and see which one is causing the problem.

···

On Mon, Aug 10, 2009 at 6:45 PM, Ben benjamin.rottman@gmail.com wrote:

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()


“A government big enough to give us everything we want is a government big enough to take from us everything we have.”
-Gerald Ford

Hi Ben,

···

On Aug 10, 5:45 pm, Ben <benjamin.rott...@gmail.com> wrote:

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()

Man, this required a ton of dependencies (PIL, scipy, numpy and
psychopy). I got it all installed on my VM and ran your sample code
and it worked just fine. I am using Python 2.5, wxPython 2.8.7.1 on
Windows XP. What are you using?

- Mike

Wow, thanks for spending the time to do that! I am running Mac OS
10.5.7, Python 2.5, and wx-2.8. (Honestly, I don't actually know the
proper way to check the version of wxpthon, but the folder containing
all the wx files is called wx-2.8).

I can also ask the psychopy people, but I thought you guys might have
a better clue of the problem. Are there any standards that I should
know about using multiple packages that may conflict? The psychopy
examples usually use "from psychopy import *" but I instead import all
the modules separately (i.e. import psychopy.visual) to avoid name
conflicts.

Thanks for your effort!
-Ben

···

On Aug 11, 10:49 am, Mike Driscoll <kyoso...@gmail.com> wrote:

Hi Ben,

On Aug 10, 5:45 pm, Ben <benjamin.rott...@gmail.com> wrote:

> 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()

Man, this required a ton of dependencies (PIL, scipy, numpy and
psychopy). I got it all installed on my VM and ran your sample code
and it worked just fine. I am using Python 2.5, wxPython 2.8.7.1 on
Windows XP. What are you using?

- Mike

Hi Joshua,

Thanks for your thoughts. I tried importing the subpackages
separately, but they seem to depend upon one another, so I couldn't
isolate it down. I will try to contact the psychopy people.

Thanks,
Ben

···

On Aug 10, 9:56 pm, Joshua Huber <jlhub...@gmail.com> wrote:

I don't see any easy answer to what is causing this. You could try importing
the sub-packages one at a time and see which one is causing the problem.

On Mon, Aug 10, 2009 at 6:45 PM, Ben <benjamin.rott...@gmail.com> wrote:

> 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()

--
"A government big enough to give us everything we want is a government big
enough to take from us everything we have."
-Gerald Ford

Hi Ben,

Wow, thanks for spending the time to do that! I am running Mac OS
10.5.7, Python 2.5, and wx-2.8. (Honestly, I don't actually know the
proper way to check the version of wxpthon, but the folder containing
all the wx files is called wx-2.8).

The "proper" way is to call wx.version()

I can also ask the psychopy people, but I thought you guys might have
a better clue of the problem. Are there any standards that I should
know about using multiple packages that may conflict? The psychopy
examples usually use "from psychopy import *" but I instead import all
the modules separately (i.e. import psychopy.visual) to avoid name
conflicts.

This was my first thought, that you had done a "from something import
*" and poisoned the namespace. I still think there may be something
like that going on here, but I'm not seeing anything obvious. You
might try using a debugger like pdb or Wing's IDE to see if the
methods work as you expect them to.

Thanks for your effort!
-Ben

Good luck,

- Mike

···

On Aug 11, 8:54 pm, Ben <benjamin.rott...@gmail.com> wrote:

On Aug 11, 10:49 am, Mike Driscoll <kyoso...@gmail.com> wrote:

> Hi Ben,

> On Aug 10, 5:45 pm, Ben <benjamin.rott...@gmail.com> wrote:

> > 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()

> Man, this required a ton of dependencies (PIL, scipy, numpy and
> psychopy). I got it all installed on my VM and ran your sample code
> and it worked just fine. I am using Python 2.5, wxPython 2.8.7.1 on
> Windows XP. What are you using?

> - Mike