home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / sgi / gl / glstdwin / fontchart.py next >
Text File  |  1992-03-30  |  661b  |  35 lines

  1. import stdwingl
  2.  
  3. import stdwin
  4. from stdwinevents import *
  5.  
  6. def main():
  7.     size = 12
  8.     w = stdwin.open('Font chart ' + `size`)
  9.     while 1:
  10.         type, window, detail = stdwin.getevent()
  11.         if type == WE_CLOSE:
  12.             break
  13.         if type == WE_DRAW:
  14.             width, height = w.getwinsize()
  15.             d = w.begindrawing()
  16.             d.setsize(size)
  17.             h, v = 0, 0
  18.             for c in range(32, 256):
  19.                 ch = chr(c)
  20.                 chw = d.textwidth(ch)
  21.                 if h + chw > width:
  22.                     v = v + d.lineheight()
  23.                     h = 0
  24.                     if v >= height:
  25.                         break
  26.                 d.text((h, v), ch)
  27.                 h = h + chw
  28.             del d
  29.         if type == WE_MOUSE_UP:
  30.             size = size + 1
  31.             w.settitle('Font chart ' + `size`)
  32.             w.change((0, 0), (2000, 2000))
  33.  
  34. main()
  35.