wx.ComboBox

J. Raichouni j.raichouni at sector.de
Fri Dec 1 12:37:02 PST 2006


Hello!

This is my first email to you, i hope it will reach you.
Sorry for my bad english, i'm german.

I've a problem with wx.ComboBox (See example below).
There are to ComboBoxes (both with initial parameter choices =
['Mustermann', 'Musterfrau']
Why is'nt it possible to set initial paramter value = 'Muster' but i can set
value = 'Test'?

Same problem exists by setting the value during runtime with the method
SetValue('Muster')

Regard and looking forward to a solution
Jamil

-------------------------------------
# -*- coding: iso-8859-1 -*-
# File: test.py
import wx
#------------------------------------------------------------------------

class MyFrame(wx.Dialog):
    def __init__(self, parent, title):
        wx.Dialog.__init__(self, parent, -1, title,
                          pos=(150, 150), size=(300, 350))

        panel = wx.Panel(self, -1)
       
        obj1 = wx.ComboBox(parent=panel, size=(200, wx.DefaultSize.height), 
                                    choices=['Mustermann', 'Musterfrau'],
                                    value='Test', 
                                    style=wx.CB_DROPDOWN)

        obj2 = wx.ComboBox(parent=panel, size=(200, wx.DefaultSize.height), 
                                    choices=['Mustermann', 'Musterfrau'],
                                    value='Muster', 
                                    style=wx.CB_DROPDOWN)
        
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(obj1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 15)
        main_sizer.Add(obj2, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 15)

        panel.SetSizer(main_sizer)
        main_sizer.Fit(self)
 
#------------------------------------------------------------------------


#------------------------------------------------------------------------ 
class MyApp(wx.App):
    def OnInit(self):
        dialog = MyFrame(None, 'Titel')
        if dialog.ShowModal() == wx.ID_OK:
            print dialog.object.GetDate() 
        return True
        
app = MyApp(0)
app.MainLoop()





More information about the wxpython-users mailing list