本文整理匯總了Python中win32console.PyCOORDType方法的典型用法代碼示例。如果您正苦於以下問題:Python win32console.PyCOORDType方法的具體用法?Python win32console.PyCOORDType怎麽用?Python win32console.PyCOORDType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類win32console
的用法示例。
在下文中一共展示了win32console.PyCOORDType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _print_at
# 需要導入模塊: import win32console [as 別名]
# 或者: from win32console import PyCOORDType [as 別名]
def _print_at(self, text, x, y, width):
"""
Print string at the required location.
:param text: The text string to print.
:param x: The x coordinate
:param y: The Y coordinate
:param width: The width of the character (for dual-width glyphs in CJK languages).
"""
# We can throw temporary errors on resizing, so catch and ignore
# them on the assumption that we'll resize shortly.
try:
# Move the cursor if necessary
if x != self._cur_x or y != self._cur_y:
self._stdout.SetConsoleCursorPosition(
win32console.PyCOORDType(x, y))
# Print the text at the required location and update the current
# position.
self._stdout.WriteConsole(text)
self._cur_x = x + width
self._cur_y = y
except pywintypes.error:
pass
示例2: _scroll
# 需要導入模塊: import win32console [as 別名]
# 或者: from win32console import PyCOORDType [as 別名]
def _scroll(self, lines):
"""
Scroll the window up or down.
:param lines: Number of lines to scroll. Negative numbers scroll
down.
"""
# Scroll the visible screen up by one line
info = self._stdout.GetConsoleScreenBufferInfo()['Window']
rectangle = win32console.PySMALL_RECTType(
info.Left, info.Top + lines, info.Right, info.Bottom)
new_pos = win32console.PyCOORDType(0, info.Top)
self._stdout.ScrollConsoleScreenBuffer(
rectangle, None, new_pos, " ", 0)
示例3: _clear
# 需要導入模塊: import win32console [as 別名]
# 或者: from win32console import PyCOORDType [as 別名]
def _clear(self):
"""
Clear the terminal.
"""
info = self._stdout.GetConsoleScreenBufferInfo()['Window']
width = info.Right - info.Left + 1
height = info.Bottom - info.Top + 1
box_size = width * height
self._stdout.FillConsoleOutputAttribute(
0, box_size, win32console.PyCOORDType(0, 0))
self._stdout.FillConsoleOutputCharacter(
" ", box_size, win32console.PyCOORDType(0, 0))
self._stdout.SetConsoleCursorPosition(
win32console.PyCOORDType(0, 0))
示例4: _ClearScreen
# 需要導入模塊: import win32console [as 別名]
# 或者: from win32console import PyCOORDType [as 別名]
def _ClearScreen(self):
"""Clears the terminal/console screen."""
if self._have_ansi_support:
# ANSI escape sequence to clear screen.
self._output_writer.Write('\033[2J')
# ANSI escape sequence to move cursor to top left.
self._output_writer.Write('\033[H')
elif win32console:
# This version of Windows cmd.exe does not support ANSI escape codes, thus
# instead we fill the console screen buffer with spaces. The downside of
# this approach is an annoying flicker.
top_left_coordinate = win32console.PyCOORDType(0, 0)
screen_buffer = win32console.GetStdHandle(win32api.STD_OUTPUT_HANDLE)
screen_buffer_information = screen_buffer.GetConsoleScreenBufferInfo()
screen_buffer_attributes = screen_buffer_information['Attributes']
screen_buffer_size = screen_buffer_information['Size']
console_size = screen_buffer_size.X * screen_buffer_size.Y
screen_buffer.FillConsoleOutputCharacter(
' ', console_size, top_left_coordinate)
screen_buffer.FillConsoleOutputAttribute(
screen_buffer_attributes, console_size, top_left_coordinate)
screen_buffer.SetConsoleCursorPosition(top_left_coordinate)
# TODO: remove update flicker. For win32console we could set the cursor
# top left, write the table, clean the remainder of the screen buffer
# and set the cursor at the end of the table.