当前位置: 首页>>代码示例>>Python>>正文


Python curses.KEY_MOUSE属性代码示例

本文整理汇总了Python中curses.KEY_MOUSE属性的典型用法代码示例。如果您正苦于以下问题:Python curses.KEY_MOUSE属性的具体用法?Python curses.KEY_MOUSE怎么用?Python curses.KEY_MOUSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在curses的用法示例。


在下文中一共展示了curses.KEY_MOUSE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMouseClickOffLinkDoesNotTriggersCommand

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def testMouseClickOffLinkDoesNotTriggersCommand(self):
    ui = MockCursesUI(
        40,
        80,
        command_sequence=[
            string_to_codes("babble -n 10 -k\n"),
            # A click off a hyperlink (too much to the right).
            [curses.KEY_MOUSE, 8, 4],
            self._EXIT
        ])
    ui.register_command_handler("babble", self._babble, "")
    ui.run_ui()

    # The mouse click event should not triggered no command.
    self.assertEqual(1, len(ui.unwrapped_outputs))
    self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[0].lines)

    # This command should have generated no main menus.
    self.assertEqual([None], ui.main_menu_list) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:21,代码来源:curses_ui_test.py

示例2: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def set_up_handlers(self):
        """This function should be called somewhere during object initialisation (which all library-defined widgets do). You might like to override this in your own definition,
but in most cases the add_handers or add_complex_handlers methods are what you want."""
        #called in __init__
        self.handlers = {
                   curses.ascii.NL:     self.h_exit_down,
                   curses.ascii.CR:     self.h_exit_down,
                   curses.ascii.TAB:    self.h_exit_down,
                   curses.KEY_BTAB:     self.h_exit_up,
                   curses.KEY_DOWN:     self.h_exit_down,
                   curses.KEY_UP:       self.h_exit_up,
                   curses.KEY_LEFT:     self.h_exit_left,
                   curses.KEY_RIGHT:    self.h_exit_right,
                   # "^P":                self.h_exit_up,
                   # "^N":                self.h_exit_down,
                   curses.ascii.ESC:    self.h_exit_escape,
                   curses.KEY_MOUSE:    self.h_exit_mouse,
                   }

        self.complex_handlers = [] 
开发者ID:hexway,项目名称:apple_bleee,代码行数:22,代码来源:wgwidget.py

示例3: event_listener

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def event_listener(scr, timeout):
    '''
    Wait for curses events on screen ``scr`` at mot ``timeout`` ms

    return
     - 1 OK
     - 2 redraw
     - 0 error
    '''
    try:
        scr.timeout(timeout)
        c = scr.getch()
        if c == -1:
            return 1
        elif c == curses.KEY_MOUSE:
            return on_mouse()
        elif c == curses.KEY_RESIZE:
            return on_resize()
        else:
            return on_keyboard(c)
    except _curses.error:
        return 0 
开发者ID:yadutaf,项目名称:ctop,代码行数:24,代码来源:cgroup_top.py

示例4: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def set_up_handlers(self):
        """This function should be called somewhere during object initialisation (which all library-defined widgets do). You might like to override this in your own definition,
but in most cases the add_handers or add_complex_handlers methods are what you want."""
        #called in __init__
        self.handlers = {
                   curses.ascii.NL:     self.h_exit_down,
                   curses.ascii.CR:     self.h_exit_down,
                   curses.ascii.TAB:    self.h_exit_down,
                   curses.KEY_BTAB:     self.h_exit_up,
                   curses.KEY_DOWN:     self.h_exit_down,
                   curses.KEY_UP:       self.h_exit_up,
                   curses.KEY_LEFT:     self.h_exit_left,
                   curses.KEY_RIGHT:    self.h_exit_right,
                   "^P":                self.h_exit_up,
                   "^N":                self.h_exit_down,
                   curses.ascii.ESC:    self.h_exit_escape,
                   curses.KEY_MOUSE:    self.h_exit_mouse,
                   }

        self.complex_handlers = [] 
开发者ID:sealingtech,项目名称:EDCOP,代码行数:22,代码来源:wgwidget.py

示例5: event_listener

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def event_listener(scr, timeout):
    '''
    Wait for curses events on screen ``scr`` at mot ``timeout`` ms
    return
     - 1 OK
     - 2 redraw
     - 0 error
    '''
    try:
        scr.timeout(timeout)
        c = scr.getch()
        if c == -1:
            return 1
        elif c == curses.KEY_MOUSE:
            return on_mouse()
        elif c == curses.KEY_RESIZE:
            return on_resize()
        else:
            return on_keyboard(c)
    except _curses.error:
        return 0 
开发者ID:soarpenguin,项目名称:python-scripts,代码行数:23,代码来源:cgroup_top.py

