在我的树莓皮上的一些文本标签上设置边框有问题。在Windows下工作正常,但在raspbian上失败。并不是所有的边界都会失败。我对wx.BORDER\u升高或wx.BORDER\u下沉没有问题,但其他的
这是一个平台的问题,还是有一些技巧/设置,我遗漏了(即指定一些边界厚度或东西)
这是我的示例代码
import wx
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title, size=(900, 750))
self.SetBackgroundColour('Black')
self.SetForegroundColour("White")
PanelMain = wx.Panel(self, -1)
PanelMain.SetForegroundColour("White")
PanelMain.SetBackgroundColour("Black")
SizerMain = wx.BoxSizer(wx.HORIZONTAL)
for i in range(3):
PanelSub = wx.Panel(PanelMain, -1, style=wx.BORDER_STATIC)
PanelSub.SetBackgroundColour("Black")
lblNew = wx.StaticText(PanelSub, -1, label="Hello {}".format(i))
lblNew.SetForegroundColour("White")
lblNew.SetBackgroundColour("Green" if i == 0 else "Blue")
SizerMain.Add(PanelSub, 1, wx.EXPAND)
PanelMain.SetSizer(SizerMain)
SizerMain.Fit(PanelMain)
self.Show()
app = wx.App()
Example(None, title='Boxes')
app.MainLoop()
我没有找到解决这个问题的办法,所以我就是这么做的
首先,我创建了一个自定义wx.Panel类
这个类可以用作普通面板,但它本身有一个框。这是主程序:
注:将
wx.StaticText
替换为ST.GenStaticText
as this works better on GTK注2:不幸的是,在这个简单的示例中,文本框与边框重叠(参见下图)。这不是我真正的代码中的情况,因为我在那里使用了一个内部sizer。在这个简单的示例中,可以通过添加包含文本标签的内部大小调整器来避免这种情况
相关问题 更多 >
编程相关推荐