2015-06-21 24 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

相关问题