Saturday, October 25, 2025
HomeLanguageswxPython – StaticText() constructor in wx.StaticText

wxPython – StaticText() constructor in wx.StaticText

In this article we are going to learn about StaticText() associated with wx.StaticText class of wxPython. A static text control displays one or more lines of read-only text.

wx.StaticText supports the three classic text alignments, label elliptization i.e. replacing parts of the text with the ellipsis (“…”) if the label doesn’t fit into the provided space and also formatting markup with wx.Control.SetLabelMarkup .

Syntax: wx.StaticText.StaticText(parent, id=ID_ANY, label=””, pos=DefaultPosition, size=DefaultSize, style=0, name=StaticTextNameStr)

Parameters:

Parameter Input Type Description
parent wx.Window Parent window. Should not be None.
id wx.Window Parent window. Should not be None.
parent wx.WindowID Control identifier. A value of -1 denotes a default value.
label string Text label.
pos wx.Point Window position.
size wx.Size Window size.
style long Window style.
name string Window name.

Code Example:




import wx
  
  
class Example(wx.Frame):
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
        self.InitUI()
  
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.pnl = wx.Panel(self)
        bmp = wx.Bitmap('right.png')
        # CREATE STATICTEXT AT POINT (20, 20)
        self.st = wx.StaticText(self.pnl, id = 1, label ="This is StaticText", pos =(20, 20),
                                size = wx.DefaultSize, style = 0, name ="statictext")
  
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
        self.Centre()
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()


Output Window:

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

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS