本文整理汇总了Python中Xlib.display方法的典型用法代码示例。如果您正苦于以下问题:Python Xlib.display方法的具体用法?Python Xlib.display怎么用?Python Xlib.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xlib
的用法示例。
在下文中一共展示了Xlib.display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def display():
'''
A context manager for display
'''
d = Xlib.display.Display()
d.set_error_handler(handle_uncaught_errors)
yield d
d.close()
示例2: get_child_windows_from_xid
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def get_child_windows_from_xid(xid):
'''
Given an X window id, return the xid's of its children
'''
try:
with display() as d:
root = d.screen().root
xw = find_xwindow_by_id(xid, root)
children = []
for c in xw.query_tree().children:
children.append(xid_to_str(c.id))
return children
except Exception:
return []
示例3: _get_current_window_id
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def _get_current_window_id() -> Optional[int]:
atom = display.get_atom("_NET_ACTIVE_WINDOW")
window_prop = screen.root.get_full_property(atom, X.AnyPropertyType)
if window_prop is None:
logger.warning("window_prop was None")
return None
# window_prop may contain more than one value, but it seems that it's always the first we want.
# The second has in my attempts always been 0 or rubbish.
window_id = window_prop.value[0]
return window_id if window_id != 0 else None
示例4: _get_window
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def _get_window(window_id: int) -> Window:
return display.create_resource_object('window', window_id)
示例5: get_window_pid
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def get_window_pid(window: Window) -> str:
atom = display.get_atom("_NET_WM_PID")
pid_property = window.get_full_property(atom, X.AnyPropertyType)
if pid_property:
pid = pid_property.value[-1]
return pid
else:
# TODO: Needed?
raise Exception("pid_property was None")
示例6: setUp
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def setUp(self):
# Create authority file.
self.display_num = os.getenv("DISPLAY")
self.display = Xlib.display.Display(self.display_num)
self.dummy_str = "qqq"
self.keysym = 65535
示例7: test_display_instance
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_display_instance(self):
self.assertTrue(isinstance(self.display, Xlib.display.Display))
示例8: test_default_display_name
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_default_display_name(self):
self.assertEqual(self.display.get_display_name(), self.display_num)
示例9: test_default_screen_number
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_default_screen_number(self):
self.assertEqual(self.display.get_default_screen(), 0)
示例10: test_returns_no_events
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_returns_no_events(self):
self.assertEqual(self.display.pending_events(), 0)
示例11: test_set_get_pointer_mapping
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_set_get_pointer_mapping(self):
orig_mapping = self.display.get_pointer_mapping()
length = len(orig_mapping)
try:
self.display.set_pointer_mapping([0] * length)
self.assertEqual(self.display.get_pointer_mapping(), [0] * length)
finally:
self.display.set_pointer_mapping(orig_mapping)
示例12: test_can_close_display
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_can_close_display(self):
self.display.close()
self.assertEqual(str(self.display.display.socket_error), "Display connection closed by client")
示例13: test_can_close_display_and_check_for_error
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_can_close_display_and_check_for_error(self):
self.display.close()
self.assertRaises(Xlib.error.ConnectionClosedError, self.display.flush)
示例14: test_return_fileno
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_return_fileno(self):
self.assertTrue(isinstance(self.display.fileno(), int))
示例15: test_has_no_invalid_extension
# 需要导入模块: import Xlib [as 别名]
# 或者: from Xlib import display [as 别名]
def test_has_no_invalid_extension(self):
self.assertTrue(~self.display.has_extension(self.dummy_str))