summaryrefslogtreecommitdiffstats
path: root/Lib/lib-stdwin/Histogram.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1990-11-05 19:44:31 (GMT)
committerGuido van Rossum <guido@python.org>1990-11-05 19:44:31 (GMT)
commit0c89ec778d684a13a656b6b3462ae7dfd2837148 (patch)
treed56db45e4a0e9d476256a9582a051cf3fa520ed9 /Lib/lib-stdwin/Histogram.py
parentc8564cde0405fd10067f40068ce6735b1bfcc7d5 (diff)
downloadcpython-0c89ec778d684a13a656b6b3462ae7dfd2837148.zip
cpython-0c89ec778d684a13a656b6b3462ae7dfd2837148.tar.gz
cpython-0c89ec778d684a13a656b6b3462ae7dfd2837148.tar.bz2
*** empty log message ***
Diffstat (limited to 'Lib/lib-stdwin/Histogram.py')
-rw-r--r--Lib/lib-stdwin/Histogram.py37
1 files changed, 16 insertions, 21 deletions
diff --git a/Lib/lib-stdwin/Histogram.py b/Lib/lib-stdwin/Histogram.py
index f469272..505bbaf 100644
--- a/Lib/lib-stdwin/Histogram.py
+++ b/Lib/lib-stdwin/Histogram.py
@@ -1,41 +1,36 @@
# Module 'Histogram'
from Buttons import *
-from Resize import Resize
-
# A Histogram displays a histogram of numeric data.
-# It reacts to resize events by resizing itself,
-# leaving the same amount of space around the borders.
-# (This is geometry management, and should really be implemented
-# by a different group of classes, but for now this hack is OK.)
#
-class HistogramAppearance() = Resize(), LabelAppearance():
+class HistogramAppearance() = LabelAppearance(), Define():
#
- def define(self, (win, bounds, ydata, scale)):
- self.init_appearance(win, bounds)
- self.init_resize()
- self.ydata = ydata
- self.scale = scale # (min, max)
+ def define(self, parent):
+ Define.define(self, (parent, ''))
+ self.ydata = []
+ self.scale = (0, 100)
return self
#
def setdata(self, (ydata, scale)):
self.ydata = ydata
self.scale = scale # (min, max)
- self.win.change(self.bounds)
+ self.parent.change(self.bounds)
#
- def drawit(self, d):
- ydata = self.ydata
+ def drawpict(self, d):
(left, top), (right, bottom) = self.bounds
min, max = self.scale
size = max-min
width, height = right-left, bottom-top
- for i in range(len(ydata)):
- h0 = left + i * width/len(ydata)
- h1 = left + (i+1) * width/len(ydata)
- v0 = top + height - (self.ydata[i]-min)*height/size
- v1 = top + height
+ ydata = self.ydata
+ npoints = len(ydata)
+ v1 = top + height # constant
+ h1 = left # changed in loop
+ for i in range(npoints):
+ h0 = h1
+ v0 = top + height - (ydata[i]-min)*height/size
+ h1 = left + (i+1) * width/npoints
d.paint((h0, v0), (h1, v1))
#
-class Histogram() = HistogramAppearance(), NoReactivity(): pass
+class Histogram() = NoReactivity(), HistogramAppearance(): pass