Clarify portability and main program.
[python/dscho.git] / Demo / sgi / gl / glstdwin / tcolor.py
blobd1c49e115d7e3ac16e83bca9056586ad516fb050
1 # Try colors -- display all 256 possible colors, with their color index
3 import stdwingl
5 import stdwin
6 from stdwinevents import *
8 NROWS = 16
9 NCOLS = 16
11 def main():
12 stdwin.setdefwinsize(NCOLS * stdwin.textwidth('12345'), \
13 NROWS * stdwin.lineheight() * 3)
14 w = stdwin.open('TestColors')
16 while 1:
17 type, window, detail = stdwin.getevent()
18 if type == WE_CLOSE:
19 print 'Bye.'
20 break
21 elif type == WE_SIZE:
22 w.change((0,0), (10000, 10000))
23 elif type == WE_DRAW:
24 width, height = w.getwinsize()
25 d = w.begindrawing()
26 for row in range(NROWS):
27 for col in range(NCOLS):
28 color = row*NCOLS + col
29 d.setfgcolor(color)
30 p = col*width/NCOLS, row*height/NROWS
31 q = (col+1)*width/NCOLS, \
32 (row+1)*height/NROWS
33 d.paint((p, q))
34 d.setfgcolor(0)
35 d.box((p, q))
36 d.text(p, `color`)
37 p = p[0] , p[1]+ d.lineheight()
38 d.setfgcolor(7)
39 d.text(p, `color`)
40 del d
43 main()