Wednesday, July 3, 2024
HomeLanguagesPythonwxPython – GetLabel() function in wx.Button

wxPython – GetLabel() function in wx.Button

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:

Ted Musemwa
As a software developer I’m interested in the intersection of computational thinking and design thinking when solving human problems. As a professional I am guided by the principles of experiential learning; experience, reflect, conceptualise and experiment.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments