def setBuffer(self, rows=None, columns=None, handle = None): traceback.debug_server_client(str(handle)) width, height, curx, cury, wattr, left, top, right, bottom, maxx, maxy = self.getBuffer(handle) print(width, height, curx, cury, wattr, left, top, right, bottom, maxx, maxy) #pause() if not rows: rows = width if not columns: columns = height print("columns =", columns) print("rows =", rows) #bufsize = wintypes._COORD(100, 80) # rows, columns bufsize = wintypes._COORD(rows, columns) # rows, columns print("bufsize 0 =", bufsize) traceback.debug_server_client(str(bufsize)) if not handle: handle = self.hdl traceback.debug_server_client(str(handle)) print("handle 0 =", handle) #pause() try: windll.kernel32.SetConsoleScreenBufferSize(handle, bufsize) except: handle = self.hdl print("handle 1 =", handle) width, height, curx, cury, wattr, left, top, right, bottom, maxx, maxy = self.getBuffer(handle) bufsize = wintypes._COORD(rows, columns) # rows, columns print("bufsize 1 =", bufsize) traceback.debug_server_client(str(bufsize)) #pause() try: windll.kernel32.SetConsoleScreenBufferSize(handle, bufsize) except: os.system("mo BL={0} BC={1} WC={2} WL=10".format(rows, columns, columns))
def _scroll(self, start, stop, rows): if not rows: return csbi = GetConsoleScreenBufferInfo(HSTDOUT) # absolute position of window in screen buffer # interpret other coordinates as relative to the window window = csbi.srWindow # scroll region clip_rect = wintypes.SMALL_RECT( window.Left, window.Top + start, window.Right, window.Top + stop ) if rows > 0: region = wintypes.SMALL_RECT(window.Left, window.Top + rows, window.Right, window.Bottom) new_pos = wintypes._COORD(window.Left, window.Top) else: # minus signs since rows is a negative number region = wintypes.SMALL_RECT(window.Left, window.Top, window.Right, window.Bottom - rows) new_pos = wintypes._COORD(window.Left, window.Top - rows) # workaround: in this particular case, Windows doesn't seem to respect the clip area. if ( clip_rect.Bottom == window.Bottom-1 and region.Bottom >= window.Bottom-1 and new_pos.Y < region.Top ): # first scroll everything up clip_rect.Bottom = window.Bottom bottom, region.Bottom = region.Bottom, window.Bottom ScrollConsoleScreenBuffer(HSTDOUT, region, clip_rect, new_pos, u' ', self._attrs) # and then scroll the bottom back down new_pos.Y = window.Bottom region.Top = bottom-1 ScrollConsoleScreenBuffer(HSTDOUT, region, clip_rect, new_pos, u' ', self._attrs) else: ScrollConsoleScreenBuffer(HSTDOUT, region, clip_rect, new_pos, u' ', self._attrs)
def write(cls, handle, unistr): """Write character to console, avoid scroll on bottom line.""" csbi = CONSOLE_SCREEN_BUFFER_INFO() _GetConsoleScreenBufferInfo(handle, byref(csbi)) col, row = csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y width, height = csbi.dwSize.X, csbi.dwSize.Y for ch in unistr: if (col >= width - 1 and ch not in (u'\n', u'\b', u'\r') and not cls._overflow): ci = CHAR_INFO(ch, csbi.wAttributes) # do not advance cursor if we're on the last position of the # screen buffer, to avoid unwanted scrolling. _WriteConsoleOutputW(handle, byref(ci), wintypes._COORD(1, 1), wintypes._COORD(0, 0), wintypes.SMALL_RECT(col, row, col, row)) else: if cls._overflow and ch not in (u'\n', u'\r', u'\b'): _WriteConsoleW(handle, u'\r\n', 1, byref(wintypes.DWORD()), byref(wintypes.DWORD())) col = 0 cls._overflow = False _WriteConsoleW(handle, ch, 1, byref(wintypes.DWORD()), byref(wintypes.DWORD())) # if we don't include \n here we get glitches on regular console writes # is it necessary to treat CR and LF separately *in raw mode*? # i.e. in raw mode, shouldn't LF just move a line down without changing the column? if ch in (u'\r', u'\n'): col = 0 cls._overflow = False elif ch == u'\b': col = max(col - 1, 0) cls._overflow = False else: col = min(col + 1, width - 1)
def setup_console(self, buffer=0): if getattr(sys, 'frozen', False) and self.os == 'Windows': if buffer > 0: windll.kernel32.SetConsoleScreenBufferSize(self.chandle, wintypes._COORD(100, 100 + round(buffer, -2))) else: windll.kernel32.SetConsoleWindowInfo(self.chandle, True, byref(wintypes.SMALL_RECT(0, 0, 99, 49))) windll.kernel32.SetConsoleScreenBufferSize(self.chandle, wintypes._COORD(100, 50)) elif self.os == 'Darwin': set_terminal_size(100, 50)
def clear(self): """Clear the screen.""" csbi = GetConsoleScreenBufferInfo(HSTDOUT) # fill the entire screen with blanks FillConsoleOutputCharacter( HSTDOUT, u' ', csbi.dwSize.X * csbi.dwSize.Y, wintypes._COORD(0, 0) ) # now set the buffer's attributes accordingly FillConsoleOutputAttribute( HSTDOUT, self._attrs, csbi.dwSize.X * csbi.dwSize.Y, wintypes._COORD(0, 0) ) _SetConsoleCursorPosition(HSTDOUT, wintypes._COORD(0, 0))
def clear(self): """Clear the screen.""" csbi = GetConsoleScreenBufferInfo(self._hstdout) # fill the entire screen with blanks FillConsoleOutputCharacter(self._hstdout, u' ', csbi.dwSize.X * csbi.dwSize.Y, wintypes._COORD(0, 0)) # now set the buffer's attributes accordingly FillConsoleOutputAttribute(self._hstdout, self._attrs, csbi.dwSize.X * csbi.dwSize.Y, wintypes._COORD(0, 0)) _SetConsoleCursorPosition(self._hstdout, wintypes._COORD(0, 0))
def setup_console(self, buffer=False): if getattr(sys, 'frozen', False): if buffer: windll.kernel32.SetConsoleScreenBufferSize( self.chandle, wintypes._COORD(100, 100)) else: windll.kernel32.SetConsoleWindowInfo( self.chandle, True, byref(wintypes.SMALL_RECT(0, 0, 99, 49))) windll.kernel32.SetConsoleScreenBufferSize( self.chandle, wintypes._COORD(100, 50)) else: os.system('mode con: cols=100 lines=50')
def console_resize(width=80, height=24, buffer_height=600): '''Sets up the console size and buffer height. <at> param width {int} Width of console in column value. <at> param height {int} Height of console in row value. <at> param buffer_height {int} Buffer console height in row value. ''' from ctypes import windll, byref, create_string_buffer from ctypes.wintypes import SMALL_RECT, _COORD # Active console screen buffer # STD_OUTPUT_HANDLE -> -11, STD_ERROR_HANDLE -> -12) STDERR = -12 # SMALL_RECT input LEFT = 0 TOP = 0 RIGHT = width - 1 BOTTOM = height - 1 # handle hdl = windll.kernel32.GetStdHandle(STDERR) csbi = create_string_buffer(22) res = windll.kernel32.GetConsoleScreenBufferInfo(hdl, csbi) if res: import struct (bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw) # current_width = right - left + 1 # current_height = bottom - top + 1 current_buffer_height = bufy if buffer_height < height: buffer_height = height # order of resizing avoiding some problems if current_buffer_height > buffer_height: rect = SMALL_RECT(LEFT, TOP, RIGHT, BOTTOM) # (left,top,right,bottom) windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect)) bufsize = _COORD(width, buffer_height) # columns, rows windll.kernel32.SetConsoleScreenBufferSize(hdl, bufsize) else: bufsize = _COORD(width, buffer_height) # columns, rows windll.kernel32.SetConsoleScreenBufferSize(hdl, bufsize) rect = SMALL_RECT(LEFT, TOP, RIGHT, BOTTOM) # (left,top,right,bottom) windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect))
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)
def resize(self, height, width): """Resize terminal.""" csbi = GetConsoleScreenBufferInfo(self._hstdout) # SetConsoleScreenBufferSize can't make the buffer smaller than the window # SetConsoleWindowInfo can't make the window larger than the buffer (in either direction) # allow for both shrinking and growing by calling one of them twice, # for each direction separately new_size = wintypes._COORD(width, csbi.dwSize.Y) new_window = wintypes.SMALL_RECT(0, 0, width - 1, csbi.dwSize.Y - 1) _SetConsoleScreenBufferSize(self._hstdout, new_size) _SetConsoleWindowInfo(self._hstdout, True, new_window) _SetConsoleScreenBufferSize(self._hstdout, new_size) new_size = wintypes._COORD(width, height) new_window = wintypes.SMALL_RECT(0, 0, width - 1, height - 1) _SetConsoleScreenBufferSize(self._hstdout, new_size) _SetConsoleWindowInfo(self._hstdout, True, new_window) _SetConsoleScreenBufferSize(self._hstdout, new_size)
def clear_row(self): """Clear the current row.""" csbi = GetConsoleScreenBufferInfo(HSTDOUT) from_coord = wintypes._COORD(0, csbi.dwCursorPosition.Y) # fill the entire screen with blanks FillConsoleOutputCharacter(HSTDOUT, u' ', csbi.dwSize.X, from_coord) # now set the buffer's attributes accordingly FillConsoleOutputAttribute(HSTDOUT, self._attrs, csbi.dwSize.X, from_coord)
def resize(self, height, width): """Resize terminal.""" csbi = GetConsoleScreenBufferInfo(HSTDOUT) # SetConsoleScreenBufferSize can't make the buffer smaller than the window # SetConsoleWindowInfo can't make the window larger than the buffer (in either direction) # allow for both shrinking and growing by calling one of them twice, # for each direction separately new_size = wintypes._COORD(width, csbi.dwSize.Y) new_window = wintypes.SMALL_RECT(0, 0, width-1, csbi.dwSize.Y-1) _SetConsoleScreenBufferSize(HSTDOUT, new_size) _SetConsoleWindowInfo(HSTDOUT, True, new_window) _SetConsoleScreenBufferSize(HSTDOUT, new_size) new_size = wintypes._COORD(width, height) new_window = wintypes.SMALL_RECT(0, 0, width-1, height-1) _SetConsoleScreenBufferSize(HSTDOUT, new_size) _SetConsoleWindowInfo(HSTDOUT, True, new_window) _SetConsoleScreenBufferSize(HSTDOUT, new_size)
def _write_console(handle, unistr): """Write character to console, avoid scroll on bottom line.""" csbi = CONSOLE_SCREEN_BUFFER_INFO() _GetConsoleScreenBufferInfo(handle, byref(csbi)) col, row = csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y width, height = csbi.dwSize.X, csbi.dwSize.Y for ch in unistr: if (row == height - 1 and col >= width - 1 and ch != u'\n'): ci = CHAR_INFO(ch, csbi.wAttributes) # do not advance cursor if we're on the last position of the # screen buffer, to avoid unwanted scrolling. _WriteConsoleOutputW(handle, byref(ci), wintypes._COORD(1, 1), wintypes._COORD(0, 0), wintypes.SMALL_RECT(col, row, col, row)) else: _WriteConsoleW(handle, ch, 1, byref(wintypes.DWORD()), byref(wintypes.DWORD()))
def _write_console(handle, unistr): """Write character to console, avoid scroll on bottom line.""" csbi = CONSOLE_SCREEN_BUFFER_INFO() _GetConsoleScreenBufferInfo(handle, byref(csbi)) col, row = csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y width, height = csbi.dwSize.X, csbi.dwSize.Y for ch in unistr: if (row == height-1 and col >= width - 1 and ch != u'\n'): ci = CHAR_INFO(ch, csbi.wAttributes) # do not advance cursor if we're on the last position of the # screen buffer, to avoid unwanted scrolling. _WriteConsoleOutputW( handle, byref(ci), wintypes._COORD(1, 1), wintypes._COORD(0, 0), wintypes.SMALL_RECT(col, row, col, row) ) else: _WriteConsoleW( handle, ch, 1, byref(wintypes.DWORD()), byref(wintypes.DWORD()) )
def clear_row(self, width=None): """Clear the current row.""" csbi = GetConsoleScreenBufferInfo(self._hstdout) from_coord = wintypes._COORD(0, csbi.dwCursorPosition.Y) # fill the entire row with blanks if width is None: width = csbi.dwSize.X FillConsoleOutputCharacter(self._hstdout, u' ', width, from_coord) # now set the buffer's attributes accordingly FillConsoleOutputAttribute(self._hstdout, self._attrs, width, from_coord)
def cleanLastRows(amount): csbi = CONSOLE_SCREEN_BUFFER_INFO() windll.kernel32.GetConsoleScreenBufferInfo(stdout_handle, ctypes.byref(csbi)) pos = wintypes._COORD(0, csbi.dwCursorPosition.Y-amount) written = wintypes.DWORD(0) windll.kernel32.FillConsoleOutputCharacterA(stdout_handle, ctypes.c_char(32), wintypes.DWORD(csbi.dwSize.X * amount), pos, ctypes.byref(written)) windll.kernel32.SetConsoleCursorPosition(stdout_handle, pos)
def set_console_size(buffer_width, buffer_height, window_width, window_height): """设备窗口的缓冲区大小及窗口大小""" stdout = -11 hdl = windll.kernel32.GetStdHandle(stdout) # 句柄 bufsize = wintypes._COORD(buffer_width, buffer_height) # rows, columns windll.kernel32.SetConsoleScreenBufferSize(hdl, bufsize) # 设置窗口大小,窗口大小不能大于缓冲区大小,否则设置无效 # width = right - left + 1 # height = bottom - top + 1 rect = wintypes.SMALL_RECT(0, 0, window_width - 1, window_height - 1) # (left, top, right, bottom) windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect))
def scroll(self, top, bottom, rows): """Scroll the region between top and bottom one row up (-) or down (+).""" if not rows: return # use zero-based indexing start, stop = top - 1, bottom - 1 # we're using opposuite sign conventions csbi = GetConsoleScreenBufferInfo(self._hstdout) # absolute position of window in screen buffer # interpret other coordinates as relative to the window window = csbi.srWindow # scroll region clip_rect = wintypes.SMALL_RECT(window.Left, window.Top + start, window.Right, window.Top + stop) if rows < 0: # minus signs since rows is a negative number region = wintypes.SMALL_RECT(window.Left, window.Top - rows, window.Right, window.Bottom) new_pos = wintypes._COORD(window.Left, window.Top) else: region = wintypes.SMALL_RECT(window.Left, window.Top, window.Right, window.Bottom + rows) new_pos = wintypes._COORD(window.Left, window.Top + rows) # workaround: in this particular case, Windows doesn't seem to respect the clip area. if (clip_rect.Bottom == window.Bottom - 1 and region.Bottom >= window.Bottom - 1 and new_pos.Y < region.Top): # first scroll everything up clip_rect.Bottom = window.Bottom bottom, region.Bottom = region.Bottom, window.Bottom ScrollConsoleScreenBuffer(self._hstdout, region, clip_rect, new_pos, u' ', self._attrs) # and then scroll the bottom back down new_pos.Y = window.Bottom region.Top = bottom - 1 ScrollConsoleScreenBuffer(self._hstdout, region, clip_rect, new_pos, u' ', self._attrs) else: ScrollConsoleScreenBuffer(self._hstdout, region, clip_rect, new_pos, u' ', self._attrs)
def move_cursor_to(self, row, col): """Move cursor to a new position (1,1 is top left).""" csbi = GetConsoleScreenBufferInfo(HSTDOUT) row, col = row-1, col-1 while col >= csbi.dwSize.X: col -= csbi.dwSize.X row += 1 while col < 0: col += csbi.dwSize.X row -= 1 # If the position is out of range, do nothing. if row >= 0 and col >= 0: _SetConsoleCursorPosition(HSTDOUT, wintypes._COORD(col, row))
def move_cursor_to(self, row, col): """Move cursor to a new position (1,1 is top left).""" csbi = GetConsoleScreenBufferInfo(self._hstdout) row, col = row - 1, col - 1 while col >= csbi.dwSize.X: col -= csbi.dwSize.X row += 1 while col < 0: col += csbi.dwSize.X row -= 1 # If the position is out of range, do nothing. if row >= 0 and col >= 0: _SetConsoleCursorPosition(self._hstdout, wintypes._COORD(col, row))
def liste(product_list, Config): clean() # Si le nombre de produits et supérieur à la taille du CMD, on ajoute une scroll bar if len(product_list) >= 32: handle = windll.kernel32.GetStdHandle(-11) buffsize = int(18 + len(product_list)) bufsize = wintypes._COORD(92, buffsize) windll.kernel32.SetConsoleScreenBufferSize(handle, bufsize) # Liste les produits disponible sous forme de tableau ascii print(Style.DIM + Fore.YELLOW + (Config.name).center(92) + Style.RESET_ALL) print(("¯" * len(Config.name)).center(92)) print("==== Produits Disponibles ({}) ====\n".format( len([f for f in product_list])).center(50)) rows = [] for elt, content_file in enumerate(sorted(product_list)): headers = ["Id", "Nom", "Prix"] rows.append([ Style.BRIGHT + "[" + Fore.RED + str(elt) + Fore.WHITE + "]", Style.DIM + Fore.YELLOW + content_file[0], Fore.WHITE + content_file[2] + " " + Fore.CYAN + content_file[3] + Style.RESET_ALL, ]) print(tabulate(rows, headers=headers, tablefmt="rst")) print("\n") # Selection du produit voulu. try: Choice = int(input("Choississez un produit (ID): " + Fore.YELLOW)) print(Style.RESET_ALL) if Choice >= len([f for f in product_list]): raise Exception("Invalid number") for elt, product in enumerate(sorted(product_list)): if elt == Choice: product_info(product, Config) break except Exception as e: print(Style.RESET_ALL) clean() print(e) print(Style.BRIGHT + Fore.RED + "[ ERROR ] Veuillez entrer un nombre valide".center(92) + Style.RESET_ALL) time.sleep(2) liste(product_list)
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()
log.i("KeyboardInterrupt") fs_rm_file(pid_file_path) sys.exit(1) # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if __name__ == '__main__': if os.name == 'nt': # noinspection PyUnresolvedReferences import msvcrt from ctypes import windll, wintypes os.system('mode con: cols=140 lines=40') chandle = windll.kernel32.GetStdHandle(-11) # STDOUT # rect = wintypes.SMALL_RECT(0, 0, 100, 80) # (left, top, right, bottom) # noinspection PyProtectedMember bufsize = wintypes._COORD(140, 512) # rows, columns # windll.kernel32.SetConsoleWindowInfo(chandle, True, byref(rect)) windll.kernel32.SetConsoleScreenBufferSize(chandle, bufsize) # __________________________________________________________________________ pid_file_path = os.path.join(tempfile.gettempdir(), os.path.basename(sys.argv[0]) + '.pid') rc = main() # __________________________________________________________________________ if os.name == 'nt': log.i("Press any key to exit") msvcrt.getch() # __________________________________________________________________________ sys.exit(not rc) # Compatible return code
b_visible (int): Description dw_size (int): Description """ def __init__(self): """Clas initialisation.""" self.dw_size = 1 self.b_visible = 0 _fields_ = [('dw_size', c_int), ('b_visible', c_int)] STD_OUTPUT_HANDLE = -11 hStdOut = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE) cursorInfo = ConsoleCursorInfo() bufsize = wintypes._COORD(80, 30) # rows, columns windll.kernel32.SetConsoleScreenBufferSize(hStdOut, bufsize) windll.kernel32.SetConsoleCursorInfo(hStdOut, byref(cursorInfo)) windll.kernel32.SetConsoleTitleA(b'Battery monitor and alarm') init() sounds = [ "sounds/apx_battery_low_aler.mp3", "sounds/battery_low.mp3", "sounds/galaxy_low_battery.mp3", "sounds/htc_one_low_battery.mp3", "sounds/jarvis_low_battery.mp3", "sounds/low_battery (1).mp3", "sounds/low_battery.mp3" ] NOTIFY = "Awake: {AWAKE} | Battery: {PERCENT}% | {CHARGER_STATUS}. (Remaining: {TIME})"
import data_manager as dm import sys import traceback import os from colorama import Fore, Back, Style ############################### # 系统设置 ############################### # 调整窗口大小,buffer,标题 from ctypes import windll, byref, c_bool, c_wchar_p, wintypes STDOUT = -12 hdl = windll.kernel32.GetStdHandle(STDOUT) bufsize = wintypes._COORD(101, 300) # rows, columns windll.kernel32.SetConsoleScreenBufferSize(hdl, bufsize) rect = wintypes.SMALL_RECT(0, 0, 100, 40) # (left, top, right, bottom) windll.kernel32.SetConsoleWindowInfo(hdl, c_bool(True), byref(rect)) windll.kernel32.SetConsoleTitleW(c_wchar_p("图书馆管理系统")) # 日志 logger = dm.logger # 中文对齐 pd.set_option('display.unicode.east_asian_width', True) pd.set_option('display.unicode.ambiguous_as_wide', True) pd.set_option('display.expand_frame_repr', False) pd.set_option('display.width', 100)
<<<<<<< HEAD def SetConsoleCursorPosition(stream_id, position): position = wintypes._COORD(*position) ======= def SetConsoleCursorPosition(stream_id, position, adjust=True): position = COORD(*position) >>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027 # 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). <<<<<<< HEAD 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 ======= adjusted_position = COORD(position.Y - 1, position.X - 1) if adjust: # Adjust for viewport's scroll position sr = GetConsoleScreenBufferInfo(STDOUT).srWindow adjusted_position.Y += sr.Top adjusted_position.X += sr.Left >>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027 # Resume normal processing handle = handles[stream_id] return _SetConsoleCursorPosition(handle, adjusted_position)
def SetConsoleCursorPosition(stream_id, position): position = wintypes._COORD(*position)
import YAPO.settings import os, platform x = 0 os.system('mode con: cols=140 lines=4096') os.system('cls' if os.name == 'nt' else 'clear') if platform.system() == "Windows": from ctypes import windll, byref import ctypes.wintypes as wintypes STDOUT = -11 hdl = windll.kernel32.GetStdHandle(STDOUT) rect = wintypes.SMALL_RECT(0, 0, 132, 55) # (left, top, right, bottom) windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect)) bufsize = wintypes._COORD(140, 4096) # rows, columns windll.kernel32.SetConsoleScreenBufferSize(hdl, bufsize) if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "YAPO.settings") from videos import apps from YAPO import pagination a = apps a = pagination if x == 0: print("") print( "____ ____ ___ ______ ______ _______ " )
try: from ctypes import windll, byref, wintypes import time time.sleep(.5) width = 90 height = 30 buffer_height = 200 hdl = windll.kernel32.GetStdHandle(-12) # os.system("mode con cols=" + str(width) + " lines=" + str(height)) # Kept here for reference rect = wintypes.SMALL_RECT(0, 50, 0 + width - 1, 50 + height - 1) # (left, top, right, bottom) windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect)) time.sleep( .5 ) # Allow time for window size to change before changing buffer size. bufsize = wintypes._COORD(width, buffer_height) # columns, rows windll.kernel32.SetConsoleScreenBufferSize(hdl, bufsize) os.system("cls") # Don't panic if the above doesn't work. except: pass #*********************************************************************** # Check FFMEGP location #*********************************************************************** def CheckFFMPEG(): if os.path.isfile(PATH_TO_FFMPEG): logging.debug('FFMPEG path validated as %s' % (PATH_TO_FFMPEG)) return True else:
# Set window size. I do this mainly so when FFMPEG_LOGLEVEL is info or higher, it will display properly. if sys.platform == 'win32': try: from ctypes import windll, byref, wintypes import time time.sleep(.5) width = 90 height = 30 buffer_height = 200 hdl = windll.kernel32.GetStdHandle(-12) # os.system("mode con cols=" + str(width) + " lines=" + str(height)) # Kept here for reference rect = wintypes.SMALL_RECT(0, 50, 0+width-1, 50+height-1) # (left, top, right, bottom) windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect)) time.sleep(.5) # Allow time for window size to change before changing buffer size. bufsize = wintypes._COORD(width, buffer_height) # columns, rows windll.kernel32.SetConsoleScreenBufferSize(hdl, bufsize) os.system("cls") # Don't panic if the above doesn't work. except: pass #*********************************************************************** # Check FFMEGP location #*********************************************************************** def CheckFFMPEG(): if os.path.isfile(PATH_TO_FFMPEG): logging.debug('FFMPEG path validated as %s' %(PATH_TO_FFMPEG)) return True else: print '***********************************************************************' print '*'
import sys #import textwrap from colorama import init init(strip=not sys.stdout.isatty()) # strip colors if stdout is redirected --- from termcolor import cprint from pyfiglet import figlet_format import os from ctypes import windll, byref,wintypes #os.system("mode con cols=79 lines=43") STDOUT = -11 hdl = windll.kernel32.GetStdHandle(STDOUT) rect = wintypes.SMALL_RECT(0, 50, 90, 180) # (left, top, right, bottom) windll.kernel32.SetConsoleWindowInfo(hdl, True, byref(rect)) bufsize = wintypes._COORD(1000, 100) # rows, columns windll.kernel32.SetConsoleScreenBufferSize(bufsize) cprint(figlet_format(' EISENRECORDER ', font='standard'), 'white', 'on_red', attrs=(['underline','bold', 'dark'])) with open("artwork/barbell_ascii.txt") as bb: print(bb.read())