forked from slightlynybbled/tk_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
49 lines (34 loc) · 987 Bytes
/
graph.py
File metadata and controls
49 lines (34 loc) · 987 Bytes
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
import tkinter as tk
import tk_tools
root = tk.Tk()
# create the graph
graph = tk_tools.Graph(
parent=root,
x_min=-1.0,
x_max=1.0,
y_min=0.0,
y_max=2.0,
x_scale=0.5,
y_scale=0.5,
width=500,
height=400
)
graph.grid(row=0, column=0)
# create an initial line
line_0 = [(x/10, x/10) for x in range(10)]
graph.plot_line(line_0)
def add_series():
line_1 = [(x/5 - 1.0, x/10.0) for x in range(10)]
graph.plot_line(line_1, point_visibility=True, color='blue')
def add_point():
point = (0.5, 0.75)
graph.plot_point(*point, color='red')
def clear():
graph.draw_axes()
add_series_btn = tk.Button(root, text='add series', command=add_series)
add_series_btn.grid(row=1, column=0, sticky='EW')
add_point_btn = tk.Button(root, text='add point', command=add_point)
add_point_btn.grid(row=2, column=0, sticky='EW')
clear_btn = tk.Button(root, text='clear', command=clear)
clear_btn.grid(row=3, column=0, sticky='EW')
root.mainloop()