파이썬 실행 흑백 반전
조회수 1496회
파이선 코드를 저장한 .py 파일을 실행하면 cmd 창으로 실행이 됩니다.
이를 메모장에 실행하거나 하는 식으로 흰색 배경에 검은색 글자가 나오도록 보고 싶은데,
별도의 실행용 프로그램이 있는 건가요??
아니면 배경을 흰색으로, 글자를 검은색으로 색상 반전을 시키는 코드가 있나요??
2 답변
-
콘솔창의 배경과 텍스트의 색을 지정하는건 해당 앱에서 설정하는것이지 파이썬과는 관계가 없습니다.
윈도우 환경이고 파이썬을 인스톨러로 설치했다면 설치 시 생성되는 IDLE 편집기로 실행해보세요.
-
답변이 조금 늦은 감이 있지만..파이썬 모듈로 흰색 배경, 글꼴 지정 정도는 가능합니다.
결과가 질문자님의 상상과는 사뭇 다를 수 있지만 혹시 몰라 코드 올려봅니다.
배경을 흰색으로, 글씨를 검정색으로 바꾸고, 글꼴을 D2coding으로 설정하는 코드입니다.
import os import ctypes 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), ("FontFamily", ctypes.c_uint), ("FontWeight", ctypes.c_uint), ("FaceName", ctypes.c_wchar * 32)] font = CONSOLE_FONT_INFOEX() font.cbSize = ctypes.sizeof(CONSOLE_FONT_INFOEX) font.nFont = 12 font.dwFontSize.X = 11 font.dwFontSize.Y = 18 font.FontFamily = 54 font.FaceName = "D2coding" # 'D2coding' 글꼴 설정 handle = ctypes.windll.kernel32.GetStdHandle(-11) ctypes.windll.kernel32.SetCurrentConsoleFontEx( handle, ctypes.c_long(False), ctypes.pointer(font)) os.system('color f0') # 흰색 배경, 검정 글씨로 변경 # 테스트 문구 print() print('한글을 사랑합시다!') input(':')
참고 : https://stackoverflow.com/questions/3592673/change-console-font-in-windows/26329412
-
(•́ ✖ •̀)
알 수 없는 사용자
-
댓글 입력