【发布时间】:2013-06-19 05:57:32
【问题描述】:
posx = 50
for name in sheets:
wx.CheckBox(self, -1 ,name, (15, posx))
posx = posx + 20
当我执行此操作时,复选框出现但它们不起作用,这意味着我无法选中任何框,动态添加复选框或按钮的正确方法是什么?
我现在已经编辑了我的代码并将其添加到面板中,现在复选框甚至都没有出现
pnl = wx.Panel(self)
posx = 50
for name in sheets:
cb = wx.CheckBox(pnl, label=name, pos=(20, posx))
cb.SetValue(True)
cb.Bind(wx.EVT_CHECKBOX, self.doSomething)
posx = posx + 20
def doSomething(Self,e):
sender = e.GetEventObject()
isChecked = sender.GetValue()
if isChecked:
#do something here
else:
#do something else here
【问题讨论】:
-
你必须将它添加到面板或框架中,然后上面的代码才能工作
-
@BinayakaChakraborty:请检查编辑,我做错了吗?
-
查看稻草人的答案 :)
标签: python python-2.7 wxpython