def __init__(self): self.cols = 64 self.rows = 32 self.display_arr = [[0]*self.cols for _ in range(self.rows)] self.console_buffer = win32console.CreateConsoleScreenBuffer( DesiredAccess = win32con.GENERIC_READ | win32con.GENERIC_WRITE, ShareMode=0, SecurityAttributes=None, Flags=1) self.set_window_size() self.console_buffer.SetConsoleActiveScreenBuffer()
def __init__(self, size): super().__init__(size) self.draw.pixel = self.draw._db_pixel stdcon = win32console.GetStdHandle(win32console.STD_OUTPUT_HANDLE) self.active_screen = 0 self.screens = [ win32console.CreateConsoleScreenBuffer( DesiredAccess=win32con.GENERIC_READ | win32con.GENERIC_WRITE, ShareMode=0, SecurityAttributes=None, Flags=1), win32console.CreateConsoleScreenBuffer( DesiredAccess=win32con.GENERIC_READ | win32con.GENERIC_WRITE, ShareMode=0, SecurityAttributes=None, Flags=1) ] self.screens[self.active_screen].SetConsoleActiveScreenBuffer() self.cursor_size, _ = stdcon.GetConsoleCursorInfo() self.backbuffer = self.screens[1]
def __init__(self, command: Command, screen: Screen, server: Server): self.prepare_console() self.__command = command self.__screen = screen self.__server = server self.__console = win32console.CreateConsoleScreenBuffer( DesiredAccess=win32con.GENERIC_READ | win32con.GENERIC_WRITE, ShareMode=0, SecurityAttributes=None, Flags=1) self.__console.SetConsoleActiveScreenBuffer() self.__server.load_map_file( # f'{os.path.dirname(__file__)}/../maps_pattern/map_test.txt') f'{os.path.dirname(__file__)}/../maps_pattern/map_1_level_1.txt') self.__frame_count = 0
def main(): args = _parse_args() print(args) indexer = Indexer() train_data = PersonaDataset('train', args.persona, args.revision, indexer) valid_data = PersonaDataset('valid', args.persona, args.revision, indexer) test_data = PersonaDataset('test', args.persona, args.revision, indexer) counts = train_data.counts + valid_data.counts + test_data.counts counts = list(counts.values()) counts.sort(reverse=True) total = sum(counts) max_val = counts[0] max_p = max_val / total rows = 30 cols = 100 items_per_col = 204 columns = [Column(rows, i) for i in range(cols)] i = 0 while i < 300: val = counts[i] idx = int(math.floor(i / 3)) columns[idx].add_point((val/ total) / (max_p + .00001)) i+=1 sc_buf = win32console.CreateConsoleScreenBuffer() sc_buf.SetConsoleActiveScreenBuffer() # print(type(s)) print(sc_buf.GetConsoleScreenBufferInfo()) for col in columns: col.render(sc_buf) # sc_buf.SetConsoleScreenBufferSize(coord(120, 120)) sc_buf.WriteConsoleOutputCharacter("data visualization for 300 most frequent tokens", win32console.PyCOORDType(0,0)) c = msvcrt.getwch() # sc_buf.SetConsoleScreenBufferSize(s) # s = coord(100, 100) # sc_buf.SetConsoleScreenBufferSize(s) sc_buf.Close() return
for k,v in list(win32con.__dict__.items()): if k.startswith('VK_'): virtual_keys[v]=k free_console=True try: win32console.AllocConsole() except win32console.error as exc: if exc.winerror!=5: raise ## only free console if one was created successfully free_console=False stdout=win32console.GetStdHandle(win32console.STD_OUTPUT_HANDLE) stdin=win32console.GetStdHandle(win32console.STD_INPUT_HANDLE) newbuffer=win32console.CreateConsoleScreenBuffer() newbuffer.SetConsoleActiveScreenBuffer() newbuffer.SetConsoleTextAttribute(win32console.FOREGROUND_RED|win32console.FOREGROUND_INTENSITY |win32console.BACKGROUND_GREEN|win32console.BACKGROUND_INTENSITY) newbuffer.WriteConsole('This is a new screen buffer\n') ## test setting screen buffer and window size ## screen buffer size cannot be smaller than window size window_size=newbuffer.GetConsoleScreenBufferInfo()['Window'] coord=win32console.PyCOORDType(X=window_size.Right+20, Y=window_size.Bottom+20) newbuffer.SetConsoleScreenBufferSize(coord) window_size.Right+=10 window_size.Bottom+=10 newbuffer.SetConsoleWindowInfo(Absolute=True,ConsoleWindow=window_size)
def init_console_output(self): """Create a new console output buffer.""" self.console_output = win32console.CreateConsoleScreenBuffer()
def cursor_toggle(self, visible): console = win32console.CreateConsoleScreenBuffer() if visible: console.SetConsoleCursorInfo(1, True) else: console.SetConsoleCursorInfo(1, False)
def __cmdHandler(cls, msg): if cls.__cmdBuffer == None: win32console.AllocConsole() cls.__cmdBuffer = win32console.CreateConsoleScreenBuffer() cls.__cmdBuffer.SetConsoleActiveScreenBuffer() cls.__cmdBuffer.WriteConsole(msg)