Re: wx.ComboBox choices

"Werner F. Bruhin" <[email protected]>
Newsgroups gmane.comp.ide.boa-constructor.user
Message-ID <[email protected]>
hpvpl wrote:
> Hi,
> 
> I have a small problem with Boa and ComboBox Choices fields. This not a 
> bug. More a "how-to" question.
> By default the wx.ComboBox is created with a choice=[].
> 
> In my code I create a list (self.myList) and would like to pass this 
> list into the ComboBox when initialized.
> When I try to put the self.myList into the Choices field of my ComboBox 
> I get the following error:
>  _your_frame_attrs_ instance has no attribute 'myList'
Without seeing the code I can't say what is wrong.

Just a guess, are you creating your myList after _init_ctrls and try to 
use it before, i.e. in Boa generated code?

> 
> This is a dummy question ... but I can't find any answer on the forum.
> 
> Any idea ?
Attached is a small sample, hope this helps.

Werner
> 
> In any case Boa constructor is really a flexible and very usefull 
> wx.pyhton RAD tool.
> 
> Thanks and congratulation. !!
> 
> Cheers
> 
> Vpl
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Boa-constructor-users mailing list
> Boa-constructor-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/boa-constructor-users

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08

_______________________________________________
Boa-constructor-users mailing list
Boa-constructor-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/boa-constructor-users
choiceSample.py (text/x-python, 1.2 KB)
#Boa:Frame:Frame1

import wx

def create(parent):
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1COMBOBOX1, wxID_FRAME1PANEL1, 
] = [wx.NewId() for _init_ctrls in range(3)]

class Frame1(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(622, 307), size=wx.Size(400, 250),
              style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
        self.SetClientSize(wx.Size(384, 214))

        self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
              pos=wx.Point(0, 0), size=wx.Size(384, 214),
              style=wx.TAB_TRAVERSAL)

        self.comboBox1 = wx.ComboBox(choices=[], id=wxID_FRAME1COMBOBOX1,
              name='comboBox1', parent=self.panel1, pos=wx.Point(56, 32),
              size=wx.Size(130, 21), style=0, value=u'')
        self.comboBox1.SetLabel(u'')

    def __init__(self, parent):
        self._init_ctrls(parent)
        myList = list()
        myList.append('item1')
        myList.append('item2')
        myList.append('item3')
        self.comboBox1.AppendItems(myList)


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = create(None)
    frame.Show()

    app.MainLoop()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.