Esempio n. 1
0
class TestController:
    def __init__(self):
        Controller.static_ctrl = self
        Controller.static_end = False
        self.graphics = Graphics()
        self.model = StartModel(
            self, self.graphics)  # FIXME change to Start a different Model
        assert hasattr(self, 'timeout'), "Model does not call setTimeOut()"
        self.timestamp = now()  # in seconds
        Input().start()  # Thread 2
        while True:  # Thread 1
            if (Controller.static_end): break
            time.sleep(REFRESH)
            if (now() - self.timestamp > self.timeout):
                if (self.model.timeout()):
                    self.model = self.model.next()
                if (self.model == None):
                    Controller.static_end = True
                    exit()
                self.timestamp = now()

    def pressed(self, key):
        """
        Invoked when Input thread gets an keystroke. key is an integer representing the key pressed. 
        """
        if (self.model.process(key)):
            self.model = self.model.next()
        if (self.model == None):
            Controller.static_end = True
            exit()
        #self.timestamp = now();

    def setTimeOut(self, timeout):
        self.timeout = timeout
Esempio n. 2
0
class TestController:
    def __init__(self):
        Controller.static_ctrl = self
        Controller.static_end = False
        self.graphics = Graphics()
        self.model = StartModel(self, self.graphics)  # FIXME change to Start a different Model
        assert hasattr(self, "timeout"), "Model does not call setTimeOut()"
        self.timestamp = now()  # in seconds
        Input().start()  # Thread 2
        while True:  # Thread 1
            if Controller.static_end:
                break
            time.sleep(REFRESH)
            if now() - self.timestamp > self.timeout:
                if self.model.timeout():
                    self.model = self.model.next()
                if self.model == None:
                    Controller.static_end = True
                    exit()
                self.timestamp = now()

    def pressed(self, key):
        """
        Invoked when Input thread gets an keystroke. key is an integer representing the key pressed. 
        """
        if self.model.process(key):
            self.model = self.model.next()
        if self.model == None:
            Controller.static_end = True
            exit()
        # self.timestamp = now();

    def setTimeOut(self, timeout):
        self.timeout = timeout
Esempio n. 3
0
 def __init__(self):
     Controller.static_ctrl = self
     Controller.static_end = False
     self.graphics = Graphics()
     self.model = StartModel(self, self.graphics) # FIXME change to Start a different Model
     assert hasattr(self, 'timeout'), "Model does not call setTimeOut()"
     self.timestamp = now() # in seconds
     Input().start() # Thread 2
     while True: # Thread 1
         if (Controller.static_end): break
         time.sleep(REFRESH)
         if(now() - self.timestamp > self.timeout):
             if(self.model.timeout()):
                 self.model = self.model.next()
             if (self.model == None):
                 Controller.static_end = True
                 exit()
             self.timestamp = now();