summaryrefslogtreecommitdiffstats
path: root/Demo/sgi
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-05-11 14:43:52 (GMT)
committerGuido van Rossum <guido@python.org>2000-05-11 14:43:52 (GMT)
commitdab6cb8f6dacc107e9482976ca2f8e0313f05131 (patch)
tree88eef631a9c853ed763bb1be126ad3a11d6185db /Demo/sgi
parentede8c6eea1da425960b27ed735a41bc23a72a89a (diff)
downloadcpython-dab6cb8f6dacc107e9482976ca2f8e0313f05131.zip
cpython-dab6cb8f6dacc107e9482976ca2f8e0313f05131.tar.gz
cpython-dab6cb8f6dacc107e9482976ca2f8e0313f05131.tar.bz2
removing more stdwin users
Diffstat (limited to 'Demo/sgi')
-rw-r--r--Demo/sgi/audio_stdwin/README19
-rwxr-xr-xDemo/sgi/audio_stdwin/jukebox.py321
-rwxr-xr-xDemo/sgi/audio_stdwin/rec.py268
-rwxr-xr-xDemo/sgi/audio_stdwin/vumeter.py35
-rw-r--r--Demo/sgi/gl/glstdwin/fontchart.py34
-rw-r--r--Demo/sgi/gl/glstdwin/glstdwdraw.py135
-rw-r--r--Demo/sgi/gl/glstdwin/glstdwin.py400
-rw-r--r--Demo/sgi/gl/glstdwin/glstdwmenu.py62
-rw-r--r--Demo/sgi/gl/glstdwin/glstdwwin.py139
-rw-r--r--Demo/sgi/gl/glstdwin/stdwingl.py10
-rw-r--r--Demo/sgi/gl/glstdwin/tcolor.py43
-rw-r--r--Demo/sgi/gl/glstdwin/tglsw.py70
-rw-r--r--Demo/sgi/gl/glstdwin/tmenu.py44
13 files changed, 0 insertions, 1580 deletions
diff --git a/Demo/sgi/audio_stdwin/README b/Demo/sgi/audio_stdwin/README
deleted file mode 100644
index 6d96fe1..0000000
--- a/Demo/sgi/audio_stdwin/README
+++ /dev/null
@@ -1,19 +0,0 @@
-Three programs that provide a user interface based upon STDWIN to the
-audio device of the SGI 4D/25. These scripts also demonstrate the power
-of a set of window interface classes implemented in Python that simplify
-the construction of all sorts of buttons, etc.
-
-XXX This hardware is already obsolete; see ../al for examples of audio
-XXX on the Indigo and 4D/35.
-
-jukebox Browses a directory full of sound samples and lets you
- play selected ones. (Probably not fully functional, it
- requires a conversion program.)
-
-rec A tape recorder that lets you record a sound sample,
- play it back, and save it to a file. Various options to
- set sampling rate, volume etc. When idle it doubles
- as a VU meter.
-
-vumeter A VU meter that displays a history of the volume of
- sound recently sampled from the microphone.
diff --git a/Demo/sgi/audio_stdwin/jukebox.py b/Demo/sgi/audio_stdwin/jukebox.py
deleted file mode 100755
index 2aaaa83..0000000
--- a/Demo/sgi/audio_stdwin/jukebox.py
+++ /dev/null
@@ -1,321 +0,0 @@
-#! /usr/bin/env python
-
-# JUKEBOX: browse directories full of sampled sound files.
-#
-# One or more "list windows" display the files and subdirectories of
-# the arguments. Double-clicking on a subdirectory opens a new window
-# displaying its contents (and so on recursively). Double clicking
-# on a file plays it as a sound file (assuming it is one).
-#
-# Playing is asynchronous: the application keeps listening to events
-# while the sample is playing, so you can change the volume (gain)
-# during playing, cancel playing or start a new sample right away.
-#
-# The control window displays the current output gain and a primitive
-# "stop button" to cancel the current play request.
-#
-# Sound files must currently be in Dik Winter's compressed Mac format.
-# Since decompression is costly, decompressed samples are saved in
-# /usr/tmp/@j* until the application is left. The files are read
-# afresh each time, though.
-
-import audio
-import sunaudio
-import commands
-import getopt
-import path
-import posix
-import rand
-import stdwin
-from stdwinevents import *
-import string
-import sys
-
-from WindowParent import WindowParent
-from HVSplit import VSplit
-from Buttons import PushButton
-from Sliders import ComplexSlider
-
-# Pathnames
-
-HOME_BIN_SGI = '/ufs/guido/bin/sgi/' # Directory where macsound2sgi lives
-DEF_DB = '/ufs/dik/sounds/Mac/HCOM' # Default directory of sounds
-
-
-# Global variables
-
-class struct: pass # Class to define featureless structures
-
-G = struct() # Holds writable global variables
-
-
-# Main program
-
-def main():
- G.synchronous = 0 # If set, use synchronous audio.write()
- G.debug = 0 # If set, print debug messages
- G.gain = 75 # Output gain
- G.rate = 3 # Sampling rate
- G.busy = 0 # Set while asynchronous playing is active
- G.windows = [] # List of open windows (except control)
- G.mode = 'mac' # Macintosh mode
- G.tempprefix = '/usr/tmp/@j' + `rand.rand()` + '-'
- #
- optlist, args = getopt.getopt(sys.argv[1:], 'dg:r:sSa')
- for optname, optarg in optlist:
- if optname == '-d':
- G.debug = 1
- elif optname == '-g':
- G.gain = string.atoi(optarg)
- if not (0 < G.gain < 256):
- raise optarg.error, '-g gain out of range'
- elif optname == '-r':
- G.rate = string.atoi(optarg)
- if not (1 <= G.rate <= 3):
- raise optarg.error, '-r rate out of range'
- elif optname == '-s':
- G.synchronous = 1
- elif optname == '-S':
- G.mode = 'sgi'
- elif optname == '-a':
- G.mode = 'sun'
- #
- if not args:
- args = [DEF_DB]
- #
- G.cw = opencontrolwindow()
- for dirname in args:
- G.windows.append(openlistwindow(dirname))
- #
- #
- savegain = audio.getoutgain()
- try:
- # Initialize stdaudio
- audio.setoutgain(0)
- audio.start_playing('')
- dummy = audio.wait_playing()
- audio.setoutgain(0)
- maineventloop()
- finally:
- audio.setoutgain(savegain)
- audio.done()
- clearcache()
-
-def maineventloop():
- mouse_events = WE_MOUSE_DOWN, WE_MOUSE_MOVE, WE_MOUSE_UP
- while G.windows:
- type, w, detail = event = stdwin.getevent()
- if w == G.cw.win:
- if type == WE_CLOSE:
- return
- G.cw.dispatch(event)
- else:
- if type == WE_DRAW:
- w.drawproc(w, detail)
- elif type in mouse_events:
- w.mouse(w, type, detail)
- elif type == WE_CLOSE:
- w.close(w)
- del w, event
- else:
- if G.debug: print type, w, detail
-
-# Control window -- to set gain and cancel play operations in progress
-
-def opencontrolwindow():
- cw = WindowParent().create('Jukebox', (0, 0))
- v = VSplit().create(cw)
- #
- gain = ComplexSlider().define(v)
- gain.setminvalmax(0, G.gain, 255)
- gain.settexts(' ', ' ')
- gain.sethook(gain_setval_hook)
- #
- stop = PushButton().definetext(v, 'Stop')
- stop.hook = stop_hook
- #
- cw.realize()
- return cw
-
-def gain_setval_hook(self):
- G.gain = self.val
- if G.busy: audio.setoutgain(G.gain)
-
-def stop_hook(self):
- if G.busy:
- audio.setoutgain(0)
- dummy = audio.stop_playing()
- G.busy = 0
-
-
-# List windows -- to display list of files and subdirectories
-
-def openlistwindow(dirname):
- list = posix.listdir(dirname)
- list.sort()
- i = 0
- while i < len(list):
- if list[i] == '.' or list[i] == '..':
- del list[i]
- else:
- i = i+1
- for i in range(len(list)):
- name = list[i]
- if path.isdir(path.join(dirname, name)):
- list[i] = list[i] + '/'
- width = maxwidth(list)
- width = width + stdwin.textwidth(' ') # XXX X11 stdwin bug workaround
- height = len(list) * stdwin.lineheight()
- stdwin.setdefwinsize(width, min(height, 500))
- w = stdwin.open(dirname)
- stdwin.setdefwinsize(0, 0)
- w.setdocsize(width, height)
- w.drawproc = drawlistwindow
- w.mouse = mouselistwindow
- w.close = closelistwindow
- w.dirname = dirname
- w.list = list
- w.selected = -1
- return w
-
-def maxwidth(list):
- width = 1
- for name in list:
- w = stdwin.textwidth(name)
- if w > width: width = w
- return width
-
-def drawlistwindow(w, area):
- d = w.begindrawing()
- d.erase((0, 0), (1000, 10000))
- lh = d.lineheight()
- h, v = 0, 0
- for name in w.list:
- d.text((h, v), name)
- v = v + lh
- showselection(w, d)
-
-def hideselection(w, d):
- if w.selected >= 0:
- invertselection(w, d)
-
-def showselection(w, d):
- if w.selected >= 0:
- invertselection(w, d)
-
-def invertselection(w, d):
- lh = d.lineheight()
- h1, v1 = p1 = 0, w.selected*lh
- h2, v2 = p2 = 1000, v1 + lh
- d.invert(p1, p2)
-
-def mouselistwindow(w, type, detail):
- (h, v), clicks, button = detail[:3]
- d = w.begindrawing()
- lh = d.lineheight()
- if 0 <= v < lh*len(w.list):
- i = v / lh
- else:
- i = -1
- if w.selected <> i:
- hideselection(w, d)
- w.selected = i
- showselection(w, d)
- if type == WE_MOUSE_DOWN and clicks >= 2 and i >= 0:
- name = path.join(w.dirname, w.list[i])
- if name[-1:] == '/':
- if clicks == 2:
- G.windows.append(openlistwindow(name[:-1]))
- else:
- playfile(name)
-
-def closelistwindow(w):
- remove(G.windows, w)
-
-def remove(list, item):
- for i in range(len(list)):
- if list[i] == item:
- del list[i]
- break
-
-
-# Playing tools
-
-cache = {}
-
-def clearcache():
- for x in cache.keys():
- try:
- sts = posix.system('rm -f ' + cache[x])
- if sts:
- print cmd
- print 'Exit status', sts
- except:
- print cmd
- print 'Exception?!'
- del cache[x]
-
-def playfile(name):
- if G.mode <> 'mac':
- tempname = name
- elif cache.has_key(name):
- tempname = cache[name]
- else:
- tempname = G.tempprefix + `rand.rand()`
- cmd = HOME_BIN_SGI + 'macsound2sgi'
- cmd = cmd + ' ' + commands.mkarg(name)
- cmd = cmd + ' >' + tempname
- if G.debug: print cmd
- sts = posix.system(cmd)
- if sts:
- print cmd
- print 'Exit status', sts
- stdwin.fleep()
- return
- cache[name] = tempname
- fp = open(tempname, 'r')
- try:
- hdr = sunaudio.gethdr(fp)
- except sunaudio.error, msg:
- hdr = ()
- if hdr:
- data_size = hdr[0]
- data = fp.read(data_size)
- # XXX this doesn't work yet, need to convert from uLAW!!!
- del fp
- else:
- del fp
- data = readfile(tempname)
- if G.debug: print len(data), 'bytes read from', tempname
- if G.busy:
- G.busy = 0
- dummy = audio.stop_playing()
- #
- # Completely reset the audio device
- audio.setrate(G.rate)
- audio.setduration(0)
- audio.setoutgain(G.gain)
- #
- if G.synchronous:
- audio.write(data)
- audio.setoutgain(0)
- else:
- try:
- audio.start_playing(data)
- G.busy = 1
- except:
- stdwin.fleep()
- del data
-
-def readfile(filename):
- return readfp(open(filename, 'r'))
-
-def readfp(fp):
- data = ''
- while 1:
- buf = fp.read(102400) # Reads most samples in one fell swoop
- if not buf:
- return data
- data = data + buf
-
-main()
diff --git a/Demo/sgi/audio_stdwin/rec.py b/Demo/sgi/audio_stdwin/rec.py
deleted file mode 100755
index 76e924e..0000000
--- a/Demo/sgi/audio_stdwin/rec.py
+++ /dev/null
@@ -1,268 +0,0 @@
-#! /usr/bin/env python
-
-import sys
-import audio
-import stdwin
-
-import string
-import getopt
-
-from stdwinevents import *
-from Buttons import *
-from Sliders import *
-#from Soundogram import Soundogram
-from VUMeter import VUMeter
-from WindowParent import WindowParent, MainLoop
-from HVSplit import HSplit, VSplit
-
-class TimeOutToggleButton(ToggleButton):
- def define(self, parent):
- self = ToggleButton.define(self, parent)
- self.parent.need_timer(self)
- self.timer_hook = 0
- return self
- def timer(self):
- if self.timer_hook:
- self.timer_hook(self)
-
-K = 1024
-BUFSIZE = 30*8*K
-Rates = [0, 32*K, 16*K, 8*K]
-Magics = ['', '0032', '0016', '0008']
-
-class Struct: pass
-G = Struct()
-
-def main():
- #
- # Turn off scroll bars
- #
- stdwin.setdefscrollbars(0, 0)
- #
- # Set default state
- #
- G.gain = 60
- G.rate = 3
- G.nomuting = 0
- G.savefile = '@rec'
- #
- # Set default values
- #
- G.data = ''
- G.playing = 0
- G.recording = 0
- G.sogram = 0
- #
- # Parse options
- #
- optlist, args = getopt.getopt(sys.argv[1:], 'mdg:r:')
- #
- for optname, optarg in optlist:
- if 0: # (So all cases start with elif)
- pass
- elif optname == '-d':
- G.debug = 1
- elif optname == '-g':
- G.gain = string.atoi(optarg)
- if not (0 < G.gain < 256):
- raise optarg.error, '-g gain out of range'
- elif optname == '-m':
- G.nomuting = (not G.nomuting)
- elif optname == '-r':
- G.rate = string.atoi(optarg)
- if not (1 <= G.rate <= 3):
- raise optarg.error, '-r rate out of range'
- #
- if args:
- G.savefile = args[0]
- #
- # Initialize the sound package
- #
- audio.setoutgain(G.nomuting * G.gain) # Silence the speaker
- audio.setrate(G.rate)
- #
- # Create the WindowParent and VSplit
- #
- G.window = WindowParent().create('Recorder', (0, 0))
- w = G.vsplit = VSplit().create(G.window)
- #
- # VU-meter
- #
- G.vubtn = VUMeter().define(w)
- #
- # Radiobuttons for rates
- #
- r1btn = RadioButton().definetext(w, '32 K/sec')
- r1btn.on_hook = rate_hook
- r1btn.rate = 1
- #
- r2btn = RadioButton().definetext(w, '16 K/sec')
- r2btn.on_hook = rate_hook
- r2btn.rate = 2
- #
- r3btn = RadioButton().definetext(w, '8 K/sec')
- r3btn.on_hook = rate_hook
- r3btn.rate = 3
- #
- radios = [r1btn, r2btn, r3btn]
- r1btn.group = r2btn.group = r3btn.group = radios
- for r in radios:
- if r.rate == G.rate: r.select(1)
- #
- # Other controls
- #
- G.recbtn = TimeOutToggleButton().definetext(w, 'Record')
- G.recbtn.on_hook = record_on_hook
- G.recbtn.timer_hook = record_timer_hook
- G.recbtn.off_hook = record_off_hook
- #
- G.mutebtn = CheckButton().definetext(w, 'Mute')
- G.mutebtn.select(not G.nomuting)
- G.mutebtn.hook = mute_hook
- #
- G.playbtn = TimeOutToggleButton().definetext(w, 'Playback')
- G.playbtn.on_hook = play_on_hook
- G.playbtn.timer_hook = play_timer_hook
- G.playbtn.off_hook = play_off_hook
- #
- G.gainbtn = ComplexSlider().define(w)
- G.gainbtn.settexts(' Volume: ', ' ')
- G.gainbtn.setminvalmax(0, G.gain, 255)
- G.gainbtn.sethook(gain_hook)
- #
- G.sizebtn = Label().definetext(w, `len(G.data)` + ' bytes')
- #
- #G.showbtn = PushButton().definetext(w, 'Sound-o-gram...')
- #G.showbtn.hook = show_hook
- #
- G.savebtn = PushButton().definetext(w, 'Save...')
- G.savebtn.hook = save_hook
- #
- G.quitbtn = PushButton().definetext(w, 'Quit')
- G.quitbtn.hook = quit_hook
- G.playbtn.enable(0)
- G.savebtn.enable(0)
- #G.showbtn.enable(0)
- start_vu()
- G.window.realize()
- #
- # Event loop
- #
- MainLoop()
-
-# XXX Disabled...
-def show_hook(self):
- savetext = self.text
- self.settext('Be patient...')
- close_sogram()
- stdwin.setdefwinsize(400, 300)
- win = stdwin.open('Sound-o-gram')
- G.sogram = Soundogram().define(win, G.data)
- win.buttons = [G.sogram]
- self.settext(savetext)
-
-def close_sogram():
- if G.sogram:
- # Break circular references
- G.sogram.win.buttons[:] = []
- del G.sogram.win
- G.sogram = 0
-
-def mute_hook(self):
- G.nomuting = (not self.selected)
- audio.setoutgain(G.nomuting * G.gain)
-
-def rate_hook(self):
- G.rate = self.rate
- audio.setrate(G.rate)
-
-def record_on_hook(self):
- stop_vu()
- close_sogram()
- audio.setrate(G.rate)
- audio.setoutgain(G.nomuting * G.gain)
- audio.start_recording(BUFSIZE)
- G.recording = 1
- G.playbtn.enable(0)
- G.window.settimer(10 * BUFSIZE / Rates[G.rate])
-
-def record_timer_hook(self):
- if G.recording:
- if audio.poll_recording():
- self.hilite(0)
- record_off_hook(self)
- else:
- self.parent.settimer(5)
-
-def record_off_hook(self):
- if not G.recording:
- return
- G.data = audio.stop_recording()
- G.recording = 0
- G.sizebtn.settext(`len(G.data)` + ' bytes')
- audio.setoutgain(G.nomuting * G.gain)
- G.playbtn.enable((len(G.data) > 0))
- G.savebtn.enable((len(G.data) > 0))
- #G.showbtn.enable((len(G.data) > 0))
- G.window.settimer(0)
- start_vu()
-
-def play_on_hook(self):
- stop_vu()
- audio.setrate(G.rate)
- audio.setoutgain(G.gain)
- audio.start_playing(G.data)
- G.playing = 1
- G.recbtn.enable(0)
- G.window.settimer(max(10 * len(G.data) / Rates[G.rate], 1))
-
-def play_timer_hook(self):
- if G.playing:
- if audio.poll_playing():
- self.hilite(0)
- play_off_hook(self)
- else:
- self.parent.settimer(5)
-
-def play_off_hook(self):
- if not G.playing:
- return
- x = audio.stop_playing()
- G.playing = 0
- audio.setoutgain(G.nomuting * G.gain)
- G.recbtn.enable(1)
- G.window.settimer(0)
- start_vu()
-
-def gain_hook(self):
- G.gain = self.val
- if G.playing or G.nomuting: audio.setoutgain(G.gain)
-
-def save_hook(self):
- if not G.data:
- stdwin.fleep()
- else:
- prompt = 'Store sampled data on file: '
- try:
- G.savefile = stdwin.askfile(prompt, G.savefile, 1)
- except KeyboardInterrupt:
- return
- try:
- fp = open(G.savefile, 'w')
- fp.write(Magics[G.rate] + G.data)
- except:
- stdwin.message('Cannot create ' + file)
-
-def stop_vu():
- G.vubtn.stop()
-
-def start_vu():
- G.vubtn.start()
-
-def quit_hook(self):
- G.window.delayed_destroy()
-
-try:
- main()
-finally:
- audio.setoutgain(0)
diff --git a/Demo/sgi/audio_stdwin/vumeter.py b/Demo/sgi/audio_stdwin/vumeter.py
deleted file mode 100755
index e27c538..0000000
--- a/Demo/sgi/audio_stdwin/vumeter.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#! /usr/bin/env python
-
-import audio
-import stdwin
-
-from VUMeter import VUMeter
-from WindowParent import WindowParent
-import MainLoop
-
-NBUFS=20
-BUFSIZE = NBUFS*48
-SCALE=128
-
-class MyVUMeter(VUMeter):
- def init_reactivity(self):
- self.parent.need_mouse(self)
- def mouse_down(self, detail):
- if self.enabled:
- self.stop()
- else:
- self.start()
- def mouse_move(self, detail): pass
- def mouse_up(self, detail): pass
-
-def main():
- audio.setrate(3)
- audio.setoutgain(0)
- w = WindowParent().create('VU Meter', (200, 100))
- v = MyVUMeter().define(w)
- v.start()
- w.realize()
- while 1:
- w.dispatch(stdwin.getevent())
-
-main()
diff --git a/Demo/sgi/gl/glstdwin/fontchart.py b/Demo/sgi/gl/glstdwin/fontchart.py
deleted file mode 100644
index 6b58f12..0000000
--- a/Demo/sgi/gl/glstdwin/fontchart.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import stdwingl
-
-import stdwin
-from stdwinevents import *
-
-def main():
- size = 12
- w = stdwin.open('Font chart ' + `size`)
- while 1:
- type, window, detail = stdwin.getevent()
- if type == WE_CLOSE:
- break
- if type == WE_DRAW:
- width, height = w.getwinsize()
- d = w.begindrawing()
- d.setsize(size)
- h, v = 0, 0
- for c in range(32, 256):
- ch = chr(c)
- chw = d.textwidth(ch)
- if h + chw > width:
- v = v + d.lineheight()
- h = 0
- if v >= height:
- break
- d.text((h, v), ch)
- h = h + chw
- del d
- if type == WE_MOUSE_UP:
- size = size + 1
- w.settitle('Font chart ' + `size`)
- w.change((0, 0), (2000, 2000))
-
-main()
diff --git a/Demo/sgi/gl/glstdwin/glstdwdraw.py b/Demo/sgi/gl/glstdwin/glstdwdraw.py
deleted file mode 100644
index 4ddc7a6..0000000
--- a/Demo/sgi/gl/glstdwin/glstdwdraw.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# Define drawing operations for GL stdwin
-
-import gl
-import fm
-from GL import LO_XOR, LO_SRC
-from glstdwin import MASK
-
-class DrawingObject:
- #
- def _init(self, win):
- self.fg = win._fg
- self.bg = win._bg
- self.font = win._font
- self.size = win._size
- self.width, self.height = win._area[1]
- gl.winset(win._gid)
- gl.color(self.fg)
- return self
- #
- def setfont(self, fontname):
- self.font = fm.findfont(fontname).scalefont(self.size)
- #
- def setsize(self, size):
- ratio = float(size) / float(self.size)
- self.size = size
- self.font = self.font.scalefont(ratio)
- #
- def setfgcolor(self, color):
- self.fg = color
- gl.color(self.fg)
- #
- def setbgcolor(self, color):
- self.bg = color
- #
- def cliprect(self, area):
- #print 'cliprect', area
- (left, top), (right, bottom) = area
- gl.scrmask(left, right, self.height-bottom, self.height-top)
- #
- def noclip(self):
- #print 'noclip()'
- gl.scrmask(0, self.width, 0, self.height)
- #
- def paint(self, ((left, top), (right, bottom))):
- gl.rectf(left, top, right, bottom)
- #
- def box(self, ((left, top), (right, bottom))):
- #print 'box', ((left, top), (right, bottom))
- gl.rect(left, top, right, bottom)
- #
- def circle(self, (h, v), radius):
- gl.circ(h, v, radius)
- #
- def elarc(self, center, (rh, rv), (a1, a2)):
- pass # XXX
- #
- def erase(self, ((left, top), (right, bottom))):
- #print 'erase', ((left, top), (right, bottom))
- gl.color(self.bg)
- gl.rectf(left, top, right, bottom)
- gl.color(self.fg)
- #
- def invert(self, ((left, top), (right, bottom))):
- #print 'invert', ((h0, v0), (h1, v1))
- gl.logicop(LO_XOR)
- gl.color(self.bg)
- gl.rectf(left, top, right, bottom)
- gl.color(self.fg)
- gl.logicop(LO_SRC)
- #
- def line(self, (h0, v0), (h1, v1)):
- #print 'line', ((h0, v0), (h1, v1))
- gl.bgnline()
- gl.v2i(h0, v0)
- gl.v2i(h1, v1)
- gl.endline()
- #
- def xorline(self, (h0, v0), (h1, v1)):
- #print 'xorline', ((h0, v0), (h1, v1))
- gl.logicop(LO_XOR)
- gl.color(self.bg)
- gl.bgnline()
- gl.v2i(h0, v0)
- gl.v2i(h1, v1)
- gl.endline()
- gl.color(self.fg)
- gl.logicop(LO_SRC)
- #
- def point(self, (h, v)):
- #print 'point', (h, v)
- gl.bgnpoint()
- gl.v2i(h, v)
- gl.endpoint()
- #
- def text(self, (h, v), string):
- #print 'text', ((h, v), string)
- if h < 0:
- # If the point is outside the window
- # the whole string isn't drawn.
- # Skip the beginning of the string.
- # XXX What if the font is bigger than 20 pixels?
- i, n = 0, len(string)
- while h < -MASK and i < n:
- h = h + self.font.getstrwidth(string[i])
- i = i + 1
- string = string[i:]
- gl.cmov2(h, v + self.baseline())
- self.font.setfont()
- fm.prstr(string)
- #
- def shade(self, (h, v), percent):
- pass # XXX
- #
- def baseline(self):
- (printermatched, fixed_width, xorig, yorig, xsize, ysize, \
- height, nglyphs) = self.font.getfontinfo()
- return height - yorig
- #
- def lineheight(self):
- (printermatched, fixed_width, xorig, yorig, xsize, ysize, \
- height, nglyphs) = self.font.getfontinfo()
- return height
- #
- def textbreak(self, string, width):
- # XXX Slooooow!
- n = len(string)
- nwidth = self.textwidth(string[:n])
- while nwidth > width:
- n = n-1
- nwidth = self.textwidth(string[:n])
- return n
- #
- def textwidth(self, string):
- return self.font.getstrwidth(string)
- #
diff --git a/Demo/sgi/gl/glstdwin/glstdwin.py b/Demo/sgi/gl/glstdwin/glstdwin.py
deleted file mode 100644
index b7d02c7..0000000
--- a/Demo/sgi/gl/glstdwin/glstdwin.py
+++ /dev/null
@@ -1,400 +0,0 @@
-# GL STDWIN
-#
-# See stdwingl for a convenient hack to use this instead of built-in stdwin
-# without modifying your application, except for one line in the main file.
-#
-# Intrinsic differences with built-in stdwin (hard or impossible to fix):
-# - Need to call w.close() to close a window !!!
-# - Need to call m.close() to remove a menu !!!
-# - Doesn't enforce the existence of at most one drawing object
-# - No textedit package
-# - No X11 selections
-#
-# Not yet implemented:
-# - shade drawing
-# - elliptical arc drawing (need to play with transformation)
-# - more than one mouse button
-# - scroll bars (need to redo viewport handling to get this)
-# - partial redraws
-# - dialog boxes
-# - timer events
-# - cursors
-#
-# Extra features:
-# - color (for now, you need to know the colormap index)
-
-
-import gl
-import fm
-from GL import *
-from DEVICE import *
-from stdwinevents import *
-
-
-# Customizable constants
-#
-DEF_FONT = 'Times-Roman' # Default font
-DEF_SIZE = 12 # Default font size (points)
-MASK = 20 # Viewport minus scrmask
-
-
-# A structure to hold global variables
-#
-class Struct: pass
-G = Struct()
-#
-G.queue = [] # Pending STDWIN events
-G.drawqueue = [] # Windows that need WE_REDRAW
-G.windowmap = {} # Map window id to window object
-G.windowmap['0'] = None # For convenience
-G.focus = None # Input focus
-G.fg = BLACK # Foreground color
-G.bg = WHITE # Background color
-G.def_size = 0, 0 # Default window size
-G.def_pos = 0, 0 # Default window position
-#
-G.size = DEF_SIZE
-G.font = fm.findfont(DEF_FONT).scalefont(G.size)
-
-
-# Initialize GL
-#
-gl.foreground()
-gl.noport()
-dummygid = gl.winopen('')
-
-# Ask for all sorts of events
-#
-# Both REDRAW (= resize and/or redraw!) and INPUTCHANGE are implicitly queued
-#qdevice(REDRAW)
-#qdevice(INPUTCHANGE)
-#
-# Keyboard
-gl.qdevice(KEYBD)
-gl.qdevice(LEFTARROWKEY)
-gl.qdevice(RIGHTARROWKEY)
-gl.qdevice(UPARROWKEY)
-gl.qdevice(DOWNARROWKEY)
-gl.qdevice(LEFTALTKEY)
-gl.qdevice(RIGHTALTKEY)
-#
-# Mouse
-gl.qdevice(LEFTMOUSE)
-#gl.qdevice(MIDDLEMOUSE)
-gl.qdevice(RIGHTMOUSE) # Menu button
-# NB MOUSEX, MOUSEY events are queued on button down
-#
-# Window close requests
-gl.qdevice(WINQUIT)
-gl.qdevice(WINSHUT)
-#
-# These aren't needed
-#gl.qdevice(TIMER0)
-#gl.qdevice(WINFREEZE)
-#gl.qdevice(WINTHAW)
-#gl.qdevice(REDRAWICONIC)
-
-
-# STDWIN: create a new window
-#
-def open(title):
- h, v = G.def_pos
- width, height = G.def_size
- if h > 0 or v > 0:
- # Choose arbitrary defaults
- if h < 0: h = 10
- if v < 0: v = 30
- if width <= 0: width = 400
- if height <= 0: height = 300
- gl.prefposition(h, h+width, 1024-v, 1024-v-height)
- elif width > 0 or height > 0:
- if width <= 0: width = 400
- if height <= 0: height = 300
- gl.prefsize(width, height)
- from glstdwwin import WindowObject
- win = WindowObject()._init(title)
- G.windowmap[`win._gid`] = win
- return win
-
-
-# STDWIN: set default initial window position (0 means use default)
-#
-def setdefwinpos(h, v):
- G.def_pos = h, v
-
-
-# STDWIN: set default window size (0 means use default)
-#
-def setdefwinsize(width, height):
- G.def_size = width, height
-
-
-# STDWIN: beep or ring the bell
-#
-def fleep():
- gl.ringbell()
-
-
-# STDWIN: set default foreground color
-#
-def setfgcolor(color):
- G.fg = color
-
-
-# STDWIN: set default background color
-#
-def setbgcolor(color):
- G.bg = color
-
-
-# STDWIN: get default foreground color
-#
-def getfgcolor():
- return G.fgcolor
-
-
-# STDWIN: get default background color
-#
-def getbgcolor():
- return G.bgcolor
-
-
-# Table mapping characters to key codes
-#
-key2code = key = {}
-key['A'] = AKEY
-key['B'] = BKEY
-key['C'] = CKEY
-key['D'] = DKEY
-key['E'] = EKEY
-key['F'] = FKEY
-key['G'] = GKEY
-key['H'] = HKEY
-key['I'] = IKEY
-key['J'] = JKEY
-key['K'] = KKEY
-key['L'] = LKEY
-key['M'] = MKEY
-key['N'] = NKEY
-key['O'] = OKEY
-key['P'] = PKEY
-key['Q'] = QKEY
-key['R'] = RKEY
-key['S'] = SKEY
-key['T'] = TKEY
-key['U'] = UKEY
-key['V'] = VKEY
-key['W'] = WKEY
-key['X'] = XKEY
-key['Y'] = YKEY
-key['Z'] = ZKEY
-key['0'] = ZEROKEY
-key['1'] = ONEKEY
-key['2'] = TWOKEY
-key['3'] = THREEKEY
-key['4'] = FOURKEY
-key['5'] = FIVEKEY
-key['6'] = SIXKEY
-key['7'] = SEVENKEY
-key['8'] = EIGHTKEY
-key['9'] = NINEKEY
-del key
-#
-code2key = {}
-codelist = []
-for key in key2code.keys():
- code = key2code[key]
- code2key[`code`] = key
- codelist.append(code)
-del key
-
-
-# STDWIN: wait for the next event
-#
-commands = {}
-commands['\r'] = WC_RETURN
-commands['\b'] = WC_BACKSPACE
-commands['\t'] = WC_TAB
-#
-def getevent():
- while 1:
- #
- # Get next event from the processed queue, if any
- #
- if G.queue:
- event = G.queue[0]
- del G.queue[0]
- #print 'getevent from queue -->', event
- return event
- #
- # Get next event from the draw queue, if any,
- # but only if there is nothing in the system queue.
- #
- if G.drawqueue and not gl.qtest():
- win = G.drawqueue[0]
- del G.drawqueue[0]
- gl.winset(win._gid)
- gl.color(win._bg)
- gl.clear()
- event = WE_DRAW, win, win._area
- #print 'getevent from drawqueue -->', event
- return event
- #
- # Get next event from system queue, blocking if necessary
- # until one is available.
- # Some cases immediately return the event, others do nothing
- # or append one or more events to the processed queue.
- #
- dev, val = gl.qread()
- #
- if dev == REDRAW:
- win = G.windowmap[`val`]
- old_area = win._area
- win._fixviewport()
- win._needredraw()
- if old_area <> win._area:
- #print 'getevent --> WE_SIZE'
- return WE_SIZE, win, None
- elif dev == KEYBD:
- if val == 3:
- raise KeyboardInterrupt # Control-C in window
- character = chr(val)
- if commands.has_key(character):
- return WE_COMMAND, G.focus, commands[character]
- return WE_CHAR, G.focus, character
- elif dev == LEFTARROWKEY:
- if val:
- return WE_COMMAND, G.focus, WC_LEFT
- elif dev == RIGHTARROWKEY:
- if val:
- return WE_COMMAND, G.focus, WC_RIGHT
- elif dev == UPARROWKEY:
- if val:
- return WE_COMMAND, G.focus, WC_UP
- elif dev == DOWNARROWKEY:
- if val:
- return WE_COMMAND, G.focus, WC_DOWN
- elif dev in (LEFTALTKEY, RIGHTALTKEY):
- if val:
- for code in codelist:
- gl.qdevice(code)
- else:
- for code in codelist:
- gl.unqdevice(code)
- elif dev in codelist:
- if val:
- event = G.focus._doshortcut(code2key[`dev`])
- if event:
- return event
- elif dev == LEFTMOUSE:
- G.mousex = gl.getvaluator(MOUSEX)
- G.mousey = gl.getvaluator(MOUSEY)
- if val:
- type = WE_MOUSE_DOWN
- gl.qdevice(MOUSEX)
- gl.qdevice(MOUSEY)
- else:
- type = WE_MOUSE_UP
- gl.unqdevice(MOUSEX)
- gl.unqdevice(MOUSEY)
- return _mouseevent(type)
- elif dev == MOUSEX:
- G.mousex = val
- return _mouseevent(WE_MOUSE_MOVE)
- elif dev == MOUSEY:
- G.mousey = val
- return _mouseevent(WE_MOUSE_MOVE)
- elif dev == RIGHTMOUSE: # Menu button press/release
- if val: # Press
- event = G.focus._domenu()
- if event:
- return event
- elif dev == INPUTCHANGE:
- if G.focus:
- G.queue.append(WE_DEACTIVATE, G.focus, None)
- G.focus = G.windowmap[`val`]
- if G.focus:
- G.queue.append(WE_ACTIVATE, G.focus, None)
- elif dev in (WINSHUT, WINQUIT):
- return WE_CLOSE, G.windowmap[`val`], None
- else:
- print '*** qread() --> dev:', dev, 'val:', val
-
-# Helper routine to construct a mouse (up, move or down) event
-#
-def _mouseevent(type):
- gl.winset(G.focus._gid)
- orgx, orgy = gl.getorigin()
- sizex, sizey = gl.getsize()
- x = G.mousex - orgx
- y = G.mousey - orgy
- return type, G.focus, ((x, sizey-y), 1, 0, 0)
-
-
-
-
-# STDWIN: text measuring functions
-
-def baseline():
- (printermatched, fixed_width, xorig, yorig, xsize, ysize, \
- height, nglyphs) = G.font.getfontinfo()
- return height - yorig
-
-def lineheight():
- (printermatched, fixed_width, xorig, yorig, xsize, ysize, \
- height, nglyphs) = G.font.getfontinfo()
- return height
-
-def textbreak(string, width):
- # XXX Slooooow!
- n = len(string)
- nwidth = textwidth(string[:n])
- while nwidth > width:
- n = n-1
- nwidth = textwidth(string[:n])
- return n
-
-def textwidth(string):
- return G.font.getstrwidth(string)
-
-
-# STDWIN: set default font and size
-
-def setfont(fontname):
- G.font = fm.findfont(fontname).scalefont(G.size)
-
-def setsize(size):
- ratio = float(size) / float(G.size)
- G.size = size
- G.font = G.font.scalefont(ratio)
-
-
-# Utility functions
-
-# Exclusive-or of two BYTES
-#
-def xor(x, y):
- a = bits(x)
- b = bits(y)
- c = [0, 0, 0, 0, 0, 0, 0, 0]
- for i in range(8):
- c[i] = (a[i] + b[i]) % 2
- return stib(c)
-
-# Return the bits of a byte as a list of 8 integers
-#
-def bits(x):
- b = [0, 0, 0, 0, 0, 0, 0, 0]
- for i in range(8):
- x, b[i] = divmod(x, 2)
- return b
-
-# Convert a list of 8 integers (0|1) to a byte
-#
-def stib(b):
- x = 0
- shift = 1
- for i in range(8):
- x = x + b[i]*shift
- shift = shift*2
- return x
diff --git a/Demo/sgi/gl/glstdwin/glstdwmenu.py b/Demo/sgi/gl/glstdwin/glstdwmenu.py
deleted file mode 100644
index dd6d90b..0000000
--- a/Demo/sgi/gl/glstdwin/glstdwmenu.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Define menu operations for GL stdwin
-
-import gl
-from glstdwin import key2code
-
-class MenuObject:
- #
- def _init(self, win, title):
- self._win = win
- self._title = title
- self._items = []
- return self
- #
- def close(self):
- self._win.remove(self)
- del self._win
- #
- def additem(self, *args):
- if len(args) == 2:
- text, shortcut = args
- elif len(args) == 1:
- text, shortcut = args[0], None
- else:
- raise TypeError, 'arg count'
- self._items.append([text, shortcut, 1, 0])
- #
- def setitem(self, i, text):
- self._items[i][0] = text
- #
- def enable(self, i, flag):
- self._items[i][2] = flag
- #
- def check(self, i, flag):
- self._items[i][3] = flag
- #
- def _makepup(self, firstitem):
- pup = gl.newpup()
- if self._title:
- gl.addtopup(pup, self._title + '%t', 0)
- for item in self._items:
- text = item[0]
- if not item[2]: # Disabled
- text = ' ( ' + text + ' )%x-1'
- else:
- if item[3]: # Check mark
- text = '-> ' + text
- else:
- text = ' ' + text
- if key2code.has_key(item[1]):
- text = text + ' [Alt-' + item[1] + ']'
- text = text + '%x' + `firstitem`
- gl.addtopup(pup, text, 0)
- firstitem = firstitem + 1
- return pup
- #
- def _checkshortcut(self, char):
- for i in range(len(self._items)):
- item = self._items[i]
- if item[2] and item[1] == char:
- return i
- return -1
- #
diff --git a/Demo/sgi/gl/glstdwin/glstdwwin.py b/Demo/sgi/gl/glstdwin/glstdwwin.py
deleted file mode 100644
index b880b9a..0000000
--- a/Demo/sgi/gl/glstdwin/glstdwwin.py
+++ /dev/null
@@ -1,139 +0,0 @@
-# Define window operations for STDWIN
-
-import gl
-from stdwinevents import *
-from glstdwin import G # Global variables
-from glstdwin import MASK # Tunable constant
-
-class WindowObject:
- #
- def _init(self, title):
- self._docsize = (0, 0)
- self._fg = G.fg
- self._bg = G.bg
- self._title = title
- self._font = G.font
- self._size = G.size
- self._menus = []
- self._gid = gl.winopen(title)
- gl.winconstraints() # To remove prefsize() effect
- self._fixviewport()
- self._needredraw()
- return self
- #
- def close(self):
- del G.windowmap[`self._gid`]
- gl.winclose(self._gid)
- self._gid = 0
- #
- def _needredraw(self):
- if self in G.drawqueue:
- G.drawqueue.remove(self)
- G.drawqueue.append(self)
- #
- def begindrawing(self):
- from glstdwdraw import DrawingObject
- return DrawingObject()._init(self)
- #
- def change(self, area):
- self._needredraw()
- # XXX Should record the area to be drawn?
- #
- def gettitle(self):
- return self._title
- #
- def getdocsize(self):
- return self._docsize
- #
- def getorigin(self):
- return self._area[0]
- #
- def getwinsize(self):
- return self._area[1]
- #
- def scroll(self, area, by):
- # XXX ought to use gl.rectcopy()
- if by <> (0, 0):
- self.change(area)
- #
- def setdocsize(self, docsize):
- self._docsize = docsize
- #
- def setorigin(self, origin):
- pass # XXX
- #
- def settimer(self, decisecs):
- pass # XXX
- #
- def settitle(self, title):
- self._title = title
- gl.wintitle(title)
- #
- def show(self, area):
- pass # XXX
- #
- def _fixviewport(self):
- #
- # Called after redraw or resize, and initially.
- #
- # Fix the coordinate system so that (0, 0) is top left,
- # units are pixels, and positive axes point right and down.
- #
- # Make the viewport slightly larger than the window,
- # and set the screenmask exactly to the window; this
- # help fixing character clipping.
- #
- # Set self._area to the window rectangle in STDWIN coords.
- #
- gl.winset(self._gid)
- gl.reshapeviewport()
- x0, x1, y0, y1 = gl.getviewport()
- width, height = x1-x0, y1-y0
- gl.viewport(x0-MASK, x1+MASK, y0-MASK, y1+MASK)
- gl.scrmask(x0, x1, y0, y1)
- gl.ortho2(-MASK, width+MASK, height+MASK, -MASK)
- self._area = (0, 0), (width, height)
- #
- def menucreate(self, title):
- from glstdwmenu import MenuObject
- menu = MenuObject()._init(self, title)
- self._menus.append(menu)
- return menu
- #
- def _domenu(self):
- if not self._menus:
- return None
- if len(self._menus) == 1:
- pup = self._menus[0]._makepup(0)
- val = gl.dopup(pup)
- gl.freepup(pup)
- if val < 0:
- return None
- return WE_MENU, self, (self._menus[0], val)
- #
- # More than one menu: use nested menus.
- #
- pups = []
- firstitem = 0
- for menu in self._menus:
- pups.append(menu._makepup(firstitem))
- firstitem = firstitem + 100
- pup = gl.newpup()
- for i in range(len(self._menus)):
- gl.addtopup(pup, self._menus[i]._title + '%m', pups[i])
- val = gl.dopup(pup)
- gl.freepup(pup)
- for pup in pups:
- gl.freepup(pup)
- if val < 0:
- return None
- i_menu, i_item = divmod(val, 100)
- return WE_MENU, self, (self._menus[i_menu], i_item)
- #
- def _doshortcut(self, char):
- for menu in self._menus:
- i = menu._checkshortcut(char)
- if i >= 0:
- return WE_MENU, self, (menu, i)
- return None
- #
diff --git a/Demo/sgi/gl/glstdwin/stdwingl.py b/Demo/sgi/gl/glstdwin/stdwingl.py
deleted file mode 100644
index 4427593..0000000
--- a/Demo/sgi/gl/glstdwin/stdwingl.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# If you put 'import stdwin_gl' in front of the main program of a program
-# using stdwin (before it has a chance to import the real stdwin!),
-# it will use glstdwin and think it is stdwin.
-
-import sys
-if sys.modules.has_key('stdwin'):
- raise RuntimeError, 'too late -- stdwin has already been imported'
-
-import glstdwin
-sys.modules['stdwin'] = glstdwin
diff --git a/Demo/sgi/gl/glstdwin/tcolor.py b/Demo/sgi/gl/glstdwin/tcolor.py
deleted file mode 100644
index d1c49e1..0000000
--- a/Demo/sgi/gl/glstdwin/tcolor.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Try colors -- display all 256 possible colors, with their color index
-
-import stdwingl
-
-import stdwin
-from stdwinevents import *
-
-NROWS = 16
-NCOLS = 16
-
-def 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()
diff --git a/Demo/sgi/gl/glstdwin/tglsw.py b/Demo/sgi/gl/glstdwin/tglsw.py
deleted file mode 100644
index 8854e98..0000000
--- a/Demo/sgi/gl/glstdwin/tglsw.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import sys
-
-if len(sys.argv) < 2:
- import stdwingl
- color = 1
- needclose = 1
-else:
- color = 0
- needclose = 0
-
-import stdwin
-import time
-from stdwinevents import *
-from GL import BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE
-
-def main():
- #
- stdwin.setdefwinsize(300, 300)
- stdwin.setdefwinpos(0, 0)
- if color: stdwin.setbgcolor(YELLOW)
- w1 = stdwin.open('Hello, world')
- w1.box = (10, 10), (90, 90)
- #
- stdwin.setdefwinsize(0, 0)
- stdwin.setdefwinpos(50, 50)
- if color: stdwin.setbgcolor(GREEN)
- w2 = stdwin.open('Second window')
- w2.box = (10, 10), (90, 90)
- #
- while w1 or w2:
- type, window, detail = stdwin.getevent()
- if type == WE_DRAW:
- d = window.begindrawing()
- if window == w1:
- if color: d.setfgcolor(BLACK)
- d.box(((50, 50), (250, 250)))
- if color: d.setfgcolor(RED)
- d.cliprect(((50, 50), (250, 250)))
- d.paint(w1.box)
- d.noclip()
- if color: d.setfgcolor(BLUE)
- d.line((0, 0), w1.box[0])
- elif window == w2:
- if color: d.setfgcolor(WHITE)
- d.box(w2.box)
- if color: d.setfgcolor(BLACK)
- d.text(w2.box[0], 'Hello world')
- else:
- print 'Strange draw???', window, detail
- del d
- elif type == WE_CLOSE:
- if needclose: window.close()
- if window == w1:
- w1 = None
- elif window == w2:
- w2 = None
- else:
- print 'weird close event???', window, detail
- elif type in (WE_MOUSE_DOWN, WE_MOUSE_MOVE, WE_MOUSE_UP):
- h, v = detail[0]
- window.box = (h, v), (h+80, v+80)
- window.change(((0,0), (2000, 2000)))
- elif type == WE_CHAR:
- print 'character', `detail`
- else:
- print type, window, detail
- #
-
-main()
-print 'Done.'
diff --git a/Demo/sgi/gl/glstdwin/tmenu.py b/Demo/sgi/gl/glstdwin/tmenu.py
deleted file mode 100644
index 233edae..0000000
--- a/Demo/sgi/gl/glstdwin/tmenu.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# Test menus
-
-import stdwingl
-
-import stdwin
-from stdwinevents import *
-
-def main():
- w = stdwin.open('TestMenus')
- #
- items1 = 'Aap', 'Noot', 'Mies'
- m1 = w.menucreate('Menu-1')
- for item in items1:
- m1.additem(item, item[0])
- #
- items2 = 'Wim', 'Zus', 'Jet', 'Teun', 'Vuur'
- m2 = w.menucreate('Menu-2')
- for item in items2:
- m2.additem(item, `len(item)`)
- #
- m1.enable(1, 0)
- m2.check(1, 1)
- #
- while 1:
- type, window, detail = stdwin.getevent()
- if type == WE_CLOSE:
- break
- elif type == WE_DRAW:
- d = w.begindrawing()
- d.box(((50,50), (100,100)))
- del d
- elif type == WE_MENU:
- mp, i = detail
- if mp == m1:
- print 'Choice:', items1[i]
- elif mp == m2:
- print 'Choice:', items2[i]
- else:
- print 'Not one of my menus!'
- elif type == WE_CHAR:
- print 'Character', `detail`
- #
-
-main()