New == syntax

This commit is contained in:
Guido van Rossum 1992-01-01 19:35:13 +00:00
parent 4d8e859e8f
commit bdfcfccbe5
73 changed files with 419 additions and 391 deletions

View file

@ -110,7 +110,7 @@ class LabelAppearance:
#
def draw(self, (d, area)):
area = _rect.intersect(area, self.bounds)
if area = _rect.empty:
if area == _rect.empty:
return
d.cliprect(area)
self.drawit(d)

View file

@ -43,7 +43,7 @@ class CSplit(Split):
# XXX One day Python will have automatic conversions...
n = len(self.children)
fn = float(n)
if n = 0: return
if n == 0: return
(left, top), (right, bottom) = bounds
width, height = right-left, bottom-top
child_width, child_height = width*3/(n+4), height*3/(n+4)

View file

@ -25,7 +25,7 @@ class DirList(VSplit):
if path.isdir(path.join(dirname, name)):
fullname = path.join(dirname, name)
btn = SubdirButton().definetext(self, fullname)
elif name[-3:] = '.py':
elif name[-3:] == '.py':
btn = ModuleButton().definetext(self, name)
else:
btn = FileButton().definetext(self, name)

View file

@ -116,7 +116,7 @@ class Split:
if not self.keybd_focus:
self.set_keybd_focus(self.keybd_interest[0])
type, detail = type_detail
if type = WE_COMMAND and detail = WC_TAB and \
if type == WE_COMMAND and detail == WC_TAB and \
len(self.keybd_interest) > 1:
self.next_keybd_focus()
return
@ -144,9 +144,9 @@ class Split:
self.timer_interest.remove(child)
if child in self.altdraw_interest:
self.altdraw_interest.remove(child)
if child = self.mouse_focus:
if child == self.mouse_focus:
self.mouse_focus = None
if child = self.keybd_focus:
if child == self.keybd_focus:
self.keybd_focus = None
#
def need_mouse(self, child):
@ -154,7 +154,7 @@ class Split:
self.mouse_interest.append(child)
self.parent.need_mouse(self)
def no_mouse(self, child):
if child = self.mouse_focus:
if child == self.mouse_focus:
self.mouse_focus = None
if child in self.mouse_interest:
self.mouse_interest.remove(child)
@ -168,7 +168,7 @@ class Split:
if not self.keybd_focus:
self.set_keybd_focus(child)
def no_keybd(self, child):
if child = self.keybd_focus:
if child == self.keybd_focus:
self.keybd_focus = None # Don't call child.deactivate()
if child in self.keybd_interest:
self.keybd_interest.remove(child)

View file

@ -51,7 +51,7 @@ class StripChart(LabelAppearance, NoReactivity):
#
def draw(self, (d, area)):
area = rect.intersect(area, self.bounds)
if area = rect.empty:
if area == rect.empty:
return
d.cliprect(area)
d.erase(self.bounds)

View file

@ -149,26 +149,26 @@ class WindowParent(ManageOneChild):
# Only call dispatch once we are realized
#
def dispatch(self, (type, win, detail)):
if type = WE_DRAW:
if type == WE_DRAW:
d = self.win.begindrawing()
self.child.draw(d, detail)
del d
if self.do_altdraw: self.child.altdraw(detail)
elif type = WE_MOUSE_DOWN:
elif type == WE_MOUSE_DOWN:
if self.do_mouse: self.child.mouse_down(detail)
elif type = WE_MOUSE_MOVE:
elif type == WE_MOUSE_MOVE:
if self.do_mouse: self.child.mouse_move(detail)
elif type = WE_MOUSE_UP:
elif type == WE_MOUSE_UP:
if self.do_mouse: self.child.mouse_up(detail)
elif type in (WE_CHAR, WE_COMMAND):
if self.do_keybd: self.child.keybd(type, detail)
elif type = WE_TIMER:
elif type == WE_TIMER:
if self.do_timer: self.child.timer()
elif type = WE_SIZE:
elif type == WE_SIZE:
self.fixup()
elif type = WE_CLOSE:
elif type == WE_CLOSE:
self.close_trigger()
elif type = WE_MENU:
elif type == WE_MENU:
self.menu_trigger(detail)
if self.pending_destroy:
self.destroy()

View file

@ -21,7 +21,7 @@ def delayfunc(msecs):
#
# Use millisleep for very short delays or if there are no windows
#
if msecs < 100 or mainloop.countwindows() = 0:
if msecs < 100 or mainloop.countwindows() == 0:
if msecs > 0:
time.millisleep(msecs)
return
@ -46,7 +46,7 @@ cancel = q.cancel
# Emptiness check must check both queues
#
def empty():
return q.empty() and mainloop.countwindows() = 0
return q.empty() and mainloop.countwindows() == 0
# Run until there is nothing left to do
#

