python - 单击按钮时如何更改wxpython gizmo LED颜色
问题描述
led
单击 wx 按钮时,我想更改 wx gizmos 的颜色。
我的例子如下。
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()
当我单击“我的按钮”时,我预计 LED 的颜色会变为“绿色”,但它仍然是“灰色”。
我的例子有什么问题?
解决方案
推荐阅读
- javascript - Bootstrap:让文本在文本输入字段周围流动
- java - 如何在 NetBeans 生成的代码上修复“线程“AWT-EventQueue-0”java.lang.NullPointerException 中的异常”?
- r-markdown - Knitr 和/或 Kableextra:全局表选项?
- c# - Jqgrid 无法在我的 SQL 服务器实例中添加、编辑或删除,我认为它甚至没有点击添加、编辑或删除功能
- html - 与 CSS 网格重叠的段落
- python - 如何在 seaborn 的条形图中的误差线上绘制标准误差?
- google-apps-script - 循环内的 setvalue 命令
- php - 返回Class的函数类型数组
- flask - 烧瓶应用程序中的服务和 flask_sqlalchemy
- laravel - Laravel Echo 不听