Python Xlib.display.Display() Examples
The following are 30
code examples of Xlib.display.Display().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Xlib.display
, or try the search function
.
Example #1
Source File: linux.py From Airtest with Apache License 2.0 | 8 votes |
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
Example #2
Source File: xfixes.py From python-xlib with GNU Lesser General Public License v2.1 | 6 votes |
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()
Example #3
Source File: eventthread.py From python-xlib with GNU Lesser General Public License v2.1 | 6 votes |
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()
Example #4
Source File: profilex.py From python-xlib with GNU Lesser General Public License v2.1 | 6 votes |
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])
Example #5
Source File: ui.py From ueberzug with GNU General Public License v3.0 | 6 votes |
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()
Example #6
Source File: pyxhook.py From Python-Programs with GNU General Public License v3.0 | 6 votes |
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()
Example #7
Source File: break_screen.py From SafeEyes with GNU General Public License v3.0 | 6 votes |
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)
Example #8
Source File: x11.py From darkc0de-old-stuff with GNU General Public License v3.0 | 5 votes |
def getDisplay(): return Display()
Example #9
Source File: threadtest.py From python-xlib with GNU Lesser General Public License v2.1 | 5 votes |
def main(): d = display.Display() root = d.screen().root colormap = d.screen().default_colormap red = colormap.alloc_named_color("red").pixel blue = colormap.alloc_named_color("blue").pixel background = colormap.alloc_named_color("white").pixel window = root.create_window(100, 100, 100, 100, 1, X.CopyFromParent, X.InputOutput, X.CopyFromParent, background_pixel = background, event_mask = X.StructureNotifyMask | X.ExposureMask) window.map() gc = window.create_gc(foreground = red) thread.start_new_thread(blink, (d, window, gc, (blue, red))) while 1: event = d.next_event() if event.type == X.Expose: if event.count == 0: redraw(window, gc) elif event.type == X.DestroyNotify: sys.exit(0)
Example #10
Source File: rdb.py From python-xlib with GNU Lesser General Public License v2.1 | 5 votes |
def get_display_opts(options, argv = sys.argv): """display, name, db, args = get_display_opts(options, [argv]) Parse X OPTIONS from ARGV (or sys.argv if not provided). Connect to the display specified by a *.display resource if one is set, or to the default X display otherwise. Extract the RESOURCE_MANAGER property and insert all resources from ARGV. The four return values are: DISPLAY -- the display object NAME -- the application name (the filname of ARGV[0]) DB -- the created resource database ARGS -- any remaining arguments """ from Xlib import display, Xatom import os name = os.path.splitext(os.path.basename(argv[0]))[0] optdb = ResourceDB() leftargv = optdb.getopt(name, argv[1:], options) dname = optdb.get(name + '.display', name + '.Display', None) d = display.Display(dname) rdbstring = d.screen(0).root.get_full_property(Xatom.RESOURCE_MANAGER, Xatom.STRING) if rdbstring: data = rdbstring.value else: data = None db = ResourceDB(string = data) db.update(optdb) return d, name, db, leftargv # Common X options
Example #11
Source File: interface.py From autokey with GNU General Public License v3.0 | 5 votes |
def initialise(self): self.recordDisplay = display.Display() self.__locksChecked = False # Check for record extension if not self.recordDisplay.has_extension("RECORD"): raise Exception("Your X-Server does not have the RECORD extension available/enabled.")
Example #12
Source File: __init__.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
def get_resolution(): d = display.Display().screen() return (d.width_in_pixels, d.height_in_pixels)
Example #13
Source File: __init__.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
def get_cursor_pos(): d = display.Display().screen().root.query_pointer() return (d.root_x, d.root_y)
Example #14
Source File: pyxhook.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
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('|'.join(( '^[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.MouseMovement = lambda x: True self.contextEventMask = [X.KeyPress, X.MotionNotify] # Hook to our display. self.local_dpy = display.Display() self.record_dpy = display.Display()
Example #15
Source File: pyxhook.py From PythonP2PBotnet with MIT License | 5 votes |
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()
Example #16
Source File: viberwrapper-indicator.py From viberwrapper-indicator with GNU General Public License v2.0 | 5 votes |
def __init__(self): if self.INSTANCE is not None: raise ValueError("An instantiation already exists!") self.display = display.Display() self.root = self.display.screen().root
Example #17
Source File: rdb.py From MIA-Dictionary-Addon with GNU General Public License v3.0 | 5 votes |
def get_display_opts(options, argv = sys.argv): """display, name, db, args = get_display_opts(options, [argv]) Parse X OPTIONS from ARGV (or sys.argv if not provided). Connect to the display specified by a *.display resource if one is set, or to the default X display otherwise. Extract the RESOURCE_MANAGER property and insert all resources from ARGV. The four return values are: DISPLAY -- the display object NAME -- the application name (the filname of ARGV[0]) DB -- the created resource database ARGS -- any remaining arguments """ from Xlib import display, Xatom import os name = os.path.splitext(os.path.basename(argv[0]))[0] optdb = ResourceDB() leftargv = optdb.getopt(name, argv[1:], options) dname = optdb.get(name + '.display', name + '.Display', None) d = display.Display(dname) rdbstring = d.screen(0).root.get_full_property(Xatom.RESOURCE_MANAGER, Xatom.STRING) if rdbstring: data = rdbstring.value else: data = None db = ResourceDB(string = data) db.update(optdb) return d, name, db, leftargv # Common X options
Example #18
Source File: ewmh.py From deepin-remote-assistance with GNU General Public License v3.0 | 5 votes |
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 ------------------------
Example #19
Source File: xutil.py From ueberzug with GNU General Public License v3.0 | 5 votes |
def __init__(self, loop, display: Xdisplay.Display): self._loop = loop self._display = display
Example #20
Source File: xutil.py From ueberzug with GNU General Public License v3.0 | 5 votes |
def prepare_display(): """Fills up the display supplies.""" if len(PREPARED_DISPLAYS) < DISPLAY_SUPPLIES: PREPARED_DISPLAYS.append(Xdisplay.Display())
Example #21
Source File: xutil.py From ueberzug with GNU General Public License v3.0 | 5 votes |
def get_display(): """Unfortunately, Xlib tends to produce death locks on requests with an expected reply. (e.g. Drawable#get_geometry) Use for each request a new display as workaround. """ for _ in range(len(PREPARED_DISPLAYS), DISPLAY_SUPPLIES): asyncio.ensure_future(prepare_display()) if not PREPARED_DISPLAYS: return Xdisplay.Display() return PREPARED_DISPLAYS.pop()
Example #22
Source File: xutil.py From ueberzug with GNU General Public License v3.0 | 5 votes |
def get_pid_by_window_id(display: Xdisplay.Display, window_id: int): window = display.create_resource_object('window', window_id) prop = window.get_full_property(display.intern_atom('_NET_WM_PID'), Xlib.X.AnyPropertyType) return (prop.value[0] if prop else None)
Example #23
Source File: main.py From inkscape-shortcut-manager with MIT License | 5 votes |
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
Example #24
Source File: pyxhook.py From botnet-lab with MIT License | 5 votes |
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()
Example #25
Source File: main.py From inkscape-shortcut-manager with MIT License | 5 votes |
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
Example #26
Source File: ewmh.py From pyewmh with GNU Lesser General Public License v3.0 | 5 votes |
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 ------------------------
Example #27
Source File: linux.py From Airtest with Apache License 2.0 | 5 votes |
def get_current_resolution(self): d = display.Display() screen = d.screen() w, h = (screen["width_in_pixels"], screen["height_in_pixels"]) return w, h
Example #28
Source File: pygrid.py From pygrid with GNU General Public License v2.0 | 5 votes |
def __init__(self): self.display = display.Display() self.root = self.display.screen().root self.keys = {}
Example #29
Source File: xutils.py From QMusic with GNU Lesser General Public License v2.1 | 5 votes |
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
Example #30
Source File: xmouse.py From iris with Mozilla Public License 2.0 | 5 votes |
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, }