【发布时间】:2018-12-05 11:04:58
【问题描述】:
我正在尝试在 wxPython 中设置 StaticText 的背景色。我正在使用方法
.SetBackgroundColour('Red')。当我在 Windows 10 上运行我的代码时,它按预期工作。但是,当它在 Raspberry pi 上运行时,它无法设置背景颜色(和文本对齐方式)。有人可以帮忙吗?
Picture: Result on Raspberry pi 3b+
wxPython4.0.3 在树莓派上构建的代码和轮子文件可以在我的 Github 上找到:https://github.com/danneedebro/Problem_bgcolor_static_text
这是我的简化代码:
Main.py
import wx
class Example(wx.Frame):
def __init__(self, parent):
super(Example, self).__init__(parent, title='Window', size=(300, 100))
panel = wx.Panel(self)
LblTextWithBgColor = wx.StaticText(panel, label='This text should have a red background', size=(250, 20), style=wx.ALIGN_CENTER)
LblTextWithBgColor.SetForegroundColour('Green')
LblTextWithBgColor.SetBackgroundColour('Red')
self.Show()
app = wx.App()
Example(None)
app.MainLoop()
【问题讨论】:
标签: python wxpython raspberry-pi3