Sunday, November 17, 2024
Google search engine
HomeLanguageswxPython – 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:

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

Most Popular

Recent Comments