Beispiel #1
0
 def __init__(self, invoker, settings):
     """
     see BaseEnv.__init__
     for convenience reasons, light_map can be either dict or list; in latter case it is changed
     to trivial {z:z} dict
     """
     BaseEnv.__init__(self, invoker, settings)
     #initialize urwid widgets 
     self.info_textbox = urwid.Text("")
     self.light_textbox = urwid.Text('')
     self.seven_textbox = urwid.Text('')
     self.keys_textbox = urwid.Text('')
     self.qr_textbox = urwid.Text('')
     div = urwid.Divider()
     pile = urwid.Pile([self.info_textbox, div, self.light_textbox, div, self.seven_textbox,
         self.keys_textbox, self.qr_textbox])
     top = urwid.Filler(pile, valign='middle')
     self.loop=urwid.MainLoop(top, unhandled_input=self.__handle_keypress__)
Beispiel #2
0
    def __handle_keypress__(self, letter):
        if letter=='esc':
            logger.info('exiting program (escape pressed)')
            BaseEnv.__exit__(self)
            if self.st.web_screen:
                self.main_window.destroy()
                gob.idle_add(gtk.main_quit)
            raise urwid.ExitMainLoop()
            self.invoker.__exit__()
            sys.exit()
            
        elif hasattr(self.qr,'key2user_id') and letter in self.qr.key2user_id.keys():
            self.qr.fire_event(letter)

        else:
            for key in self.keyboard.keys:
                if key.key_object==letter:
                    key.pressed=not key.pressed
                    updown='down' if key.pressed else 'up'
                    key.fire_event(updown)
            self.refresh_keys()