2010-12-06 47 views

回答

4

這裏有一個簡單的例子:

import wx 
import time 

TIMER_ID = wx.NewId() 

class MyFrame(wx.Frame): 
    def __init__(self, *args, **kwargs): 
     wx.Frame.__init__(self, *args, **kwargs) 
     self.lstctrl = wx.ListCtrl(self, wx.ID_ANY, 
            size=(250,300), 
            style=wx.LC_REPORT) 
     self.lstctrl.InsertColumn(0, "Date", width=200) 

     sizer = wx.BoxSizer(wx.VERTICAL) 
     sizer.Add(self.lstctrl, 1, wx.EXPAND) 
     self.SetSizerAndFit(sizer) 

     wx.EVT_TIMER(self, TIMER_ID, self.OnTimer) 

     self.timer = wx.Timer(self, TIMER_ID) 
     self.timer.Start(2000) 

    def OnTimer(self, event): 
     self.lstctrl.InsertStringItem(self.lstctrl.GetItemCount(), 
             time.asctime()) 

app=wx.App() 
frame = MyFrame(None) 
frame.Show() 
app.MainLoop() 
+0

感謝您的回答 – 2010-12-06 18:12:36