Skip to content
Related Articles

Related Articles

wxPython – Staticline using Create() function

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 08 Jul, 2020

In this article we are going to learn about Create() method 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. Create() function creates Staticline using two step creation.

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.Create(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=LI_HORIZONTAL, name=StaticLineNameStr)


ParameterInput TypeDescription
parentwx.WindowParent window. Must not be None.
idwx.WindowIDWindow identifier. The value wx.ID_ANY indicates a default value.
poswx.PointWindow position. If wx.DefaultPosition is specified then a default position is chosen.
sizewx.SizeSize. Note that either the height or the width (depending on whether the line if horizontal or vertical) is ignored.
stylelongWindow style (either wx.LI_HORIZONTAL or wx.LI_VERTICAL).
namestringWindow Name

Code Example:

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
    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']
        # initialize a static line = wx.StaticLine()
        # add attributes using Create()  function, 2,  pos =(50, 0), size = (1, 250),
                                     style = wx.LI_VERTICAL)
        # set frame in centre
        # set size of frame
        self.SetSize((400, 250))
        # show output frame
# wx App instance
ex = wx.App()
# Example instance
FrameUI(None, 'RadioButton and RadioBox')

Output Window:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!