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


Python display.Display方法代碼示例

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


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

示例1: snapshot

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def snapshot(self, filename="tmp.png"):
        """
        Take a screenshot and save it to `tmp.png` filename by default

        Args:
            filename: name of file where to store the screenshot

        Returns:
            display the screenshot

        """
        w, h = self.get_current_resolution()
        dsp = display.Display()
        root = dsp.screen().root
        raw = root.get_image(0, 0, w, h, X.ZPixmap, 0xffffffff)
        image = Image.frombytes("RGB", (w, h), raw.data, "raw", "BGRX")
        from airtest.aircv.utils import pil_2_cv2
        image = pil_2_cv2(image)
        return image 
開發者ID:AirtestProject,項目名稱:Airtest,代碼行數:21,代碼來源:linux.py

示例2: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self):
        threading.Thread.__init__(self)
        self.finished = threading.Event()
        
        # Give these some initial values
        self.mouse_position_x = 0
        self.mouse_position_y = 0
        self.ison = {"shift":False, "caps":False}
        
        # Compile our regex statements.
        self.isshift = re.compile('^Shift')
        self.iscaps = re.compile('^Caps_Lock')
        self.shiftablechar = re.compile('^[a-z0-9]$|^minus$|^equal$|^bracketleft$|^bracketright$|^semicolon$|^backslash$|^apostrophe$|^comma$|^period$|^slash$|^grave$')
        self.logrelease = re.compile('.*')
        self.isspace = re.compile('^space$')
        
        # Assign default function actions (do nothing).
        self.KeyDown = lambda x: True
        self.KeyUp = lambda x: True
        self.MouseAllButtonsDown = lambda x: True
        self.MouseAllButtonsUp = lambda x: True
        
        self.contextEventMask = [X.KeyPress,X.MotionNotify]
        
        # Hook to our display.
        self.local_dpy = display.Display()
        self.record_dpy = display.Display() 
開發者ID:OmkarPathak,項目名稱:Python-Programs,代碼行數:29,代碼來源:pyxhook.py

示例3: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self, context, on_skip, on_postpone, style_sheet_path):
        self.context = context
        self.count_labels = []
        self.display = Display()
        self.enable_postpone = False
        self.enable_shortcut = False
        self.is_pretified = False
        self.keycode_shortcut_postpone = 65
        self.keycode_shortcut_skip = 9
        self.on_postpone = on_postpone
        self.on_skip = on_skip
        self.shortcut_disable_time = 2
        self.strict_break = False
        self.windows = []

        # Initialize the theme
        css_provider = Gtk.CssProvider()
        css_provider.load_from_path(style_sheet_path)
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) 
開發者ID:slgobinath,項目名稱:SafeEyes,代碼行數:21,代碼來源:break_screen.py

示例4: dostuff

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def dostuff():
    d = display.Display()
    r = d.screen().root
    cm = d.screen().default_colormap

    for i in range(0, 1000):
        if i % 50 == 0:
            print('Iteration', i)

        r.delete_property(Xatom.WM_NORMAL_HINTS)
        r.delete_property(Xatom.WM_NORMAL_HINTS)
        r.get_geometry()
        r.get_geometry()
        r.delete_property(Xatom.WM_NORMAL_HINTS)
        r.delete_property(Xatom.WM_NORMAL_HINTS)
        r.change_property(Xatom.WM_NORMAL_HINTS, Xatom.STRING, 32, [1, 2, 3, 4])
        r.query_tree()
        cm.query_colors([0, 1, 2, 3, 4, 5, 6, 7]) 
開發者ID:python-xlib,項目名稱:python-xlib,代碼行數:20,代碼來源:profilex.py

示例5: main

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def main(argv):
    display = Display()

    thread = EventThread(display)
    thread.start()
    time.sleep(1)

    screen = display.screen()

    # The get_property call should not deadlock, despite the blocking next_event
    # call in the thread.
    atom = display.intern_atom('_XROOTPMAP_ID', True)
    response = screen.root.get_property(atom, Xatom.PIXMAP, 0, 1)
    print('get_property response: %r' % response)

    display.close() 
開發者ID:python-xlib,項目名稱:python-xlib,代碼行數:18,代碼來源:eventthread.py

示例6: main

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def main(argv):
    display = Display()

    if not display.has_extension('XFIXES'):
        if display.query_extension('XFIXES') is None:
            print('XFIXES extension not supported', file=sys.stderr)
            return 1

    xfixes_version = display.xfixes_query_version()
    print('Found XFIXES version %s.%s' % (
      xfixes_version.major_version,
      xfixes_version.minor_version,
    ), file=sys.stderr)

    screen = display.screen()

    print('Hiding cursor ...', file=sys.stderr)
    screen.root.xfixes_hide_cursor()
    display.sync()

    time.sleep(5)

    print('Showing cursor ...', file=sys.stderr)
    screen.root.xfixes_show_cursor()
    display.sync() 
開發者ID:python-xlib,項目名稱:python-xlib,代碼行數:27,代碼來源:xfixes.py

示例7: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self, display: Xdisplay.Display,
                 view, term_info: xutil.TerminalWindowInfo):
        """Changes the foreground color of the gc object.

        Args:
            display (Xlib.display.Display): any created instance
            parent_id (int): the X11 window id of the parent window
        """
        self._display = display
        self._screen = display.screen()
        self._colormap = None
        self.parent_info = term_info
        self.parent_window = None
        self.window = None
        self._view = view
        self._width = 1
        self._height = 1
        self._image = Xshm.Image(
            self._screen.width_in_pixels,
            self._screen.height_in_pixels)
        self.create() 
