Python curses 模块,KEY_F1 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用curses.KEY_F1

项目:PRET    作者:RUB-NDS    | 项目源码 | 文件源码
def create(self):
        self.name = 'Dictionary Browser \xe2\x94\x80\xe2\x94\x80 (Press F1 for help)'
        self.add_handlers({curses.KEY_F1: self.usage,
         ord('/'): self.search,
         ord('f'): self.filter,
         ord('r'): self.reset,
         ord('q'): self.quit})
        self.items = self.add(npyscreen.TitleText, name='Items total', value='0', editable=False)
        self.add(npyscreen.TitleText, name='PS version', value='3010', editable=False)
        self.search_btn = self.add(SearchButton, relx=33, rely=2, name='Search')
        self.search_text = self.add(npyscreen.FixedText, relx=53, rely=2, editable=False)
        self.filter_btn = self.add(FilterButton, relx=33, rely=3, name='Filter')
        self.filter_text = self.add(npyscreen.FixedText, relx=53, rely=3, editable=False)
        self.dict = self.add(Dict, name='Dictionary', scroll_exit=True, max_width=43, relx=2, rely=5, max_height=-2)
        self.perms = self.add(Perms, name='Permissions', scroll_exit=True, rely=5, relx=46, max_height=6)
        self.value = self.add(Value, name='Edit Value', scroll_exit=True, rely=11, relx=46, max_height=-2)
        self.status = self.add(npyscreen.TitleText, name='Status', editable=False, value='Connected to laserjet.lan', rely=-3)
        self.save = self.add(npyscreen.ButtonPress, name='Save Changes', rely=-3, relx=-27)
        self.exit = self.add(npyscreen.ButtonPress, name='Exit', rely=-3, relx=-12)
        self.save.whenPressed = self.commit
        self.exit.whenPressed = self.quit
        self.update_dict()
项目:notex    作者:adiultra    | 项目源码 | 文件源码
def keys_init_noedit(self):
        """Define methods for each key for non-editing mode.

        """
        self.keys = {
            curses.ascii.ETX:               self.close,
            curses.KEY_DOWN:                self.down_noedit,
            CTRL('n'):                      self.down_noedit,
            'j':                            self.down_noedit,
            curses.KEY_F1:                  self.help,
            curses.KEY_NPAGE:               self.page_down,
            'J':                            self.page_down,
            CTRL('f'):                      self.page_up,
            curses.KEY_PPAGE:               self.page_up,
            'K':                            self.page_up,
            CTRL('b'):                      self.page_up,
            CTRL('x'):                      self.quit,
            curses.KEY_F2:                  self.quit,
            curses.KEY_F3:                  self.quit_nosave,
            curses.ascii.ESC:               self.quit_nosave,
            curses.KEY_RESIZE:              self.resize,
            -1:                             self.resize,
            curses.KEY_UP:                  self.up_noedit,
            CTRL('p'):                      self.up_noedit,
            'k':                            self.up_noedit,
        }
项目:sciibo    作者:fdev    | 项目源码 | 文件源码
def on_key(self, ch):
        if self.alerts.open:
            self.alerts.on_key(ch)
        elif ch == curses.KEY_F1:
            self.state.set_scene("Help")
        elif ch == curses.KEY_F10:
            Animation.pause()
            self.alerts.confirm('Are you sure you want to leave the game?', action='Leave', on_dismiss=self.on_alert_leave)
        elif not self.animating:
            self.playfield.on_key(ch)
项目:notex    作者:adiultra    | 项目源码 | 文件源码
def keys_init(self):
        """Define methods for each key.

        """
        self.keys = {
            curses.KEY_BACKSPACE:           self.backspace,
            CTRL('h'):                      self.backspace,
            curses.ascii.BS:                self.backspace,
            curses.ascii.DEL:               self.backspace,
            curses.ascii.ETX:               self.close,
            curses.KEY_DC:                  self.del_char,
            CTRL('d'):                      self.del_char,
            CTRL('u'):                      self.del_to_bol,
            CTRL('k'):                      self.del_to_eol,
            curses.KEY_DOWN:                self.down,
            CTRL('n'):                      self.down,
            curses.KEY_END:                 self.end,
            CTRL('e'):                      self.end,
            curses.KEY_F1:                  self.help,
            curses.KEY_HOME:                self.home,
            CTRL('a'):                      self.home,
            curses.KEY_ENTER:               self.insert_line_or_quit,
            curses.ascii.NL:                self.insert_line_or_quit,
            curses.ascii.LF:                self.insert_line_or_quit,
            "\n":                           self.insert_line_or_quit,
            curses.KEY_LEFT:                self.left,
            CTRL('b'):                      self.left,
            curses.KEY_NPAGE:               self.page_down,
            curses.KEY_PPAGE:               self.page_up,
            CTRL('v'):                      self.paste,
            CTRL('x'):                      self.quit,
            curses.KEY_F2:                  self.quit,
            curses.KEY_F3:                  self.quit_nosave,
            curses.ascii.ESC:               self.quit_nosave,
            curses.KEY_RESIZE:              self.resize,
            -1:                             self.resize,
            curses.KEY_RIGHT:               self.right,
            CTRL('f'):                      self.right,
            curses.KEY_UP:                  self.up,
            CTRL('p'):                      self.up,
        }