我想执行以下任务但没有到达那里:
1]在“OnApply”下获取选中的选项
2] 一旦我检查了几个选项,那么“选择”或“取消全选”将不会选择/取消选择那些未手动选择/选择的选项?
我是否需要索引所有复选框选项才能执行上述任务?
任何帮助实现这一点将非常感激。如果不清楚,请告诉我。
import wx
class MyCheckBox(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, 'Checking Options', size=(470, 400))
panel = wx.Panel(self, -1)
self.cb = wx.CheckBox(panel, -1, '', (120, 75))
self.cb.SetValue(False)
self.cb = wx.CheckBox(panel, -1, '', (200, 75))
self.cb.SetValue(False)
self.cb = wx.CheckBox(panel, -1, '', (278, 75))
self.cb.SetValue(False)
self.cb = wx.CheckBox(panel, -1, '', (356, 75))
self.cb.SetValue(False)
self.cb = wx.CheckBox(panel, -1, '', (120, 105))
self.cb.SetValue(False)
self.cb = wx.CheckBox(panel, -1, '', (200, 105))
self.cb.SetValue(False)
self.cb = wx.CheckBox(panel, -1, '', (278, 105))
self.cb.SetValue(False)
self.cb = wx.CheckBox(panel, -1, '', (356, 105))
self.cb.SetValue(False)
wx.StaticText(panel, -1, "Send output to File", (70, 255))
self.cb = wx.CheckBox(panel, -1, '', (50, 255))
self.cb.SetValue(True)
wx.EVT_CHECKBOX(self, self.cb.GetId(), self.ShowTitle)
self.btnSelect = wx.Button(panel, label="Select All", pos=(45, 295))
self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id = self.btnSelect.GetId())
self.btnUnSelectAll = wx.Button(panel, label="Unselect All*", pos=(173, 295))
self.Bind(wx.EVT_BUTTON, self.OnUnSelectAll, id = self.btnUnSelectAll.GetId())
self.btnApply = wx.Button(panel, label="Apply/Close", pos=(305, 295))
self.Bind(wx.EVT_BUTTON, self.OnApply, id = self.btnApply.GetId())
wx.StaticText(panel, -1, "* Note: 'Unselect All' button will not unselect storms that" '\n'
" have already determined", (20, 350))
self.Show()
self.Centre()
def ShowTitle(self, event):
if self.cb.GetValue():
self.SetTitle('checkbox.py')
else: self.SetTitle('')
def OnSelectAll(self, event):
self.cb.SetValue(True)
def OnUnSelectAll(self, event):
pass
def OnApply(self, event):
selection = self.cb.GetValue()
app = wx.App(0)
MyCheckBox(None, -1, 'checkbox.py')
app.MainLoop()