當前位置: 首頁>>代碼示例>>Python>>正文


Python curses.BUTTON1_DOUBLE_CLICKED屬性代碼示例

本文整理匯總了Python中curses.BUTTON1_DOUBLE_CLICKED屬性的典型用法代碼示例。如果您正苦於以下問題:Python curses.BUTTON1_DOUBLE_CLICKED屬性的具體用法?Python curses.BUTTON1_DOUBLE_CLICKED怎麽用?Python curses.BUTTON1_DOUBLE_CLICKED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在curses的用法示例。


在下文中一共展示了curses.BUTTON1_DOUBLE_CLICKED屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _inject_mouse

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import BUTTON1_DOUBLE_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: set_mouse_tracking

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import BUTTON1_DOUBLE_CLICKED [as 別名]
def set_mouse_tracking(self, enable=True):
        """
        Enable mouse tracking.

        After calling this function get_input will include mouse
        click events along with keystrokes.
        """
        enable = bool(enable)
        if enable == self._mouse_tracking_enabled:
            return

        if enable:
            curses.mousemask(0
                | 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_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)
        else:
            raise NotImplementedError()

        self._mouse_tracking_enabled = enable 
開發者ID:AnyMesh,項目名稱:anyMesh-Python,代碼行數:29,代碼來源:curses_display.py

示例3: init_curses

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import BUTTON1_DOUBLE_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

示例4: get_event

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import BUTTON1_DOUBLE_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

示例5: _encode_mouse_event

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import BUTTON1_DOUBLE_CLICKED [as 別名]
def _encode_mouse_event(self):
        # convert to escape sequence
        last = next = self.last_bstate
        (id,x,y,z,bstate) = curses.getmouse()
        
        mod = 0
        if bstate & curses.BUTTON_SHIFT:    mod |= 4
        if bstate & curses.BUTTON_ALT:        mod |= 8
        if bstate & curses.BUTTON_CTRL:        mod |= 16
        
        l = []
        def append_button( b ):
            b |= mod
            l.extend([ 27, ord('['), ord('M'), b+32, x+33, y+33 ])
        
        if bstate & curses.BUTTON1_PRESSED and last & 1 == 0:
            append_button( 0 )
            next |= 1
        if bstate & curses.BUTTON2_PRESSED and last & 2 == 0:
            append_button( 1 )
            next |= 2
        if bstate & curses.BUTTON3_PRESSED and last & 4 == 0:
            append_button( 2 )
            next |= 4
        if bstate & curses.BUTTON4_PRESSED and last & 8 == 0:
            append_button( 64 )
            next |= 8
        if bstate & curses.BUTTON1_RELEASED and last & 1:
            append_button( 0 + escape.MOUSE_RELEASE_FLAG )
            next &= ~ 1
        if bstate & curses.BUTTON2_RELEASED and last & 2:
            append_button( 1 + escape.MOUSE_RELEASE_FLAG )
            next &= ~ 2
        if bstate & curses.BUTTON3_RELEASED and last & 4:
            append_button( 2 + escape.MOUSE_RELEASE_FLAG )
            next &= ~ 4
        if bstate & curses.BUTTON4_RELEASED and last & 8:
            append_button( 64 + escape.MOUSE_RELEASE_FLAG )
            next &= ~ 8
        
        if bstate & curses.BUTTON1_DOUBLE_CLICKED:
            append_button( 0 + escape.MOUSE_MULTIPLE_CLICK_FLAG )
        if bstate & curses.BUTTON2_DOUBLE_CLICKED:
            append_button( 1 + escape.MOUSE_MULTIPLE_CLICK_FLAG )
        if bstate & curses.BUTTON3_DOUBLE_CLICKED:
            append_button( 2 + escape.MOUSE_MULTIPLE_CLICK_FLAG )
        if bstate & curses.BUTTON4_DOUBLE_CLICKED:
            append_button( 64 + escape.MOUSE_MULTIPLE_CLICK_FLAG )

        if bstate & curses.BUTTON1_TRIPLE_CLICKED:
            append_button( 0 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )
        if bstate & curses.BUTTON2_TRIPLE_CLICKED:
            append_button( 1 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )
        if bstate & curses.BUTTON3_TRIPLE_CLICKED:
            append_button( 2 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )
        if bstate & curses.BUTTON4_TRIPLE_CLICKED:
            append_button( 64 + escape.MOUSE_MULTIPLE_CLICK_FLAG*2 )

        self.last_bstate = next
        return l 
開發者ID:AnyMesh,項目名稱:anyMesh-Python,代碼行數:62,代碼來源:curses_display.py

示例6: mouseButtonName

# 需要導入模塊: import curses [as 別名]
# 或者: from curses import BUTTON1_DOUBLE_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.BUTTON1_DOUBLE_CLICKED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。