本文整理汇总了Python中ctypes.wintypes._COORD属性的典型用法代码示例。如果您正苦于以下问题:Python wintypes._COORD属性的具体用法?Python wintypes._COORD怎么用?Python wintypes._COORD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类ctypes.wintypes
的用法示例。
在下文中一共展示了wintypes._COORD属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetConsoleCursorPosition
# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import _COORD [as 别名]
def SetConsoleCursorPosition(stream_id, position):
position = wintypes._COORD(*position)
# If the position is out of range, do nothing.
if position.Y <= 0 or position.X <= 0:
return
# Adjust for Windows' SetConsoleCursorPosition:
# 1. being 0-based, while ANSI is 1-based.
# 2. expecting (x,y), while ANSI uses (y,x).
adjusted_position = wintypes._COORD(position.Y - 1, position.X - 1)
# Adjust for viewport's scroll position
sr = GetConsoleScreenBufferInfo(STDOUT).srWindow
adjusted_position.Y += sr.Top
adjusted_position.X += sr.Left
# Resume normal processing
handle = handles[stream_id]
return _SetConsoleCursorPosition(handle, adjusted_position)
示例2: setup_console
# 需要导入模块: from ctypes import wintypes [as 别名]
# 或者: from ctypes.wintypes import _COORD [as 别名]
def setup_console(self):
if self.headless:
self.console = Console(record=True)
if self.os == 'Windows':
window = windll.kernel32.GetConsoleWindow()
if window:
windll.user32.ShowWindow(window, 0)
elif 'WINDIR' in os.environ and 'WT_SESSION' not in os.environ:
set_terminal_size(100, 50)
windll.kernel32.SetConsoleScreenBufferSize(windll.kernel32.GetStdHandle(-11), wintypes._COORD(100, 200))
self.console = Console(width=97)
elif self.os == 'Darwin':
set_terminal_size(100, 50)
self.console = Console()
else:
self.console = Console()