Luk*_*keG 3 python wxpython append
所以假设我在 wxPython 中有一个复选框:
cb1 = wx.CheckBox(panelWX, label='TIME', pos=(20, 20))
cb1.SetValue(False)
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法可以检查它是否已更改为true?也许像这样?
if cb1.SetValue == True:
Run Code Online (Sandbox Code Playgroud)
从那一刻开始,从它的行为中附加一些东西是真的吗?像这样:
selectionSEM1.append('Time')
Run Code Online (Sandbox Code Playgroud)
你只需要使用GetValue()方法。从 wxpython wiki 看这个例子:
#!/usr/bin/python
# checkbox.py
import wx
class MyCheckBox(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(250, 170))
panel = wx.Panel(self, -1)
self.cb = wx.CheckBox(panel, -1, 'Show Title', (10, 10))
self.cb.SetValue(True)
wx.EVT_CHECKBOX(self, self.cb.GetId(), self.ShowTitle)
self.Show()
self.Centre()
def ShowTitle(self, event):
if self.cb.GetValue():#here you check if it is true or not
self.SetTitle('checkbox.py')
else: self.SetTitle('')
app = wx.App(0)
MyCheckBox(None, -1, 'checkbox.py')
app.MainLoop()
Run Code Online (Sandbox Code Playgroud)