1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| from graphplotlib import *
class DrawGraph():
def __init__(self, dg, g):
self.dg = dg
self.g = g
def plot(self, *args):
self.dg.plot (self.g, *args)
class DynaGraph():
def __init__(self):
self.boss=Tk()
self.boss.overrideredirect(1)
self.boss.withdraw()
def NewGraph(self, **kwargs):
w=Toplevel()
graph=Graph(w, **kwargs)
graph.pack()
return DrawGraph(self, graph)
def plot(self, graph, *args):
graph.delete_all()
graph.plot(*args)
graph.update()
if __name__ == '__main__':
import math
import time
v_x=[0]
v_y=[0]
v_y_2=[0]
toto=DynaGraph()
a=toto.NewGraph(grid=True, width=600, height=300)
b=toto.NewGraph(grid=True, width=600, height=300)
i=10000
while 1:
v_x.append(i)
v_y_2.append(math.sin(float(i)))
v_y.append(math.cos(float(i)))
a.plot([v_x,v_y_2,{'fill':'blue','line':True,'point':True}])
b.plot([v_x,v_y,{'fill':'green','line':True,'point':True,'point_color':'green'}])
i=i+1000
time.sleep(1) |