本文整理匯總了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()