有没有可能在wxpythongizmos ledctrl上贴个标签?

2024-05-23 21:59:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在wxPython gizmos led上贴个标签,像这样

enter image description here

但我找不到如何在led上做标签

我的代码是这样的。我使用wxpythonstatictext制作了led标签,并调整了位置

import wx.lib.gizmos.ledctrl as led
import wx

class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, parent = None, title= "LED Test", size = (300,200))
        self.panel = wx.Panel(self)
        self.myLed = led.LEDNumberCtrl(self.panel, -1, size = (100, 30), pos = (100,50))
        self.label = wx.StaticText(self.panel, -1, "my LED" , pos=(130,57))
        self.myLed.SetBackgroundColour("green")
        self.label.SetBackgroundColour("green")


if __name__ == "__main__":
    app = wx.App()
    frame = MainFrame()
    frame.Show()
    app.MainLoop()

如何制作gizmos led标签


Tags: posimportselfsizeledinit标签frame
1条回答
网友
1楼 · 发布于 2024-05-23 21:59:23

简而言之,答案是否定的,因为问题是书面的。
它仅限于可以显示的字符

The LEDNumberCtrl can be used to display a series of digits, (plus spaces, colons or dashes,) using a style reminiscent of old-timey segmented digital displays.

import wx.lib.gizmos.ledctrl as led
import wx

class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, parent = None, title= "LED Test", size = (300,200))
        self.panel = wx.Panel(self)
        self.myLed = led.LEDNumberCtrl(self.panel, -1, size = (200,50), pos = (50,50))
        self.myLed.SetValue(" 22:01")

if __name__ == "__main__":
    app = wx.App()
    frame = MainFrame()
    frame.Show()
    app.MainLoop()

enter image description here

相关问题 更多 >