wxPyhton 的 StaticLine 构造函数不考虑样式参数
wxPyhton's StaticLine Constructor doesn't account for style parameter
我最近开始学习wxPython,我只需要显示一条垂直线来分隔我框架上的按钮,但是我尝试使用带有参数"style = wx.LI_VERTICAL"的构造函数StaticLine,比如文档建议,但是当我 运行 它显示一条水平线。更奇怪的是,当我使用 "IsVertical()" 方法检查元素时,它 returns 是的,就像没有错一样。
这是代码:
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()
我该怎么做才能解决这个问题?
不要显式传递“大小”参数,您是在告诉该行具有 450 像素的固定大小水平 ...它如何显示为垂直线?
@infinity77 提供的答案是正确的。
使用 StaticLine
声明 size
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()
我最近开始学习wxPython,我只需要显示一条垂直线来分隔我框架上的按钮,但是我尝试使用带有参数"style = wx.LI_VERTICAL"的构造函数StaticLine,比如文档建议,但是当我 运行 它显示一条水平线。更奇怪的是,当我使用 "IsVertical()" 方法检查元素时,它 returns 是的,就像没有错一样。
这是代码:
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()
我该怎么做才能解决这个问题?
不要显式传递“大小”参数,您是在告诉该行具有 450 像素的固定大小水平 ...它如何显示为垂直线?
@infinity77 提供的答案是正确的。
使用 StaticLine
声明 size
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()