Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython – GetLabel() function in wx.Button

  • Last Updated : 18 Jun, 2020

In this article, we are going to learn about GetLabel() function associated with wx.Button class of wxPython. GetLabel() function is used to return the string label for the button. No parameters are required by GetLabel() function.

Syntax: wx.Button.GetLabel(self)

Parameters: No parameters are required in GetLabel() function.

Return Type: string

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.pnl = wx.Panel(self)
        self.btn = wx.Button(self.pnl, label ='Button'
                              pos =(20, 20), size =(100, 20))
  
        # GET STRING LABEL ON BUTTON
        s = self.btn.GetLabel()
        # PRINT STRING LABEL
        print(s)
  
        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()

Console Output:

Button

Output Window:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!