[wxPython-users] combobox problem
Thippana, Prasoonadevi
pthippan at mc.com
Tue Nov 20 09:14:13 PST 2007
Thank you very much
________________________________
From: C M [mailto:cmpython at gmail.com]
Sent: Monday, November 19, 2007 4:48 PM
To: wxPython-users at lists.wxwidgets.org
Subject: Re: [wxPython-users] combobox problem
On Nov 19, 2007 4:23 PM, Thippana, Prasoonadevi <pthippan at mc.com> wrote:
Hi,
Can somebody help me with the combobox problem.When I start the
my GUI application, it should upload all the directories from the path
into the combo box.
I created 2 directories in my path. When I run this program, it
Sets up one directory and when I click it, it just disappears.
Thanks in advance for the help.
---------------------------------------------------------------------
To unsubscribe, e-mail:
wxPython-users-unsubscribe at lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help at lists.wxwidgets.org
Your program was adding each entry to the combobox as the displayed
value
in the textbox but not creating a list for the combobox to hold all the
items. So
you only saw the last one added.
You can just append each new entry to a growing list and then use
comboBox.SetItems(list) as below...
import wx
import os, sys
import string
import re
import wx.lib.dialogs
class MyFrame1(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self,
parent,-1,title,wx.DefaultPosition,wx.Size(450,200))
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition,
wx.DefaultSize)
self.samplelist = []
self.combo1=
wx.ComboBox(self.mainpa,-1,"",(120,70),(105,-1),self.samplelist,
wx.CB_DROPDOWN)
path=os.getcwd()
for entry in os.listdir(path):
if os.path.isdir(entry):
print 'entry %s' % entry
self.samplelist.append(entry)
self.combo1.SetItems(self.samplelist)
ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(300,100))
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame1(None, -1, 'Make Directory Structure')
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20071120/a54df961/attachment.htm
More information about the wxpython-users
mailing list