Beispiel #1
0
Datei: heli.py Projekt: tyco/heli
 def OnInit(self, *args, **kw):
     self.viewer = HeliDisplay()
     self.controller = HeliPlotter(viewer = self.viewer)
    
     # Pop up the windows for the two objects
     self.viewer.edit_traits()
     self.controller.edit_traits()
     
     # Set up the timer and start it up
     self.setup_read(self.controller)
     return True
Beispiel #2
0
Datei: heli.py Projekt: tyco/heli
class HeliApp(wx.PySimpleApp):
   
    def OnInit(self, *args, **kw):
        self.viewer = HeliDisplay()
        self.controller = HeliPlotter(viewer = self.viewer)
       
        # Pop up the windows for the two objects
        self.viewer.edit_traits()
        self.controller.edit_traits()
        
        # Set up the timer and start it up
        self.setup_read(self.controller)
        return True
    
    def setup_read(self, controller):
        self.t = SerialThread()
        self.t.controller = controller
        self.t.start()
        return
        
        # Create a new WX timer
        timerId = wx.NewId()
        self.timer = wx.Timer(self, timerId)
       
        # Register a callback with the timer event
        self.Bind(wx.EVT_TIMER, self.timer_tick, id=timerId)
       
        # Start up the timer!  We have to tell it how many milliseconds
        # to wait between timer events.  For now we will hardcode it
        # to be 100 ms, so we get 10 updates per second.
        self.timer.Start(100.0, wx.TIMER_CONTINUOUS)
        return
    
    def timer_tick(self, *args):
        nextdata = self.generator.next()
        self.controller.plot_data(nextdata)