Answer the question
In order to leave comments, you need to log in
How to link Python code and GUI on wxPython?
Sorry for the dumb question, I'm new. I couldn't find the answer myself. Essence of the question: there is dynamic code, for example a simple counter:
i=0
while i<10:
print (i)
i=i+1
import wx
app = wx.App()
frame = wx.Frame(None, -1, 'win.py')
panel = wx.Panel(frame, wx.ID_ANY)
text1 = wx.StaticText(panel, wx.ID_ANY, str (i), (50, 10))
frame.Show()
frame.Centre()
app.MainLoop()
Answer the question
In order to leave comments, you need to log in
Through the timer, of course.
It is possible through multithreading.
import wx
i=0
def Timer1(evt):
global text1,i
i+=1
text1.SetLabelText(str(i))
app = wx.App()
frame = wx.Frame(None, -1, 'win.py')
t1 = wx.Timer(frame)
t1.Start(1000)
panel = wx.Panel(frame, wx.ID_ANY)
text1 = wx.StaticText(panel, wx.ID_ANY, str(i), (50, 10))
frame.Bind(wx.EVT_TIMER, Timer1)
frame.Show()
frame.Centre()
app.MainLoop()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question