distribution.py 1.46 KB
Newer Older
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
import matplotlib, sys
matplotlib.use('TkAgg')
from numpy import arange, sin, pi
from matplotlib.figure import Figure
from Tkinter import *
from pylab import *

def plot_dist(ELEM, window):

    points = []

    spline = 0

    tag1 = "theline"

    def point(event):
        c.create_oval(event.x, event.y, event.x+1, event.y+1, fill="black")
        points.append(event.x)
        points.append(event.y)
        return points

    def canxy(event):
        print event.x, event.y

    def graph(event):
        global theline
        c.create_line(points, tags="theline")
	

    def toggle(event):
        global spline
        if spline == 0:
            c.itemconfigure(tag1, smooth=1)
            spline = 1
        elif spline == 1:
            c.itemconfigure(tag1, smooth=0)
            spline = 0
        return spline


    c = Canvas(window, bg="white", width=600, height= 400)

    c.configure(cursor="crosshair")

    c.pack()

    c.bind("<Button-1>", point)

    c.bind("<Button-3>", graph)

    c.bind("<Button-2>", toggle)







'''    f = Figure(figsize=(5,4), dpi=100)
    a = f.add_subplot(111)
    t = arange(0.0,20.0,0.01)
    s = ELEM['dist']
    a.plot(t,s)

    dataPlot = FigureCanvasTkAgg(f, master=window)
    dataPlot.show()
    dataPlot.get_tk_widget().pack(side='left', fill=BOTH, expand=1)'''
#-------------------------------------------------------------------------------