示例6: event_listener

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def event_listener(scr, timeout):
    '''
    Wait for curses events on screen ``scr`` at mot ``timeout`` ms

    return
     - 1 OK
     - 2 redraw
     - 0 error
    '''
    try:
        scr.timeout(timeout)
        c = scr.getch()
        if c == -1:
            return 1
        elif c == curses.KEY_MOUSE:
            return on_mouse()
        elif c == curses.KEY_RESIZE:
            return on_resize()
        else:
            return on_keyboard(scr, c)
    except _curses.error:
        return 0 
开发者ID:soarpenguin,项目名称:python-scripts,代码行数:24,代码来源:top.py

示例7: findTextAndClick

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def findTextAndClick(self, timeStamp, screenText, bState):
        caller = inspect.stack()[1]
        callerText = u"\n  %s:%s:%s(): " % (os.path.split(caller[1])[1],
                                            caller[2], caller[3])

        def createEvent(display, cmdIndex):
            row, col = self.findText(screenText)
            if row < 0:
                output = u"%s at index %d, did not find %r" % (
                    callerText, cmdIndex, screenText)
                if self.cursesScreen.movie:
                    print(output)
                else:
                    self.fail(output)
            # Note that the mouse info is x,y (col, row).
            info = (timeStamp, col, row, 0, bState)
            curses.addMouseEvent(info)
            return curses.KEY_MOUSE

        return createEvent 
开发者ID:google,项目名称:ci_edit,代码行数:22,代码来源:fake_curses_testing.py

示例8: mouseEvent

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def mouseEvent(self, timeStamp, mouseRow, mouseCol, bState):
        """
        bState may be a logical or of:
          curses.BUTTON1_PRESSED;
          curses.BUTTON1_RELEASED;
          ...
          curses.BUTTON_SHIFT
          curses.BUTTON_CTRL
          curses.BUTTON_ALT
        """
        assert isinstance(timeStamp, int)
        assert isinstance(mouseRow, int)
        assert isinstance(mouseCol, int)
        assert isinstance(bState, int)
        # Note that the mouse info is x,y (col, row).
        info = (timeStamp, mouseCol, mouseRow, 0, bState)

        def createEvent(display, cmdIndex):
            curses.addMouseEvent(info)
            return curses.KEY_MOUSE

        return createEvent 
开发者ID:google,项目名称:ci_edit,代码行数:24,代码来源:fake_curses_testing.py

示例9: _ui_loop

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def _ui_loop(self):
    """Command-line UI loop.

    Returns:
      An exit token of arbitrary type. The token can be None.
    """

    while True:
      # Enter history command if pointer is in history (> 0):
      if self._command_pointer > 0:
        existing_command = self._active_command_history[-self._command_pointer]
      else:
        existing_command = self._pending_command
      self._screen_create_command_textbox(existing_command)

      try:
        command, terminator, pending_command_changed = self._get_user_command()
      except debugger_cli_common.CommandLineExit as e:
        return e.exit_token

      if not command and terminator != self.CLI_TAB_KEY:
        continue

      if terminator in self.CLI_CR_KEYS or terminator == curses.KEY_MOUSE:
        exit_token = self._dispatch_command(command)
        if exit_token is not None:
          return exit_token
      elif terminator == self.CLI_TAB_KEY:
        tab_completed = self._tab_complete(command)
        self._pending_command = tab_completed
        self._cmd_ptr = 0
      elif pending_command_changed:
        self._pending_command = command

    return 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:37,代码来源:curses_ui.py

示例10: _screen_get_user_command

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def _screen_get_user_command(self):
    command = self._command_sequence[self._command_counter]

    self._command_key_counter = 0
    for c in command:
      if c == curses.KEY_RESIZE:
        # Special case for simulating a terminal resize event in curses.
        self._height = command[1]
        self._width = command[2]
        self._on_textbox_keypress(c)
        self._command_counter += 1
        return ""
      elif c == curses.KEY_MOUSE:
        mouse_x = command[1]
        mouse_y = command[2]
        self._command_counter += 1
        self._textbox_curr_terminator = c
        return self._fetch_hyperlink_command(mouse_x, mouse_y)
      else:
        y = self._on_textbox_keypress(c)

        self._command_key_counter += 1
        if y == curses_ui.CursesUI.CLI_TERMINATOR_KEY:
          break

    self._command_counter += 1

    # Take into account pre-existing string automatically entered on textbox
    # creation.
    return self._curr_existing_command + codes_to_string(command) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:32,代码来源:curses_ui_test.py

