2018-04-10 22:15:32

Hi all.
I and my friend are buildinga GUI app with wx.
While we were developing it, we faced an issue.
Basically what I want to do is changing the button's label name as soon as it's pressed
I've tried using the wx.SetLabel() method, but that doesn't work. Also I've tried searching online for solutions but seems all of them tell the same thing.
Do you know how could I fix this issue?
Also, if you have any GUI library that you think is better than wx feel free to share it here.
big_smile

Paul

2018-04-11 00:09:16

I did a quick test to see if it works and it worked on my computer.
Here is the code I used (might help to solve your problem):
import wx
app = wx.App()
frame = wx.Frame(None, wx.ID_ANY, "Button Test", size=(640, 480))
panel = wx.Panel(frame)
b = wx.Button(panel, wx.ID_ANY, "Press this")
bquit = wx.Button(panel, wx.ID_ANY, "&Quit")

def pressed(event):
        b.SetLabel("Button pressed")

def quit(event):
    exit(0)

b.Bind(wx.EVT_BUTTON, pressed)
bquit.Bind(wx.EVT_BUTTON, quit)
frame.Show()
app.MainLoop()