開發者ID:seebye,項目名稱:ueberzug,代碼行數:23,代碼來源:ui.py

示例8: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self, inkscape_id):
        self.id = inkscape_id
        self.disp = Display()
        self.screen = self.disp.screen()
        self.root = self.screen.root

        self.inkscape = self.disp.create_resource_object('window', inkscape_id)
        self.mode = normal_mode 
開發者ID:gillescastel,項目名稱:inkscape-shortcut-manager,代碼行數:10,代碼來源:main.py

示例9: main

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def main():
    disp = Display()
    screen = disp.screen()
    root = screen.root

    # First listen for existing windows
    for window in root.query_tree().children:
        if is_inkscape(window):
            print('Found existing window')
            listen = threading.Thread(target=create, args=[window.id])
            listen.start()


    # New windows
    root.change_attributes(event_mask=X.SubstructureNotifyMask)
    while True:
        evt = disp.next_event()
        if evt.type == X.CreateNotify:
            window = evt.window
            try:
                if is_inkscape(window):
                    print('New window!')
                    listen = threading.Thread(target=create, args=[window.id])
                    listen.start()

            except Xlib.error.BadWindow:
                pass 
開發者ID:gillescastel,項目名稱:inkscape-shortcut-manager,代碼行數:29,代碼來源:main.py

示例10: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self, _display=None, root=None):
        self.display = _display or display.Display()
        self.root = root or self.display.screen().root
        self.__getAttrs = {
            '_NET_CLIENT_LIST':           self.getClientList,
            '_NET_CLIENT_LIST_STACKING':  self.getClientListStacking,
            '_NET_NUMBER_OF_DESKTOPS':    self.getNumberOfDesktops,
            '_NET_DESKTOP_GEOMETRY':      self.getDesktopGeometry,
            '_NET_DESKTOP_VIEWPORT':      self.getDesktopViewPort,
            '_NET_CURRENT_DESKTOP':       self.getCurrentDesktop,
            '_NET_ACTIVE_WINDOW':         self.getActiveWindow,
            '_NET_WORKAREA':              self.getWorkArea,
            '_NET_SHOWING_DESKTOP':       self.getShowingDesktop,
            '_NET_WM_NAME':               self.getWmName,
            '_NET_WM_VISIBLE_NAME':       self.getWmVisibleName,
            '_NET_WM_DESKTOP':            self.getWmDesktop,
            '_NET_WM_WINDOW_TYPE':        self.getWmWindowType,
            '_NET_WM_STATE':              self.getWmState,
            '_NET_WM_ALLOWED_ACTIONS':    self.getWmAllowedActions,
            '_NET_WM_PID':                self.getWmPid,
        }
        self.__setAttrs = {
            '_NET_NUMBER_OF_DESKTOPS':  self.setNumberOfDesktops,
            '_NET_DESKTOP_GEOMETRY':    self.setDesktopGeometry,
            '_NET_DESKTOP_VIEWPORT':    self.setDesktopViewport,
            '_NET_CURRENT_DESKTOP':     self.setCurrentDesktop,
            '_NET_ACTIVE_WINDOW':       self.setActiveWindow,
            '_NET_SHOWING_DESKTOP':     self.setShowingDesktop,
            '_NET_CLOSE_WINDOW':        self.setCloseWindow,
            '_NET_MOVERESIZE_WINDOW':   self.setMoveResizeWindow,
            '_NET_WM_NAME':             self.setWmName,
            '_NET_WM_VISIBLE_NAME':     self.setWmVisibleName,
            '_NET_WM_DESKTOP':          self.setWmDesktop,
            '_NET_WM_STATE':            self.setWmState,
        }

    # ------------------------ setters properties ------------------------ 
開發者ID:parkouss,項目名稱:pyewmh,代碼行數:39,代碼來源:ewmh.py

示例11: get_current_resolution

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def get_current_resolution(self):
        d = display.Display()
        screen = d.screen()
        w, h = (screen["width_in_pixels"], screen["height_in_pixels"])
        return w, h 
開發者ID:AirtestProject,項目名稱:Airtest,代碼行數:7,代碼來源:linux.py

示例12: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self):
        self.display = display.Display()
        self.root = self.display.screen().root
        self.keys = {} 
開發者ID:pkkid,項目名稱:pygrid,代碼行數:6,代碼來源:pygrid.py

示例13: init_xlib

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def init_xlib(func):
    global xlib_display

    if xlib_display == None:
        xlib_display = display.Display()

    def wrap(*a, **kw):
        ret = func(*a, **kw)
        return ret

    return wrap 
開發者ID:dragondjf,項目名稱:QMusic,代碼行數:13,代碼來源:xutils.py

示例14: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self):
        self.display = Display(os.environ["DISPLAY"])
        self.MOUSE_BUTTONS = {
            "left": 1,
            "middle": 2,
            "right": 3,
            1: 1,
            2: 2,
            3: 3,
            4: 4,
            5: 5,
            6: 6,
            7: 7,
        } 
開發者ID:mozilla,項目名稱:iris,代碼行數:16,代碼來源:xmouse.py

示例15: __init__

# 需要導入模塊: from Xlib import display [as 別名]
# 或者: from Xlib.display import Display [as 別名]
def __init__(self):
        self.display = Display(os.environ["DISPLAY"]) 
開發者ID:mozilla,項目名稱:iris,代碼行數:4,代碼來源:keyboard.py


注:本文中的Xlib.display.Display方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。