I'm a very beginner of wxPython. Now I'm trying to make a static text moveable by using timer(), but the question is that when the later one appears, the former one just doesn't hide. So I'm thinking in these ways: (1) Is that because I'm using static text? Maybe it could be "moveable" while I'm using some other widgets? (2) When I wanna use "hide" or "destroy" at first, it comes out "not defined".
Any helpful suggestion will be great, and below is my code(python version: 2.6):
#!/user/bin/python
import wx
pos_st = [[10,50],[40,50],[70,50],[100,50]]
i = -1
class Frame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self, parent, id,
'Move widget',
size = (200,150),
style=wx.MINIMIZE_BOX | wx.RESIZE_BORDER
| wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)
self.initUI()
def initUI(self):
self.widgetPanel=wx.Panel(self, -1)
self.widgetPanel.SetBackgroundColour('white')
# Buttons for play the simulation
playButton = wx.Button(self.widgetPanel, -1, "Play", pos=(10,10), size=(30,30))
self.Bind(wx.EVT_BUTTON, self.play, playButton)
playButton.SetDefault()
def play(self, event):
self.timer = wx.CallLater(1000, self.run_st)
def run_st(self):
global i
i = (i+1)%4
self.timer.Restart(1000)
self.sT = wx.StaticText(self.widgetPanel, -1, '1',
pos=pos_st[i], size=(20,20))
self.sT.SetBackgroundColour('grey')
if __name__ == "__main__":
app = wx.App(False)
frame = Frame(parent=None,id=-1)
frame.Show()
app.MainLoop()