python - wxPyhton 的 StaticLine 构造函数不考虑样式参数

标签 python wxpython

我最近开始学习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 提供的答案是正确的。
使用声明 sizeStaticLine

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()

enter image description here

关于python - wxPyhton 的 StaticLine 构造函数不考虑样式参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57826952/

相关文章:

python - 如何使用 Sqlalchemy 创建序列并将该特定序列添加到表中?

python - match_phrase 不适用于分析索引

python - 如何在 Vertical BoxSizer 中设置间隙?

python - 将多个日期时间数据帧行分组为单个行

python - 不透明度的 QVariantAnimation : the item appears at the end of the animation

python - 如何从嵌套列中提取 json 到数据框

python - 如何从 Python 制作 .app 包含图像文件

python - Wxpython,如何使用给定的按键代码创建wx.KeyEvent?

wxpython - 如何使用wxpython绘制垂直线

python - 在Python中响应按键而不生成窗口