2015-06-21 22 views

回答

0

要更改命令提示符的大小:

import os 
os.system("mode con cols=18 lines=10") # cols for the width and lines for the length 

要更改命令提示符的charachter大小:

import ctypes 

STD_OUTPUT_HANDLE = -11 

class COORD(ctypes.Structure): 
    _fields_ = [("X", ctypes.c_short), ("Y", ctypes.c_short)] 

class CONSOLE_FONT_INFOEX(ctypes.Structure): 
    _fields_ = [("cbSize", ctypes.c_ulong), 
       ("nFont", ctypes.c_ulong), 
       ("dwFontSize", COORD)] 

font = CONSOLE_FONT_INFOEX() 
font.cbSize = ctypes.sizeof(CONSOLE_FONT_INFOEX) 
font.nFont = 12 
font.dwFontSize.X = 10 # in your case X=10 
font.dwFontSize.Y = 18 # and Y=18 



handle = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE) 
ctypes.windll.kernel32.SetCurrentConsoleFontEx(
     handle,False, ctypes.byref(font)) 
+0

這將cols和爲什麼要覆蓋OP的'FontFamily'和'FontWeight'?窗口的行不是字符 –

+0

例如,'FontFamily'的低4位(54&0xf == 6)表示一種TrueType固定間距字體。高4位(48)表示「現代」字體系列。你似乎堅決避免調用'GetCurrentConsoleFontEx'出於一些奇怪的原因。 – eryksun

+0

將值設置爲0只是使用當前值爲任意字體索引12的值。這仍然是錯誤的。 – eryksun

相關問題