Hi,
I just started coding with wxPython. The idea is to be able to change the gui dynamically. I am trying to change the static text inside the panel after the panel is created without user input/interaction, and I am not very successful with it. Below is my codes:
Is anyone can tell me what I have done wrong here. Thanks in advance.
I just started coding with wxPython. The idea is to be able to change the gui dynamically. I am trying to change the static text inside the panel after the panel is created without user input/interaction, and I am not very successful with it. Below is my codes:
Code:
import wx
class MyForm (wx.Panel):
def __init__ (self, parent, id):
wx.Panel.__init__(self, parent, id)
self.info = wx.StaticText (self, 10, "This is my first text", wx.Point (10, 10))
def changeStaticText (self, newText):
self.info.SetLabel (newText)
app = wx.PySimpleApp()
frame = wx.Frame (None, -1, "Fun with wxPython")
myForm = MyForm (frame, -1)
frame.Show (True)
app.MainLoop()
# Change the text dynamically after the panel is created.
myForm.changeStaticText ("NEW line of text")