1 Star 0 Fork 4

zzllzz/Cocos-Creator-Build-Tool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
consoleColorFont.py 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
hw_Geek7 提交于 2021-08-31 17:52 . 开源
import ctypes, sys
STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11
STD_ERROR_HANDLE = -12
# 字体颜色定义 text colors
FOREGROUND_BLUE = 0x09 # blue.
FOREGROUND_GREEN = 0x0a # green.
FOREGROUND_RED = 0x0c # red.
FOREGROUND_YELLOW = 0x0e # yellow.
# 背景颜色定义 background colors
BACKGROUND_YELLOW = 0xe0 # yellow.
# get handle
std_out_handle = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
def set_cmd_text_color(color, handle=std_out_handle):
Bool = ctypes.windll.kernel32.SetConsoleTextAttribute(handle, color)
return Bool
# reset white
def resetColor():
set_cmd_text_color(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
# green
def printGreen(mess):
set_cmd_text_color(FOREGROUND_GREEN)
sys.stdout.write(mess + '\n')
resetColor()
# red
def printRed(mess):
set_cmd_text_color(FOREGROUND_RED)
sys.stdout.write(mess + '\n')
resetColor()
# yellow
def printYellow(mess):
set_cmd_text_color(FOREGROUND_YELLOW)
sys.stdout.write(mess + '\n')
resetColor()
# white bkground and black text
def printYellowRed(mess):
set_cmd_text_color(BACKGROUND_YELLOW | FOREGROUND_RED)
sys.stdout.write(mess + '\n')
resetColor()
# example
# if __name__ == '__main__':
# printGreen("你好,世界!")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zzllzz/Cocos-Creator-Build-Tool.git
git@gitee.com:zzllzz/Cocos-Creator-Build-Tool.git
zzllzz
Cocos-Creator-Build-Tool
Cocos-Creator-Build-Tool
facebook2.4.4

搜索帮助

0d507c66 1850385 C8b1a773 1850385