# For historical reasons, button creation methods are called
# define() while split creation methods are called create().
-class AbstractParent():
+class AbstractParent:
#
# Upcalls from child to parent
#
def scroll(self, (area, (dh, dv))): unimpl()
def settimer(self, itimer): unimpl()
-class AbstractChild():
+class AbstractChild:
#
# Downcalls from parent to child
#
# Certain upcalls and downcalls can be handled transparently, but
# for others (e.g., all geometry related calls) this is not possible.
-class AbstractSplit() = AbstractChild(), AbstractParent():
+class AbstractSplit(AbstractChild, AbstractParent):
pass
from TransParent import TransParent
-class BoxParent() = TransParent():
+class BoxParent(TransParent):
#
def create(self, (parent, (dh, dv))):
self = TransParent.create(self, parent)
# disabled --> crossed out
# hilited --> inverted
#
-class LabelAppearance():
+class LabelAppearance:
#
# Initialization
#
# A Strut is a label with no width of its own.
-class StrutAppearance() = LabelAppearance():
+class StrutAppearance(LabelAppearance):
#
def getminsize(self, (m, (width, height))):
height = max(height, m.lineheight() + 6)
# disabled --> crossed out
# hilited --> inverted
#
-class ButtonAppearance() = LabelAppearance():
+class ButtonAppearance(LabelAppearance):
#
def drawpict(self, d):
d.box(_rect.inset(self.bounds, (1, 1)))
# disabled --> whole button crossed out
# hilited --> box is inverted
#
-class CheckAppearance() = LabelAppearance():
+class CheckAppearance(LabelAppearance):
#
def getminsize(self, (m, (width, height))):
minwidth = m.textwidth(self.text) + 6
# disabled --> whole button crossed out
# hilited --> indicator is inverted
#
-class RadioAppearance() = CheckAppearance():
+class RadioAppearance(CheckAppearance):
#
def drawpict(self, d):
(left, top), (right, bottom) = self.boxbounds
# NoReactivity ignores mouse events.
#
-class NoReactivity():
+class NoReactivity:
def init_reactivity(self): pass
# There are usually extra conditions, e.g., hooks are only called
# when the button is enabled, or active, or selected (on).
#
-class BaseReactivity():
+class BaseReactivity:
#
def init_reactivity(self):
self.down_hook = self.move_hook = self.up_hook = \
# ToggleReactivity acts like a simple pushbutton.
# It toggles its hilite state on mouse down events.
#
-class ToggleReactivity() = BaseReactivity():
+class ToggleReactivity(BaseReactivity):
#
def mouse_down(self, detail):
if self.enabled and self.mousetest(detail[_HV]):
# TriggerReactivity acts like a fancy pushbutton.
# It hilites itself while the mouse is down within its bounds.
#
-class TriggerReactivity() = BaseReactivity():
+class TriggerReactivity(BaseReactivity):
#
def mouse_down(self, detail):
if self.enabled and self.mousetest(detail[_HV]):
# CheckReactivity handles mouse events like TriggerReactivity,
# It overrides the up_trigger method to flip its selected state.
#
-class CheckReactivity() = TriggerReactivity():
+class CheckReactivity(TriggerReactivity):
#
def up_trigger(self):
self.select(not self.selected)
# RadioReactivity turns itself on and the other buttons in its group
# off when its up_trigger method is called.
#
-class RadioReactivity() = TriggerReactivity():
+class RadioReactivity(TriggerReactivity):
#
def init_reactivity(self):
TriggerReactivity.init_reactivity(self)
# Auxiliary class for 'define' method.
# Call the initializers in the right order.
#
-class Define():
+class Define:
#
def define(self, parent):
self.parent = parent
# Ready-made button classes.
#
-class Label() = NoReactivity(), LabelAppearance(), Define(): pass
-class Strut() = NoReactivity(), StrutAppearance(), Define(): pass
-class PushButton() = TriggerReactivity(), ButtonAppearance(), Define(): pass
-class CheckButton() = CheckReactivity(), CheckAppearance(), Define(): pass
-class RadioButton() = RadioReactivity(), RadioAppearance(), Define(): pass
-class ToggleButton() = ToggleReactivity(), ButtonAppearance(), Define(): pass
+class Label(NoReactivity, LabelAppearance, Define): pass
+class Strut(NoReactivity, StrutAppearance, Define): pass
+class PushButton(TriggerReactivity, ButtonAppearance, Define): pass
+class CheckButton(CheckReactivity, CheckAppearance, Define): pass
+class RadioButton(RadioReactivity, RadioAppearance, Define): pass
+class ToggleButton(ToggleReactivity, ButtonAppearance, Define): pass
from math import pi, sin, cos
from Split import Split
-class CSplit() = Split():
+class CSplit(Split):
#
def getminsize(self, (m, (width, height))):
# Since things look best if the children are spaced evenly
from Split import Split
-class FormSplit() = Split():
+class FormSplit(Split):
#
def create(self, parent):
self.next_left = self.next_top = 0
from Split import Split
-class HVSplit() = Split():
+class HVSplit(Split):
#
def create(self, (parent, hv)):
# hv is 0 for HSplit, 1 for VSplit
# XXX too-small
#
-class HSplit() = HVSplit():
+class HSplit(HVSplit):
def create(self, parent):
return HVSplit.create(self, (parent, 0))
-class VSplit() = HVSplit():
+class VSplit(HVSplit):
def create(self, parent):
return HVSplit.create(self, (parent, 1))
# A Histogram displays a histogram of numeric data.
#
-class HistogramAppearance() = LabelAppearance(), Define():
+class HistogramAppearance(LabelAppearance, Define):
#
def define(self, parent):
Define.define(self, (parent, ''))
d.paint((h0, v0), (h1, v1))
#
-class Histogram() = NoReactivity(), HistogramAppearance(): pass
+class Histogram(NoReactivity, HistogramAppearance): pass
# It does not support any of the triggers or hooks defined by Buttons,
# but defines its own setval_trigger and setval_hook.
#
-class DragSliderReactivity() = BaseReactivity():
+class DragSliderReactivity(BaseReactivity):
#
def mouse_down(self, detail):
h, v = hv = detail[_HV]
self.active = 0
#
-class DragSliderAppearance() = ButtonAppearance():
+class DragSliderAppearance(ButtonAppearance):
#
# INVARIANTS maintained by the setval method:
#
self.settext(self.pretext + `self.val` + self.postext)
#
-class DragSlider() = DragSliderReactivity(), DragSliderAppearance(), Define():
+class DragSlider(DragSliderReactivity, DragSliderAppearance, Define):
def definetext(self, (parent, text)):
raise RuntimeError, 'DragSlider.definetext() not supported'
# Auxiliary class for PushButton incorporated in ComplexSlider
#
-class _StepButton() = PushButton():
+class _StepButton(PushButton):
def define(self, parent):
self = PushButton.define(self, parent)
self.step = 0
# A complex slider is an HSplit initialized to three buttons:
# one to step down, a dragslider, and one to step up.
#
-class ComplexSlider() = HSplit():
+class ComplexSlider(HSplit):
#
# Override Slider define() method
#
import audio
from Histogram import Histogram
-class Soundogram() = Histogram():
+class Soundogram(Histogram):
#
def define(self, (win, chunk)):
width, height = corner = win.getwinsize()
import rect
from stdwinevents import *
-class Split():
+class Split:
#
# Calls from creator
# NB derived classes may add parameters to create()
# A StripChart doesn't really look like a label but it needs a base class.
# LabelAppearance allows it to be disabled and hilited.
-class StripChart() = LabelAppearance(), NoReactivity():
+class StripChart(LabelAppearance, NoReactivity):
#
def define(self, (parent, scale)):
self.parent = parent
K = 1024
Rates = [0, 32*K, 16*K, 8*K]
-class VUMeter() = StripChart():
+class VUMeter(StripChart):
#
# Override define() and timer() methods
#
Error = 'WindowParent.Error' # Exception
-class WindowParent() = ManageOneChild():
+class WindowParent(ManageOneChild):
#
def create(self, (title, size)):
self.title = title
# Of course, no multi-threading is implied -- hence the funny interface
# for lock, where a function is called once the lock is aquired.
#
-class mutex():
+class mutex:
#
# Create a new mutex -- initially unlocked
#
# XXX instead of having to define a module or class just to hold
# XXX the global state of your particular time and delay functtions.
-class scheduler():
+class scheduler:
#
# Initialize a new instance, passing the time and delay functions
#
# For historical reasons, button creation methods are called
# define() while split creation methods are called create().
-class AbstractParent():
+class AbstractParent:
#
# Upcalls from child to parent
#
def scroll(self, (area, (dh, dv))): unimpl()
def settimer(self, itimer): unimpl()
-class AbstractChild():
+class AbstractChild:
#
# Downcalls from parent to child
#
# Certain upcalls and downcalls can be handled transparently, but
# for others (e.g., all geometry related calls) this is not possible.
-class AbstractSplit() = AbstractChild(), AbstractParent():
+class AbstractSplit(AbstractChild, AbstractParent):
pass
from TransParent import TransParent
-class BoxParent() = TransParent():
+class BoxParent(TransParent):
#
def create(self, (parent, (dh, dv))):
self = TransParent.create(self, parent)
# disabled --> crossed out
# hilited --> inverted
#
-class LabelAppearance():
+class LabelAppearance:
#
# Initialization
#
# A Strut is a label with no width of its own.
-class StrutAppearance() = LabelAppearance():
+class StrutAppearance(LabelAppearance):
#
def getminsize(self, (m, (width, height))):
height = max(height, m.lineheight() + 6)
# disabled --> crossed out
# hilited --> inverted
#
-class ButtonAppearance() = LabelAppearance():
+class ButtonAppearance(LabelAppearance):
#
def drawpict(self, d):
d.box(_rect.inset(self.bounds, (1, 1)))
# disabled --> whole button crossed out
# hilited --> box is inverted
#
-class CheckAppearance() = LabelAppearance():
+class CheckAppearance(LabelAppearance):
#
def getminsize(self, (m, (width, height))):
minwidth = m.textwidth(self.text) + 6
# disabled --> whole button crossed out
# hilited --> indicator is inverted
#
-class RadioAppearance() = CheckAppearance():
+class RadioAppearance(CheckAppearance):
#
def drawpict(self, d):
(left, top), (right, bottom) = self.boxbounds
# NoReactivity ignores mouse events.
#
-class NoReactivity():
+class NoReactivity:
def init_reactivity(self): pass
# There are usually extra conditions, e.g., hooks are only called
# when the button is enabled, or active, or selected (on).
#
-class BaseReactivity():
+class BaseReactivity:
#
def init_reactivity(self):
self.down_hook = self.move_hook = self.up_hook = \
# ToggleReactivity acts like a simple pushbutton.
# It toggles its hilite state on mouse down events.
#
-class ToggleReactivity() = BaseReactivity():
+class ToggleReactivity(BaseReactivity):
#
def mouse_down(self, detail):
if self.enabled and self.mousetest(detail[_HV]):
# TriggerReactivity acts like a fancy pushbutton.
# It hilites itself while the mouse is down within its bounds.
#
-class TriggerReactivity() = BaseReactivity():
+class TriggerReactivity(BaseReactivity):
#
def mouse_down(self, detail):
if self.enabled and self.mousetest(detail[_HV]):
# CheckReactivity handles mouse events like TriggerReactivity,
# It overrides the up_trigger method to flip its selected state.
#
-class CheckReactivity() = TriggerReactivity():
+class CheckReactivity(TriggerReactivity):
#
def up_trigger(self):
self.select(not self.selected)
# RadioReactivity turns itself on and the other buttons in its group
# off when its up_trigger method is called.
#
-class RadioReactivity() = TriggerReactivity():
+class RadioReactivity(TriggerReactivity):
#
def init_reactivity(self):
TriggerReactivity.init_reactivity(self)
# Auxiliary class for 'define' method.
# Call the initializers in the right order.
#
-class Define():
+class Define:
#
def define(self, parent):
self.parent = parent
# Ready-made button classes.
#
-class Label() = NoReactivity(), LabelAppearance(), Define(): pass
-class Strut() = NoReactivity(), StrutAppearance(), Define(): pass
-class PushButton() = TriggerReactivity(), ButtonAppearance(), Define(): pass
-class CheckButton() = CheckReactivity(), CheckAppearance(), Define(): pass
-class RadioButton() = RadioReactivity(), RadioAppearance(), Define(): pass
-class ToggleButton() = ToggleReactivity(), ButtonAppearance(), Define(): pass
+class Label(NoReactivity, LabelAppearance, Define): pass
+class Strut(NoReactivity, StrutAppearance, Define): pass
+class PushButton(TriggerReactivity, ButtonAppearance, Define): pass
+class CheckButton(CheckReactivity, CheckAppearance, Define): pass
+class RadioButton(RadioReactivity, RadioAppearance, Define): pass
+class ToggleButton(ToggleReactivity, ButtonAppearance, Define): pass
from math import pi, sin, cos
from Split import Split
-class CSplit() = Split():
+class CSplit(Split):
#
def getminsize(self, (m, (width, height))):
# Since things look best if the children are spaced evenly
from Split import Split
-class FormSplit() = Split():
+class FormSplit(Split):
#
def create(self, parent):
self.next_left = self.next_top = 0
from Split import Split
-class HVSplit() = Split():
+class HVSplit(Split):
#
def create(self, (parent, hv)):
# hv is 0 for HSplit, 1 for VSplit
# XXX too-small
#
-class HSplit() = HVSplit():
+class HSplit(HVSplit):
def create(self, parent):
return HVSplit.create(self, (parent, 0))
-class VSplit() = HVSplit():
+class VSplit(HVSplit):
def create(self, parent):
return HVSplit.create(self, (parent, 1))
# A Histogram displays a histogram of numeric data.
#
-class HistogramAppearance() = LabelAppearance(), Define():
+class HistogramAppearance(LabelAppearance, Define):
#
def define(self, parent):
Define.define(self, (parent, ''))
d.paint((h0, v0), (h1, v1))
#
-class Histogram() = NoReactivity(), HistogramAppearance(): pass
+class Histogram(NoReactivity, HistogramAppearance): pass
# It does not support any of the triggers or hooks defined by Buttons,
# but defines its own setval_trigger and setval_hook.
#
-class DragSliderReactivity() = BaseReactivity():
+class DragSliderReactivity(BaseReactivity):
#
def mouse_down(self, detail):
h, v = hv = detail[_HV]
self.active = 0
#
-class DragSliderAppearance() = ButtonAppearance():
+class DragSliderAppearance(ButtonAppearance):
#
# INVARIANTS maintained by the setval method:
#
self.settext(self.pretext + `self.val` + self.postext)
#
-class DragSlider() = DragSliderReactivity(), DragSliderAppearance(), Define():
+class DragSlider(DragSliderReactivity, DragSliderAppearance, Define):
def definetext(self, (parent, text)):
raise RuntimeError, 'DragSlider.definetext() not supported'
# Auxiliary class for PushButton incorporated in ComplexSlider
#
-class _StepButton() = PushButton():
+class _StepButton(PushButton):
def define(self, parent):
self = PushButton.define(self, parent)
self.step = 0
# A complex slider is an HSplit initialized to three buttons:
# one to step down, a dragslider, and one to step up.
#
-class ComplexSlider() = HSplit():
+class ComplexSlider(HSplit):
#
# Override Slider define() method
#
import audio
from Histogram import Histogram
-class Soundogram() = Histogram():
+class Soundogram(Histogram):
#
def define(self, (win, chunk)):
width, height = corner = win.getwinsize()
import rect
from stdwinevents import *
-class Split():
+class Split:
#
# Calls from creator
# NB derived classes may add parameters to create()
# A StripChart doesn't really look like a label but it needs a base class.
# LabelAppearance allows it to be disabled and hilited.
-class StripChart() = LabelAppearance(), NoReactivity():
+class StripChart(LabelAppearance, NoReactivity):
#
def define(self, (parent, scale)):
self.parent = parent
K = 1024
Rates = [0, 32*K, 16*K, 8*K]
-class VUMeter() = StripChart():
+class VUMeter(StripChart):
#
# Override define() and timer() methods
#
Error = 'WindowParent.Error' # Exception
-class WindowParent() = ManageOneChild():
+class WindowParent(ManageOneChild):
#
def create(self, (title, size)):
self.title = title
# Kludge to hold mutable state
-class Struct(): pass
+class Struct: pass
G = Struct()
G.i = 0