This is my first application in Boa Constructor and my first time using wxPython.
#Boa:Frame:Frame1
import wx
choiceList = ['DAR', 'Impex', 'Endon', 'Astro', 'Ansell', 'Other']
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1BUTTONSELECTDIR, wxID_FRAME1BUTTONSELECTFILE,
wxID_FRAME1CHOICESUPPLIER,
] = [wx.NewId() for _init_ctrls in range(4)]
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(517, 20), size=wx.Size(400, 492),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(392, 458))
self.choiceSupplier = wx.Choice(choices=choiceList, id=wxID_FRAME1CHOICESUPPLIER,
name=u'choiceSupplier', parent=self, pos=wx.Point(48, 176),
size=wx.Size(120, 21), style=0)
self.choiceSupplier.Bind(wx.EVT_CHOICE, self.OnChoiceSupplierChoice,
id=wxID_FRAME1CHOICESUPPLIER)
def __init__(self, parent):
self._init_ctrls(parent)
def OnChoiceSupplierChoice(self, event):
supplier = choiceList[self.choiceSupplier.GetSelection()]
print supplier
My code runs fine when I click run application. However when I try to edit it in designer I get an error:
16:17:06: Traceback (most recent call last):
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Models\wxPythonControllers.py", line 78, in OnDesigner self.showDesigner()
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Models\wxPythonControllers.py", line 143, in showDesigner designer.refreshCtrl()
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Views\Designer.py", line 399, in refreshCtrl self.initObjectsAndCompanions(objCol.creators[1:], objCol, deps, depLnks)
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Views\InspectableViews.py", line 127, in initObjectsAndCompanions self.initObjCreator(constr)
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Views\Designer.py", line 529, in initObjCreator InspectableObjectView.initObjCreator(self, constrPrs)
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Views\InspectableViews.py", line 155, in initObjCreator constrPrs.comp_name, constrPrs.params)
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Views\Designer.py", line 483, in loadControl compClass=CtrlCompanion, evalDct=self.model.specialAttrs)
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\Views\Designer.py", line 62, in setupArgs args = InspectableObjectView.setupArgs(self, ctrlName, params, dontEval, evalDct=evalDct)
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\View \InspectableViews.py", line 63, in setupArgs evalDct)
16:17:06: File "C:\Python27\Lib\site-packages\boa-constructor\PaletteMapping.py", line 158, in evalCtrl return eval(expr, globals(), localsDct)
16:17:06: File "<string>", line 1, in <module>
16:17:06: NameError: name 'choiceList' is not defined
Stumbled across this question while looking for something else boa-constructor related, sorry if answering to kinda-dead posts here is considered faux pas, I'm new here.
Anyway, my best guess is you messed with the _init_ctrls yourself even tho there's that "don't edit" comment. Tried that one myself a couple times, well boa doesn't handle that too well. After changing
to
you can enter the designer once again, and to be able to have that AND populate the wx.Choice item I moved the list inside the init :
Probably the issue is how the designer session analyzes the file, missing out on the list that's external to the class.