summaryrefslogtreecommitdiffstats
path: root/Lib/lib-stdwin/gwin.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-12-14 12:57:56 (GMT)
committerGuido van Rossum <guido@python.org>1992-12-14 12:57:56 (GMT)
commit89a78697b86782a08be54269b9a7f55d4137d184 (patch)
treec93404611fb1495f466ccd5695b8e80cfab870a1 /Lib/lib-stdwin/gwin.py
parenta8993cfe16a04c612da72f72181ac63c6f858224 (diff)
downloadcpython-89a78697b86782a08be54269b9a7f55d4137d184.zip
cpython-89a78697b86782a08be54269b9a7f55d4137d184.tar.gz
cpython-89a78697b86782a08be54269b9a7f55d4137d184.tar.bz2
* Got entirely rid of path.py.
* Many modules: fixes for new, stricter, argument passing rules (most changes were automatic ones -- not all of this is tested!). * gwin.py: now uses mainloop.py for its main loop and window admin. * mainloop.py: always call dispatch() with event as a tuple! * Fix bug in pdb's 'clear' command -- don't set the bpt but clear it!
Diffstat (limited to 'Lib/lib-stdwin/gwin.py')
-rw-r--r--Lib/lib-stdwin/gwin.py27
1 files changed, 8 insertions, 19 deletions
diff --git a/Lib/lib-stdwin/gwin.py b/Lib/lib-stdwin/gwin.py
index 12ed90b..626c8fa 100644
--- a/Lib/lib-stdwin/gwin.py
+++ b/Lib/lib-stdwin/gwin.py
@@ -2,16 +2,11 @@
# Generic stdwin windows
# This is used as a base class from which to derive other window types.
-# The mainloop() function here is an event dispatcher for all window types.
-
-# XXX This is really obsoleted by "mainloop.py".
-# XXX Also you should to it class-oriented...
+# XXX DON'T USE THIS CODE ANY MORE! It is ages old!
import stdwin, stdwinq
from stdwinevents import *
-
-windows = [] # List of open windows
-
+from mainloop import mainloop, register, unregister, windows
# Open a window
@@ -37,16 +32,11 @@ def open(title): # Open a generic window
w.backspace = backspace
w.arrow = arrow
w.kleft = w.kup = w.kright = w.kdown = nop
- windows.append(w)
+ w.dispatch = treatevent
+ register(w)
return w
-# Generic event dispatching
-
-def mainloop(): # Handle events until no windows left
- while windows:
- treatevent(stdwinq.getevent())
-
def treatevent(e): # Handle a stdwin event
type, w, detail = e
if type == WE_DRAW:
@@ -95,10 +85,9 @@ def treatcommand(w, type): # Handle a we_command event
# Methods
def close(w): # Close method
- for i in range(len(windows)):
- if windows[i] is w:
- del windows[i]
- break
+ unregister(w)
+ del w.close # Delete our close function
+ w.close() # Call the close method
def arrow(w, detail): # Arrow key method
if detail == WC_LEFT:
@@ -118,4 +107,4 @@ def enter(w): w.char(w, '\n') # 'return' is a Python reserved word
def backspace(w): w.char(w, '\b')
def m2down(w, detail): w.mdown(w, detail)
def m2up(w, detail): w.mup(w, detail)
-def nop(args): pass
+def nop(*args): pass