Reputation: 363
I've recently started to learn wxPython, and I just need to display a vertical line to separate the buttons on my frame, however I tried to use the constructor StaticLine with the parameter "style = wx.LI_VERTICAL", like the documentation suggests, but when I run it displays a horizontal line. Even more strangely, when I check on the element with the method "IsVertical()" it returns True, as like nothing was wrong.
This is the code:
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()
What can I do to fix this?
Upvotes: 1
Views: 37
Reputation: 22453
The answer provided by @infinity77 is spot on.
With a StaticLine
where you declare a size
either the height or the width (depending on whether the line if horizontal or vertical) is ignored.
Try:
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()
Upvotes: 1
Reputation: 1449
Do not pass explicitly the “size” parameter, you’re telling the line to have a fixed size of 450 pixels horizontally ... how can it be displayed as a vertical line?
Upvotes: 1