diff options
author | Guido van Rossum <guido@python.org> | 1992-12-14 12:57:56 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-12-14 12:57:56 (GMT) |
commit | 89a78697b86782a08be54269b9a7f55d4137d184 (patch) | |
tree | c93404611fb1495f466ccd5695b8e80cfab870a1 /Lib/stdwin | |
parent | a8993cfe16a04c612da72f72181ac63c6f858224 (diff) | |
download | cpython-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/stdwin')
-rwxr-xr-x | Lib/stdwin/Abstract.py | 6 | ||||
-rwxr-xr-x | Lib/stdwin/BoxParent.py | 4 | ||||
-rwxr-xr-x | Lib/stdwin/Buttons.py | 12 | ||||
-rwxr-xr-x | Lib/stdwin/CSplit.py | 4 | ||||
-rwxr-xr-x | Lib/stdwin/DirList.py | 2 | ||||
-rwxr-xr-x | Lib/stdwin/FormSplit.py | 6 | ||||
-rwxr-xr-x | Lib/stdwin/HVSplit.py | 8 | ||||
-rwxr-xr-x | Lib/stdwin/Histogram.py | 2 | ||||
-rwxr-xr-x | Lib/stdwin/Sliders.py | 18 | ||||
-rwxr-xr-x | Lib/stdwin/Soundogram.py | 2 | ||||
-rwxr-xr-x | Lib/stdwin/Split.py | 2 | ||||
-rwxr-xr-x | Lib/stdwin/StripChart.py | 6 | ||||
-rwxr-xr-x | Lib/stdwin/TextEdit.py | 10 | ||||
-rwxr-xr-x | Lib/stdwin/WindowParent.py | 8 | ||||
-rwxr-xr-x | Lib/stdwin/formatter.py | 6 | ||||
-rwxr-xr-x | Lib/stdwin/gwin.py | 27 | ||||
-rwxr-xr-x | Lib/stdwin/mainloop.py | 2 |
17 files changed, 57 insertions, 68 deletions
diff --git a/Lib/stdwin/Abstract.py b/Lib/stdwin/Abstract.py index c6fe137..51bd305 100755 --- a/Lib/stdwin/Abstract.py +++ b/Lib/stdwin/Abstract.py @@ -30,7 +30,7 @@ class AbstractParent: def getwindow(self): return unimpl() # Only for very special cases # def change(self, area): unimpl() - def scroll(self, (area, (dh, dv))): unimpl() + def scroll(self, area, (dh, dv)): unimpl() def settimer(self, itimer): unimpl() class AbstractChild: @@ -40,10 +40,10 @@ class AbstractChild: def destroy(self): unimpl() # def realize(self): return unimpl() - def getminsize(self, (m, (width, height))): return unimpl() + def getminsize(self, m, (width, height)): return unimpl() def getbounds(self): return unimpl() def setbounds(self, bounds): unimpl() - def draw(self, (d, area)): unimpl() + def draw(self, d, area): unimpl() # # Downcalls only made after certain upcalls # diff --git a/Lib/stdwin/BoxParent.py b/Lib/stdwin/BoxParent.py index d042e88..a44995d 100755 --- a/Lib/stdwin/BoxParent.py +++ b/Lib/stdwin/BoxParent.py @@ -2,13 +2,13 @@ from TransParent import TransParent class BoxParent(TransParent): # - def create(self, (parent, (dh, dv))): + def create(self, parent, (dh, dv)): self = TransParent.create(self, parent) self.dh = dh self.dv = dv return self # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): width = max(0, width - 2*self.dh) height = max(0, height - 2*self.dv) width, height = self.child.getminsize(m, (width, height)) diff --git a/Lib/stdwin/Buttons.py b/Lib/stdwin/Buttons.py index d1435d3..9a99707 100755 --- a/Lib/stdwin/Buttons.py +++ b/Lib/stdwin/Buttons.py @@ -35,7 +35,7 @@ class LabelAppearance: # # Size enquiry # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): width = max(width, m.textwidth(self.text) + 6) height = max(height, m.lineheight() + 6) return width, height @@ -108,8 +108,8 @@ class LabelAppearance: d.erase(self.bounds) self.draw(d, self.bounds) # - def draw(self, (d, area)): - area = _rect.intersect(area, self.bounds) + def draw(self, d, area): + area = _rect.intersect([area, self.bounds]) if area == _rect.empty: return d.cliprect(area) @@ -145,7 +145,7 @@ class LabelAppearance: class StrutAppearance(LabelAppearance): # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): height = max(height, m.lineheight() + 6) return width, height # @@ -175,7 +175,7 @@ class ButtonAppearance(LabelAppearance): # class CheckAppearance(LabelAppearance): # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): minwidth = m.textwidth(self.text) + 6 minheight = m.lineheight() + 6 width = max(width, minwidth + minheight + m.textwidth(' ')) @@ -382,7 +382,7 @@ class Define: def destroy(self): self.parent = 0 # - def definetext(self, (parent, text)): + def definetext(self, parent, text): self = self.define(parent) self.settext(text) return self diff --git a/Lib/stdwin/CSplit.py b/Lib/stdwin/CSplit.py index 90d137e..90d5111 100755 --- a/Lib/stdwin/CSplit.py +++ b/Lib/stdwin/CSplit.py @@ -9,7 +9,7 @@ from Split import Split class CSplit(Split): # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): # Since things look best if the children are spaced evenly # along the circle (and often all children have the same # size anyway) we compute the max child size and assume @@ -65,5 +65,5 @@ class CSplit(Split): right, bottom = \ left + child_width, \ top + child_height - child.setbounds((left, top), (right, bottom)) + child.setbounds(((left, top), (right, bottom))) # diff --git a/Lib/stdwin/DirList.py b/Lib/stdwin/DirList.py index 00e9a8c..4b98b1d 100755 --- a/Lib/stdwin/DirList.py +++ b/Lib/stdwin/DirList.py @@ -11,7 +11,7 @@ from HVSplit import HSplit, VSplit class DirList(VSplit): # - def create(self, (parent, dirname)): + def create(self, parent, dirname): self = VSplit.create(self, parent) names = os.listdir(dirname) for name in names: diff --git a/Lib/stdwin/FormSplit.py b/Lib/stdwin/FormSplit.py index 16f3293..271cb23 100755 --- a/Lib/stdwin/FormSplit.py +++ b/Lib/stdwin/FormSplit.py @@ -20,7 +20,7 @@ class FormSplit(Split): self.last_child = None return Split.create(self, parent) # - def getminsize(self, (m, sugg_size)): + def getminsize(self, m, sugg_size): max_width, max_height = 0, 0 for c in self.children: c.form_width, c.form_height = c.getminsize(m, (0, 0)) @@ -38,9 +38,9 @@ class FormSplit(Split): for c in self.children: left, top = c.form_left + fleft, c.form_top + ftop right, bottom = left + c.form_width, top + c.form_height - c.setbounds((left, top), (right, bottom)) + c.setbounds(((left, top), (right, bottom))) # - def placenext(self, (left, top)): + def placenext(self, left, top): self.next_left = left self.next_top = top self.last_child = None diff --git a/Lib/stdwin/HVSplit.py b/Lib/stdwin/HVSplit.py index 9790b7b..c42327d 100755 --- a/Lib/stdwin/HVSplit.py +++ b/Lib/stdwin/HVSplit.py @@ -9,13 +9,13 @@ from Split import Split class HVSplit(Split): # - def create(self, (parent, hv)): + def create(self, parent, hv): # hv is 0 for HSplit, 1 for VSplit self = Split.create(self, parent) self.hv = hv return self # - def getminsize(self, (m, sugg_size)): + def getminsize(self, m, sugg_size): hv, vh = self.hv, 1 - self.hv size = [0, 0] sugg_size = [sugg_size[0], sugg_size[1]] @@ -46,8 +46,8 @@ class HVSplit(Split): corner = [0, 0] corner[vh] = end[vh] corner[hv] = origin[hv] + size[hv] - c.setbounds((origin[0], origin[1]), \ - (corner[0], corner[1])) + c.setbounds(((origin[0], origin[1]), \ + (corner[0], corner[1]))) origin[hv] = corner[hv] # XXX stretch # XXX too-small diff --git a/Lib/stdwin/Histogram.py b/Lib/stdwin/Histogram.py index 27ae673..74a75f3 100755 --- a/Lib/stdwin/Histogram.py +++ b/Lib/stdwin/Histogram.py @@ -12,7 +12,7 @@ class HistogramAppearance(LabelAppearance, Define): self.scale = (0, 100) return self # - def setdata(self, (ydata, scale)): + def setdata(self, ydata, scale): self.ydata = ydata self.scale = scale # (min, max) self.parent.change(self.bounds) diff --git a/Lib/stdwin/Sliders.py b/Lib/stdwin/Sliders.py index 0a709d6..cbf776d 100755 --- a/Lib/stdwin/Sliders.py +++ b/Lib/stdwin/Sliders.py @@ -69,12 +69,12 @@ class DragSliderAppearance(ButtonAppearance): def sethook(self, hook): self.hook = hook # - def setminvalmax(self, (min, val, max)): + def setminvalmax(self, min, val, max): self.min = min self.max = max self.setval(val) # - def settexts(self, (pretext, postext)): + def settexts(self, pretext, postext): self.pretext = pretext self.postext = postext self.recalctext() @@ -95,7 +95,7 @@ class DragSliderAppearance(ButtonAppearance): # class DragSlider(DragSliderReactivity, DragSliderAppearance, Define): - def definetext(self, (parent, text)): + def definetext(self, parent, text): raise RuntimeError, 'DragSlider.definetext() not supported' @@ -108,7 +108,7 @@ class _StepButton(PushButton): return self def setstep(self, step): self.step = step - def definetextstep(self, (parent, text, step)): + def definetextstep(self, parent, text, step): self = self.definetext(parent, text) self.setstep(step) return self @@ -145,7 +145,7 @@ class ComplexSlider(HSplit): # # Override HSplit methods # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): w1, h1 = self.downbutton.getminsize(m, (0, height)) w3, h3 = self.upbutton.getminsize(m, (0, height)) w1 = max(w1, h1) @@ -156,10 +156,10 @@ class ComplexSlider(HSplit): def setbounds(self, bounds): (left, top), (right, bottom) = self.bounds = bounds size = bottom - top - self.downbutton.setbounds((left, top), (left+size, bottom)) - self.dragbutton.setbounds((left+size, top), \ - (right-size, bottom)) - self.upbutton.setbounds((right-size, top), (right, bottom)) + self.downbutton.setbounds(((left, top), (left+size, bottom))) + self.dragbutton.setbounds(((left+size, top), \ + (right-size, bottom))) + self.upbutton.setbounds(((right-size, top), (right, bottom))) # # Pass other Slider methods on to dragbutton # diff --git a/Lib/stdwin/Soundogram.py b/Lib/stdwin/Soundogram.py index a68d4b3..e3c797e 100755 --- a/Lib/stdwin/Soundogram.py +++ b/Lib/stdwin/Soundogram.py @@ -5,7 +5,7 @@ from Histogram import Histogram class Soundogram(Histogram): # - def define(self, (win, chunk)): + def define(self, win, chunk): width, height = corner = win.getwinsize() bounds = (0, 0), corner self.chunk = chunk diff --git a/Lib/stdwin/Split.py b/Lib/stdwin/Split.py index aacfa98..8eb0254 100755 --- a/Lib/stdwin/Split.py +++ b/Lib/stdwin/Split.py @@ -39,7 +39,7 @@ class Split: self.mouse_focus = None self.keybd_focus = None # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): return unimpl() # Should ask children def getbounds(self): return unimpl() diff --git a/Lib/stdwin/StripChart.py b/Lib/stdwin/StripChart.py index 5bce412..afec007 100755 --- a/Lib/stdwin/StripChart.py +++ b/Lib/stdwin/StripChart.py @@ -8,7 +8,7 @@ from Buttons import LabelAppearance, NoReactivity class StripChart(LabelAppearance, NoReactivity): # - def define(self, (parent, scale)): + def define(self, parent, scale): self.parent = parent parent.addchild(self) self.init_appearance() @@ -49,8 +49,8 @@ class StripChart(LabelAppearance, NoReactivity): area = (left+i-1, top), (left+i, bottom) self.draw(self.parent.begindrawing(), area) # - def draw(self, (d, area)): - area = rect.intersect(area, self.bounds) + def draw(self, d, area): + area = rect.intersect([area, self.bounds]) if area == rect.empty: return d.cliprect(area) diff --git a/Lib/stdwin/TextEdit.py b/Lib/stdwin/TextEdit.py index 698a7d5..e08e496 100755 --- a/Lib/stdwin/TextEdit.py +++ b/Lib/stdwin/TextEdit.py @@ -7,7 +7,7 @@ from stdwinevents import * class TextEdit: # - def create(self, (parent, (cols, rows))): + def create(self, parent, (cols, rows)): parent.addchild(self) self.parent = parent self.cols = cols @@ -18,7 +18,7 @@ class TextEdit: self.dh = self.dv = 0 return self # - def createboxed(self, (parent, (cols, rows), (dh, dv))): + def createboxed(self, parent, (cols, rows), (dh, dv)): self = self.create(parent, (cols, rows)) self.dh = max(0, dh) self.dv = max(0, dv) @@ -37,7 +37,7 @@ class TextEdit: del self.editor del self.window # - def getminsize(self, (m, (width, height))): + def getminsize(self, m, (width, height)): width = max(0, width - 2*self.dh) height = max(0, height - 2*self.dv) if width > 0 and self.editor: @@ -96,7 +96,7 @@ class TextEdit: self.parent.need_keybd(self) self.parent.need_altdraw(self) # - def draw(self, (d, area)): + def draw(self, d, area): if self.dh and self.dv: d.box(self.bounds) # @@ -114,7 +114,7 @@ class TextEdit: def mouse_up(self, detail): x = self.editor.event(WE_MOUSE_UP, self.window, detail) # - def keybd(self, (type, detail)): + def keybd(self, type, detail): x = self.editor.event(type, self.window, detail) # def activate(self): diff --git a/Lib/stdwin/WindowParent.py b/Lib/stdwin/WindowParent.py index 697ed07..1964d38 100755 --- a/Lib/stdwin/WindowParent.py +++ b/Lib/stdwin/WindowParent.py @@ -14,7 +14,7 @@ Error = 'WindowParent.Error' # Exception class WindowParent(ManageOneChild): # - def create(self, (title, size)): + def create(self, title, size): self.title = title self.size = size # (width, height) self._reset() @@ -47,7 +47,7 @@ class WindowParent(ManageOneChild): def close_trigger(self): if self.close_hook: self.close_hook(self) # - def menu_trigger(self, (menu, item)): + def menu_trigger(self, menu, item): if self.menu_hook: self.menu_hook(self, menu, item) # @@ -94,7 +94,7 @@ class WindowParent(ManageOneChild): width = self.size[0] if self.vbar: height = self.size[1] - self.child.setbounds((0, 0), (width, height)) + self.child.setbounds(((0, 0), (width, height))) self.child.realize() self.win.dispatch = self.dispatch mainloop.register(self.win) @@ -109,7 +109,7 @@ class WindowParent(ManageOneChild): width = self.size[0] if self.vbar: height = self.size[1] - self.child.setbounds((0, 0), (width, height)) + self.child.setbounds(((0, 0), (width, height))) # Force a redraw of the entire window: self.win.change((0, 0), self.size) # diff --git a/Lib/stdwin/formatter.py b/Lib/stdwin/formatter.py index b2d4add..ac34ce9 100755 --- a/Lib/stdwin/formatter.py +++ b/Lib/stdwin/formatter.py @@ -13,7 +13,7 @@ class formatter: # Pass the window's drawing object, and left, top, right # coordinates of the drawing space as arguments. # - def init(self, (d, left, top, right)): + def init(self, d, left, top, right): self.d = d # Drawing object self.left = left # Left margin self.right = right # Right margin @@ -50,10 +50,10 @@ class formatter: # of the current font's space width. # (Two variations: one without, one with explicit stretch factor.) # - def addword(self, (word, spacefactor)): + def addword(self, word, spacefactor): self.addwordstretch(word, spacefactor, spacefactor) # - def addwordstretch(self, (word, spacefactor, stretchfactor)): + def addwordstretch(self, word, spacefactor, stretchfactor): width = self.d.textwidth(word) if width > self.avail_width: self._flush(1) diff --git a/Lib/stdwin/gwin.py b/Lib/stdwin/gwin.py index 12ed90b..626c8fa 100755 --- a/Lib/stdwin/gwin.py +++ b/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 diff --git a/Lib/stdwin/mainloop.py b/Lib/stdwin/mainloop.py index ab8ad3a..f1fe617 100755 --- a/Lib/stdwin/mainloop.py +++ b/Lib/stdwin/mainloop.py @@ -23,7 +23,7 @@ last_window = None def register(win): # First test the dispatch function by passing it a null event -- # this catches registration of unconforming windows. - win.dispatch(WE_NULL, win, None) + win.dispatch((WE_NULL, win, None)) if win not in windows: windows.append(win) |