tcolor.py

来自「Python语言编译器」· Python 代码 · 共 44 行

PY
44
字号
# Try colors -- display all 256 possible colors, with their color indeximport stdwinglimport stdwinfrom stdwinevents import *NROWS = 16NCOLS = 16def main():	stdwin.setdefwinsize(NCOLS * stdwin.textwidth('12345'), \				NROWS * stdwin.lineheight() * 3)	w = stdwin.open('TestColors')	#	while 1:		type, window, detail = stdwin.getevent()		if type == WE_CLOSE:			print 'Bye.'			break		elif type == WE_SIZE:			w.change((0,0), (10000, 10000))		elif type == WE_DRAW:			width, height = w.getwinsize()			d = w.begindrawing()			for row in range(NROWS):				for col in range(NCOLS):					color = row*NCOLS + col					d.setfgcolor(color)					p = col*width/NCOLS, row*height/NROWS					q = (col+1)*width/NCOLS, \						(row+1)*height/NROWS					d.paint((p, q))					d.setfgcolor(0)					d.box((p, q))					d.text(p, `color`)					p = p[0] , p[1]+ d.lineheight()					d.setfgcolor(7)					d.text(p, `color`)			del d	#main()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?