Set label in button action : Button « wxPython « Python Tutorial






Set label in button action
import wx

class ButtonFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Button Example', size=(300, 100))
        panel = wx.Panel(self, -1)
        self.button = wx.Button(panel, -1, "Button", pos=(50, 20))
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
        self.button.SetDefault()

    def OnClick(self, event):
        self.button.SetLabel("Clicked")
        
app = wx.PySimpleApp()
frame = ButtonFrame()
frame.Show()
app.MainLoop()








19.2.Button
19.2.1.Adding a Button to a FrameAdding a Button to a Frame
19.2.2.Setting Button PositionsSetting Button Positions
19.2.3.Add action to buttonAdd action to button
19.2.4.Set label in button actionSet label in button action
19.2.5.Bind event to button (Mouse enter and leave, button clicked)Bind event to button (Mouse enter and leave, button clicked)