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


Python curses.BUTTON3_CLICKED属性代码示例

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


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

示例1: _inject_mouse

# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON3_CLICKED [as 别名]
def _inject_mouse(screen, x, y, button):
        """
        Inject a mouse event into the input buffers.
        """
        if sys.platform == "win32":
            event = win32console.PyINPUT_RECORDType(win32console.MOUSE_EVENT)
            event.MousePosition.X = x
            event.MousePosition.Y = y
            if button & MouseEvent.LEFT_CLICK != 0:
                event.ButtonState |= win32con.FROM_LEFT_1ST_BUTTON_PRESSED
            if button & MouseEvent.RIGHT_CLICK != 0:
                event.ButtonState |= win32con.RIGHTMOST_BUTTON_PRESSED
            if button & MouseEvent.DOUBLE_CLICK != 0:
                event.EventFlags |= win32con.DOUBLE_CLICK
            screen._stdin.WriteConsoleInput([event])
        else:
            # Curses doesn't like no value in some cases - use a dummy button
            # click which we don't use instead.
            bstate = curses.BUTTON4_CLICKED
            if button & MouseEvent.LEFT_CLICK != 0:
                bstate |= curses.BUTTON1_CLICKED
            if button & MouseEvent.RIGHT_CLICK != 0:
                bstate |= curses.BUTTON3_CLICKED
            if button & MouseEvent.DOUBLE_CLICK != 0:
                bstate |= curses.BUTTON1_DOUBLE_CLICKED
            curses.ungetmouse(0, x, y, 0, bstate) 
开发者ID:peterbrittain,项目名称:asciimatics,代码行数:28,代码来源:test_screen.py

示例2: init_curses

# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON3_CLICKED [as 别名]
def init_curses(self):
        os.environ.setdefault('ESCDELAY', '25')
        self.stdscr = curses.initscr()
        self.stdscr.clear()
        curses.noecho()
        curses.curs_set(0) 
        curses.mousemask(curses.REPORT_MOUSE_POSITION
            | curses.BUTTON1_PRESSED | curses.BUTTON1_RELEASED
            | curses.BUTTON2_PRESSED | curses.BUTTON2_RELEASED
            | curses.BUTTON3_PRESSED | curses.BUTTON3_RELEASED
            | curses.BUTTON4_PRESSED | curses.BUTTON4_RELEASED
            | curses.BUTTON1_CLICKED | curses.BUTTON3_CLICKED
            | curses.BUTTON1_DOUBLE_CLICKED 
            | curses.BUTTON1_TRIPLE_CLICKED
            | curses.BUTTON2_DOUBLE_CLICKED 
            | curses.BUTTON2_TRIPLE_CLICKED
            | curses.BUTTON3_DOUBLE_CLICKED 
            | curses.BUTTON3_TRIPLE_CLICKED
            | curses.BUTTON4_DOUBLE_CLICKED 
            | curses.BUTTON4_TRIPLE_CLICKED
            | curses.BUTTON_SHIFT | curses.BUTTON_ALT
            | curses.BUTTON_CTRL)
        self.stdscr.keypad(True) # Handle our own escape codes for now

        # The first call to getch seems to clobber the statusbar.
        # So we make a dummy first call.
        self.stdscr.nodelay(True)
        self.stdscr.getch()
        self.stdscr.nodelay(False) 
开发者ID:dsanson,项目名称:termpdf.py,代码行数:31,代码来源:termpdf.py

示例3: get_event

# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON3_CLICKED [as 别名]
def get_event(self):
            """
            Check for an event without waiting.
            """
            # Spin through notifications until we find something we want.
            key = 0
            while key != -1:
                # Get the next key
                key = self._screen.getch()

                if key == curses.KEY_RESIZE:
                    # Handle screen resize
                    self._re_sized = True
                elif key == curses.KEY_MOUSE:
                    # Handle a mouse event
                    _, x, y, _, bstate = curses.getmouse()
                    buttons = 0
                    # Some Linux modes only report clicks, so check for any
                    # button down or click events.
                    if (bstate & curses.BUTTON1_PRESSED != 0 or
                            bstate & curses.BUTTON1_CLICKED != 0):
                        buttons |= MouseEvent.LEFT_CLICK
                    if (bstate & curses.BUTTON3_PRESSED != 0 or
                            bstate & curses.BUTTON3_CLICKED != 0):
                        buttons |= MouseEvent.RIGHT_CLICK
                    if bstate & curses.BUTTON1_DOUBLE_CLICKED != 0:
                        buttons |= MouseEvent.DOUBLE_CLICK
                    return MouseEvent(x, y, buttons)
                elif key != -1:
                    # Handle any byte streams first
                    logger.debug("Processing key: %x", key)
                    if self._unicode_aware and key > 0:
                        if key & 0xC0 == 0xC0:
                            self._bytes_to_return = struct.pack(b"B", key)
                            self._bytes_to_read = bin(key)[2:].index("0") - 1
                            logger.debug("Byte stream: %d bytes left",
                                         self._bytes_to_read)
                            continue
                        elif self._bytes_to_read > 0:
                            self._bytes_to_return += struct.pack(b"B", key)
                            self._bytes_to_read -= 1
                            if self._bytes_to_read > 0:
                                continue
                            else:
                                key = ord(self._bytes_to_return.decode("utf-8"))

                    # Handle a genuine key press.
                    logger.debug("Returning key: %x", key)
                    if key in self._KEY_MAP:
                        return KeyboardEvent(self._KEY_MAP[key])
                    elif key != -1:
                        return KeyboardEvent(key)

            return None 
开发者ID:peterbrittain,项目名称:asciimatics,代码行数:56,代码来源:screen.py

示例4: mouseButtonName

# 需要导入模块: import curses [as 别名]
# 或者: from curses import BUTTON3_CLICKED [as 别名]
def mouseButtonName(buttonState):
    """Curses debugging. Prints readable name for state of mouse buttons."""
    result = u""
    if buttonState & curses.BUTTON1_RELEASED:
        result += u'BUTTON1_RELEASED'
    if buttonState & curses.BUTTON1_PRESSED:
        result += u'BUTTON1_PRESSED'
    if buttonState & curses.BUTTON1_CLICKED:
        result += u'BUTTON1_CLICKED'
    if buttonState & curses.BUTTON1_DOUBLE_CLICKED:
        result += u'BUTTON1_DOUBLE_CLICKED'

    if buttonState & curses.BUTTON2_RELEASED:
        result += u'BUTTON2_RELEASED'
    if buttonState & curses.BUTTON2_PRESSED:
        result += u'BUTTON2_PRESSED'
    if buttonState & curses.BUTTON2_CLICKED:
        result += u'BUTTON2_CLICKED'
    if buttonState & curses.BUTTON2_DOUBLE_CLICKED:
        result += u'BUTTON2_DOUBLE_CLICKED'

    if buttonState & curses.BUTTON3_RELEASED:
        result += u'BUTTON3_RELEASED'
    if buttonState & curses.BUTTON3_PRESSED:
        result += u'BUTTON3_PRESSED'
    if buttonState & curses.BUTTON3_CLICKED:
        result += u'BUTTON3_CLICKED'
    if buttonState & curses.BUTTON3_DOUBLE_CLICKED:
        result += u'BUTTON3_DOUBLE_CLICKED'

    if buttonState & curses.BUTTON4_RELEASED:
        result += u'BUTTON4_RELEASED'
    if buttonState & curses.BUTTON4_PRESSED:
        result += u'BUTTON4_PRESSED'
    if buttonState & curses.BUTTON4_CLICKED:
        result += u'BUTTON4_CLICKED'
    if buttonState & curses.BUTTON4_DOUBLE_CLICKED:
        result += u'BUTTON4_DOUBLE_CLICKED'

    if buttonState & curses.REPORT_MOUSE_POSITION:
        result += u'REPORT_MOUSE_POSITION'

    if buttonState & curses.BUTTON_SHIFT:
        result += u' SHIFT'
    if buttonState & curses.BUTTON_CTRL:
        result += u' CTRL'
    if buttonState & curses.BUTTON_ALT:
        result += u' ALT'
    return result 
开发者ID:google,项目名称:ci_edit,代码行数:51,代码来源:curses_util.py


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