这是我在 Boa Constructor 中的第一个应用程序,也是我第一次使用 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
单击运行应用程序时,我的代码运行良好。但是,当我尝试在设计器中对其进行编辑时,出现错误:
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