单击按钮时如何更改 wxpython gizmo LED 颜色
How to change wxpython gizmo LED color when button is clicked
我想在单击 wx 按钮时更改 wx gizmos led
的颜色。
我的例子如下
import wx
import wx.lib.gizmos.ledctrl as led
class Main(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent = None, title ="LED test")
panel = wx.Panel(self)
self.myLED = led.LEDNumberCtrl(panel, -1, pos = (150,50), size = (100,100))
self.myLED.SetBackgroundColour("gray")
self.myButton = wx.Button(panel, -1, "myButton", pos =(50, 50))
self.myButton.Bind(wx.EVT_BUTTON, self.changeLEDColor)
def changeLEDColor(self,event):
self.myLED.SetBackgroundColour("green")
if __name__ == "__main__":
app = wx.App()
frame = Main()
frame.Show()
app.MainLoop()
当我点击 'mybutton' 时,我预计 LED 颜色会变为 'green',但它仍然是 'gray'。
我的示例有什么问题?
我想在单击 wx 按钮时更改 wx gizmos led
的颜色。
我的例子如下
import wx
import wx.lib.gizmos.ledctrl as led
class Main(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent = None, title ="LED test")
panel = wx.Panel(self)
self.myLED = led.LEDNumberCtrl(panel, -1, pos = (150,50), size = (100,100))
self.myLED.SetBackgroundColour("gray")
self.myButton = wx.Button(panel, -1, "myButton", pos =(50, 50))
self.myButton.Bind(wx.EVT_BUTTON, self.changeLEDColor)
def changeLEDColor(self,event):
self.myLED.SetBackgroundColour("green")
if __name__ == "__main__":
app = wx.App()
frame = Main()
frame.Show()
app.MainLoop()
当我点击 'mybutton' 时,我预计 LED 颜色会变为 'green',但它仍然是 'gray'。
我的示例有什么问题?