View file

@ -10,7 +10,7 @@ import dircache
def action(w, string, i, detail):
(h, v), clicks, button, mask = detail
if clicks = 2:
if clicks == 2:
name = path.join(w.name, string)
try:
w2 = anywin.open(name)

View file

@ -175,20 +175,20 @@ def test():
winsize = w.getwinsize()
while 1:
type, window, detail = stdwinq.getevent()
if type = WE_CLOSE:
if type == WE_CLOSE:
break
elif type = WE_SIZE:
elif type == WE_SIZE:
newsize = w.getwinsize()
if newsize <> winsize:
w.change((0,0), winsize)
winsize = newsize
w.change((0,0), winsize)
elif type = WE_MOUSE_DOWN:
elif type == WE_MOUSE_DOWN:
stage = (stage + 1) % len(stages)
justify, center, title = stages[stage]
w.settitle(title)
w.change((0, 0), (1000, 1000))
elif type = WE_DRAW:
elif type == WE_DRAW:
width, height = winsize
f = formatter().init(w.begindrawing(), 0, 0, width)
f.center = center
@ -198,7 +198,7 @@ def test():
for font in font1, font2, font1:
f.setfont(font)
for word in words:
space = 1 + (word[-1:] = '.')
space = 1 + (word[-1:] == '.')
f.addword(word, space)
if center and space > 1:
f.flush()

View file

@ -49,44 +49,44 @@ def mainloop(): # Handle events until no windows left
def treatevent(e): # Handle a stdwin event
type, w, detail = e
if type = WE_DRAW:
if type == WE_DRAW:
w.draw(w, detail)
elif type = WE_MENU:
elif type == WE_MENU:
m, item = detail
m.action[item](w, m, item)
elif type = WE_COMMAND:
elif type == WE_COMMAND:
treatcommand(w, detail)
elif type = WE_CHAR:
elif type == WE_CHAR:
w.char(w, detail)
elif type = WE_MOUSE_DOWN:
elif type == WE_MOUSE_DOWN:
if detail[1] > 1: w.m2down(w, detail)
else: w.mdown(w, detail)
elif type = WE_MOUSE_MOVE:
elif type == WE_MOUSE_MOVE:
w.mmove(w, detail)
elif type = WE_MOUSE_UP:
elif type == WE_MOUSE_UP:
if detail[1] > 1: w.m2up(w, detail)
else: w.mup(w, detail)
elif type = WE_SIZE:
elif type == WE_SIZE:
w.size(w, w.getwinsize())
elif type = WE_ACTIVATE:
elif type == WE_ACTIVATE:
w.activate(w)
elif type = WE_DEACTIVATE:
elif type == WE_DEACTIVATE:
w.deactivate(w)
elif type = WE_MOVE:
elif type == WE_MOVE:
w.move(w)
elif type = WE_TIMER:
elif type == WE_TIMER:
w.timer(w)
elif type = WE_CLOSE:
elif type == WE_CLOSE:
w.close(w)
def treatcommand(w, type): # Handle a we_command event
if type = WC_CLOSE:
if type == WC_CLOSE:
w.close(w)
elif type = WC_RETURN:
elif type == WC_RETURN:
w.enter(w)
elif type = WC_TAB:
elif type == WC_TAB:
w.tab(w)
elif type = WC_BACKSPACE:
elif type == WC_BACKSPACE:
w.backspace(w)
elif type in (WC_LEFT, WC_UP, WC_RIGHT, WC_DOWN):
w.arrow(w, type)
@ -101,13 +101,13 @@ def close(w): # Close method
break
def arrow(w, detail): # Arrow key method
if detail = WC_LEFT:
if detail == WC_LEFT:
w.kleft(w)
elif detail = WC_UP:
elif detail == WC_UP:
w.kup(w)
elif detail = WC_RIGHT:
elif detail == WC_RIGHT:
w.kright(w)
elif detail = WC_DOWN:
elif detail == WC_DOWN:
w.kdown(w)

View file

@ -164,13 +164,13 @@ def whichcol(w, h): # Return column number (may be >= len(w.data))
return len(w.data)
def arrow(w, type):
if type = WC_LEFT:
if type == WC_LEFT:
incr = -1, 0
elif type = WC_UP:
elif type == WC_UP:
incr = 0, -1
elif type = WC_RIGHT:
elif type == WC_RIGHT:
incr = 1, 0
elif type = WC_DOWN:
elif type == WC_DOWN:
incr = 0, 1
else:
return