Saturday, August 30, 2025
HomeLanguageswxPython – StaticLine() constructor in wx.StaticLine

wxPython – StaticLine() constructor in wx.StaticLine

In this article we are going to learn about StaticLine() constructor associated with wx.StaticLine class of wxPython. A static line is just a line which may be used in a dialog to separate the groups of controls. The line may be only vertical or horizontal. Moreover, not all ports (notably not wxGTK) support specifying the transversal direction of the line (e.g. height for a horizontal line) so for maximal portability you should specify it as DefaultCoord.

Syntax: wx.StaticLine.StaticLine(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=LI_HORIZONTAL, name=StaticLineNameStr) Parameters

Parameter Input Type Description
parent wx.Window Parent window. Must not be None.
id wx.WindowID Window identifier. The value wx.ID_ANY indicates a default value.
pos wx.Point Window position. If wx.DefaultPosition is specified then a default position is chosen.
size wx.Size Size. Note that either the height or the width (depending on whether the line is horizontal or vertical) is ignored.
style long Window style (either wx.LI_HORIZONTAL or wx.LI_VERTICAL).
name string Window Name

Code Example: 

Python3




import wx
 
 
class FrameUI(wx.Frame):
 
    def __init__(self, parent, title):
        super(FrameUI, self).__init__(parent, title = title, size =(300, 200))
 
        # function for in-frame components
        self.InitUI()
 
    def InitUI(self):
        # parent panel for radio box
        pnl = wx.Panel(self)
 
        # list of choices
        hlist = ['Item One', 'Item Two']
        vlist =['Item One', 'Item Two']
 
        # create vertical line from point (50, 0) to (50, 250)
        self.sl = wx.StaticLine(pnl, 2,  pos =(50, 0), size = (1, 250),
                                              style = wx.LI_VERTICAL)
 
        # set frame in centre
        self.Centre()
        # set size of frame
        self.SetSize((400, 250))
        # show output frame
        self.Show(True)
 
 
 
# wx App instance
ex = wx.App()
# Example instance
FrameUI(None, 'RadioButton and RadioBox')
ex.MainLoop()


Output Window:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32249 POSTS0 COMMENTS
Milvus
80 POSTS0 COMMENTS
Nango Kala
6617 POSTS0 COMMENTS
Nicole Veronica
11792 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11838 POSTS0 COMMENTS
Shaida Kate Naidoo
6731 POSTS0 COMMENTS
Ted Musemwa
7012 POSTS0 COMMENTS
Thapelo Manthata
6689 POSTS0 COMMENTS
Umr Jansen
6701 POSTS0 COMMENTS