我最近开始学习wxPython,我只需要显示一条垂直线来分隔框架上的按钮,但是我尝试使用带有参数“style = wx.LI_VERTICAL”的构造函数StaticLine,就像文档表明,但是当我运行时它显示一条水平线。更奇怪的是,当我使用“IsVertical()”方法检查元素时,它返回 True,就像没有任何错误一样。
这是代码:
import wx
class Finestra(wx.Frame):
def __init__ (self, genitore = None, titolo = "Netflix Preferences Carrier", dimensioni = (600, 450)):
super(Finestra, self).__init__(parent = genitore, title = titolo, size = dimensioni, style = wx.MINIMIZE_BOX | wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.RESIZE_BORDER)
self.Center()
self.interfaccia()
self.Show()
def interfaccia(self):
self.pannello =wx.Panel(self)
self.pannello.SetBackgroundColour("white")
self.sep = wx.StaticLine(self.pannello, pos = (50,50), size = (450, -1), style = wx.LI_VERTICAL)
print(self.sep.IsVertical())
app = wx.App()
Finestra()
app.MainLoop()
我可以做什么来解决这个问题?
最佳答案
@infinity77 提供的答案是正确的。
使用声明 size
的 StaticLine
either the height or the width (depending on whether the line if horizontal or vertical) is ignored.
尝试:
import wx
class Finestra(wx.Frame):
def __init__ (self, genitore = None, titolo = "Netflix Preferences Carrier", dimensioni = (600, 450)):
super(Finestra, self).__init__(parent = genitore, title = titolo, size = dimensioni, style = wx.MINIMIZE_BOX | wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.RESIZE_BORDER)
self.Center()
self.interfaccia()
self.Show()
def interfaccia(self):
self.pannello =wx.Panel(self)
self.pannello.SetBackgroundColour("blue")
self.sep = wx.StaticLine(self.pannello, pos = (50,50), size = (-1, 350), style = wx.LI_VERTICAL)
app = wx.App()
Finestra()
app.MainLoop()
关于python - wxPyhton 的 StaticLine 构造函数不考虑样式参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57826952/