示例11: testMouseClickOnLinkTriggersCommand

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def testMouseClickOnLinkTriggersCommand(self):
    ui = MockCursesUI(
        40,
        80,
        command_sequence=[
            string_to_codes("babble -n 10 -k\n"),
            [curses.KEY_MOUSE, 1, 4],  # A click on a hyperlink.
            self._EXIT
        ])
    ui.register_command_handler("babble", self._babble, "")
    ui.run_ui()

    self.assertEqual(2, len(ui.unwrapped_outputs))
    self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[0].lines)
    self.assertEqual(["bar"] * 60, ui.unwrapped_outputs[1].lines) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:17,代码来源:curses_ui_test.py

示例12: testMouseClickOnEnabledMenuItemWorks

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def testMouseClickOnEnabledMenuItemWorks(self):
    ui = MockCursesUI(
        40,
        80,
        command_sequence=[
            string_to_codes("babble -n 10 -m\n"),
            # A click on the enabled menu item.
            [curses.KEY_MOUSE, 3, 1],
            self._EXIT
        ])
    ui.register_command_handler("babble", self._babble, "")
    ui.run_ui()

    self.assertEqual(2, len(ui.unwrapped_outputs))
    self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[0].lines)
    self.assertEqual(["bar"] * 60, ui.unwrapped_outputs[1].lines)

    # Check the content of the menu.
    self.assertEqual(["| babble again | ahoy | "], ui.main_menu_list[0].lines)
    self.assertEqual(1, len(ui.main_menu_list[0].font_attr_segs))
    self.assertEqual(1, len(ui.main_menu_list[0].font_attr_segs[0]))

    item_annot = ui.main_menu_list[0].font_attr_segs[0][0]
    self.assertEqual(2, item_annot[0])
    self.assertEqual(14, item_annot[1])
    self.assertEqual("babble", item_annot[2][0].content)
    self.assertEqual("underline", item_annot[2][1])

    # The output from the menu-triggered command does not have a menu.
    self.assertIsNone(ui.main_menu_list[1]) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:32,代码来源:curses_ui_test.py

示例13: testMouseClickOnDisabledMenuItemTriggersNoCommand

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def testMouseClickOnDisabledMenuItemTriggersNoCommand(self):
    ui = MockCursesUI(
        40,
        80,
        command_sequence=[
            string_to_codes("babble -n 10 -m\n"),
            # A click on the disabled menu item.
            [curses.KEY_MOUSE, 18, 1],
            self._EXIT
        ])
    ui.register_command_handler("babble", self._babble, "")
    ui.run_ui()

    self.assertEqual(1, len(ui.unwrapped_outputs))
    self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[0].lines) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:17,代码来源:curses_ui_test.py

示例14: h_exit_mouse

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def h_exit_mouse(self, _input):
        mouse_event = self.parent.safe_get_mouse_event()
        if mouse_event and self.intersted_in_mouse_event(mouse_event):
            self.handle_mouse_event(mouse_event)
        else:
            if mouse_event and self._test_safe_to_exit():
                curses.ungetmouse(*mouse_event)
                ch = self.parent.curses_pad.getch()
                assert ch == curses.KEY_MOUSE
            self.editing = False
            self.how_exited = EXITED_MOUSE 
开发者ID:hexway,项目名称:apple_bleee,代码行数:13,代码来源:wgwidget.py

示例15: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_MOUSE [as 别名]
def set_up_handlers(self):
        super(SimpleGrid, self).set_up_handlers()
        self.handlers = {
                    curses.KEY_UP:      self.h_move_line_up,
                    curses.KEY_LEFT:    self.h_move_cell_left,
                    curses.KEY_DOWN:    self.h_move_line_down,
                    curses.KEY_RIGHT:   self.h_move_cell_right,
                    "k":                self.h_move_line_up,
                    "h":                self.h_move_cell_left,
                    "j":                self.h_move_line_down,
                    "l":                self.h_move_cell_right,
                    curses.KEY_NPAGE:   self.h_move_page_down,
                    curses.KEY_PPAGE:   self.h_move_page_up,
                    curses.KEY_HOME:    self.h_show_beginning,
                    curses.KEY_END:     self.h_show_end,
                    ord('g'):           self.h_show_beginning,
                    ord('G'):           self.h_show_end,
                    curses.ascii.TAB:   self.h_exit,
                    curses.KEY_BTAB:     self.h_exit_up,
                    '^P':               self.h_exit_up,
                    '^N':               self.h_exit_down,
                    #curses.ascii.NL:    self.h_exit,
                    #curses.ascii.SP:    self.h_exit,
                    #ord('x'):       self.h_exit,
                    ord('q'):       self.h_exit,
                    curses.ascii.ESC:   self.h_exit,
                    curses.KEY_MOUSE:    self.h_exit_mouse,
                }

        self.complex_handlers = [
                    ] 
开发者ID:hexway,项目名称:apple_bleee,代码行数:33,代码来源:wggrid.py


注:本文中的curses.KEY_MOUSE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。