当前位置: 首页>>代码示例>>Python>>正文


Python win32console.GetStdHandle方法代码示例

本文整理汇总了Python中win32console.GetStdHandle方法的典型用法代码示例。如果您正苦于以下问题:Python win32console.GetStdHandle方法的具体用法?Python win32console.GetStdHandle怎么用?Python win32console.GetStdHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32console的用法示例。


在下文中一共展示了win32console.GetStdHandle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def __init__(self, stream):
        import win32console
        red, green, blue, bold = (win32console.FOREGROUND_RED,
                                  win32console.FOREGROUND_GREEN,
                                  win32console.FOREGROUND_BLUE,
                                  win32console.FOREGROUND_INTENSITY)
        self.stream = stream
        self.screenBuffer = win32console.GetStdHandle(
            win32console.STD_OUT_HANDLE)
        self._colors = {'normal': red | green | blue,
                        'red': red | bold,
                        'green': green | bold,
                        'blue': blue | bold,
                        'yellow': red | green | bold,
                        'magenta': red | blue | bold,
                        'cyan': green | blue | bold,
                        'white': red | green | blue | bold} 
开发者ID:openstack,项目名称:ec2-api,代码行数:19,代码来源:colorizer.py

示例2: supported

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def supported(cls, stream=sys.stdout):
        try:
            import win32console
            screenBuffer = win32console.GetStdHandle(
                win32console.STD_OUT_HANDLE)
        except ImportError:
            return False
        import pywintypes
        try:
            screenBuffer.SetConsoleTextAttribute(
                win32console.FOREGROUND_RED |
                win32console.FOREGROUND_GREEN |
                win32console.FOREGROUND_BLUE)
        except pywintypes.error:
            return False
        else:
            return True 
开发者ID:openstack,项目名称:ec2-api,代码行数:19,代码来源:colorizer.py

示例3: __init__

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def __init__(self, stream):
        from win32console import GetStdHandle, STD_OUTPUT_HANDLE, \
             FOREGROUND_RED, FOREGROUND_BLUE, FOREGROUND_GREEN, \
             FOREGROUND_INTENSITY
        red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
                                  FOREGROUND_BLUE, FOREGROUND_INTENSITY)
        self.stream = stream
        self.screenBuffer = GetStdHandle(STD_OUTPUT_HANDLE)
        self._colors = {
            'normal': red | green | blue,
            'red': red | bold,
            'green': green | bold,
            'blue': blue | bold,
            'yellow': red | green | bold,
            'magenta': red | blue | bold,
            'cyan': green | blue | bold,
            'white': red | green | blue | bold
            } 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:reporter.py

示例4: supported

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def supported(cls, stream=sys.stdout):
        try:
            import win32console
            screenBuffer = win32console.GetStdHandle(
                win32console.STD_OUTPUT_HANDLE)
        except ImportError:
            return False
        import pywintypes
        try:
            screenBuffer.SetConsoleTextAttribute(
                win32console.FOREGROUND_RED |
                win32console.FOREGROUND_GREEN |
                win32console.FOREGROUND_BLUE)
        except pywintypes.error:
            return False
        else:
            return True 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:reporter.py

示例5: __init__

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def __init__(self, stream):
        import win32console
        red, green, blue, bold = (win32console.FOREGROUND_RED,
                                  win32console.FOREGROUND_GREEN,
                                  win32console.FOREGROUND_BLUE,
                                  win32console.FOREGROUND_INTENSITY)
        self.stream = stream
        self.screenBuffer = win32console.GetStdHandle(
            win32console.STD_OUT_HANDLE)
        self._colors = {
            'normal': red | green | blue,
            'red': red | bold,
            'green': green | bold,
            'blue': blue | bold,
            'yellow': red | green | bold,
            'magenta': red | blue | bold,
            'cyan': green | blue | bold,
            'white': red | green | blue | bold
        } 
开发者ID:openstack,项目名称:glance_store,代码行数:21,代码来源:colorizer.py

示例6: supported

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def supported(stream=sys.stdout):
        try:
            import win32console
            screenBuffer = win32console.GetStdHandle(
                win32console.STD_OUT_HANDLE)
        except ImportError:
            return False
        import pywintypes
        try:
            screenBuffer.SetConsoleTextAttribute(
                win32console.FOREGROUND_RED |
                win32console.FOREGROUND_GREEN |
                win32console.FOREGROUND_BLUE)
        except pywintypes.error:
            return False
        else:
            return True 
开发者ID:openstack,项目名称:glance_store,代码行数:19,代码来源:colorizer.py

示例7: __init__

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def __init__(self, stream):
        from win32console import GetStdHandle, STD_OUT_HANDLE
        from win32console import FOREGROUND_RED, FOREGROUND_BLUE
        from win32console import FOREGROUND_GREEN, FOREGROUND_INTENSITY
        red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
                                  FOREGROUND_BLUE, FOREGROUND_INTENSITY)
        self.stream = stream
        self.screenBuffer = GetStdHandle(STD_OUT_HANDLE)
        self._colors = {
            'normal': red | green | blue,
            'red': red | bold,
            'green': green | bold,
            'blue': blue | bold,
            'yellow': red | green | bold,
            'magenta': red | blue | bold,
            'cyan': green | blue | bold,
            'white': red | green | blue | bold} 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:19,代码来源:test_lib.py

示例8: __init__

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [as 别名]
def __init__(self, output_writer, tool_name):
    """Initializes a status view.

    Args:
      output_writer (OutputWriter): output writer.
      tool_name (str): namd of the tool.
    """
    super(StatusView, self).__init__()
    self._artifact_filters = None
    self._filter_file = None
    self._have_ansi_support = not win32console
    self._mode = self.MODE_WINDOW
    self._output_writer = output_writer
    self._source_path = None
    self._source_type = None
    self._stdout_output_writer = isinstance(
        output_writer, tools.StdoutOutputWriter)
    self._storage_file_path = None
    self._tool_name = tool_name

    if win32console:
      kernel32 = ctypes.windll.kernel32
      stdout_handle = kernel32.GetStdHandle(self._WINAPI_STD_OUTPUT_HANDLE)
      result = kernel32.SetConsoleMode(
          stdout_handle, self._WINAPI_ANSI_CONSOLE_MODE)
      self._have_ansi_support = result != 0 
开发者ID:log2timeline,项目名称:plaso,代码行数:28,代码来源:status_view.py

示例9: _ClearScreen

# 需要导入模块: import win32console [as 别名]
# 或者: from win32console import GetStdHandle [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. 
开发者ID:log2timeline,项目名称:plaso,代码行数:31,代码来源:status_view.py


注:本文中的win32console.GetStdHandle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。