Skip to content
Related Articles

Related Articles

wxPython – Create() function in wx.StaticText

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 18 Jun, 2020

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

Create() function is used for two step creation of static text. I takes attributes of statictext as arguments.

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

Parameters:

ParameterInput TypeDescription
parentwx.WindowParent window. Should not be None.
idwx.WindowParent window. Should not be None.
parentwx.WindowIDControl identifier. A value of -1 denotes a default value.
labelstringText label.
poswx.PointWindow position.
sizewx.SizeWindow size.
stylelongWindow style.
namestringWindow name.

Return Type:
bool

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')
          
        self.st = wx.StaticText()
        # CREATE STATICTEXT AT POINT (20, 20) USING Create() FUNCTION
        self.st.Create(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:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!