-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI_launch.py
37 lines (31 loc) · 979 Bytes
/
GUI_launch.py
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
'''Code needs a lot of work - it's just made to work.'''
import Tkinter as tk
import csv
from finanse_wp import *
nameAr = []
codeAr = []
with open('indicators.csv', 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=';')
for row in reader:
nameAr.append(row[0])
codeAr.append(row[1])
def select():
# draw a chart
index = nameAr.index(name_var.get())
stock_id = codeAr[index]
try:
graphData(stock_id, 20, 200)
except Exception as e:
print 'Something went wrong.\nError details: ', e
root = tk.Tk()
# use width x height + x_offset + y_offset (no spaces!)
root.geometry("%dx%d+%d+%d" % (400, 60, 200, 150))
root.title("Simple Stock Chart Drawing Tool")
name_var = tk.StringVar(root)
name_var.set('Pick a stock')
choices = nameAr
option = tk.OptionMenu(root, name_var, *choices)
option.pack(side='left', padx=10, pady=10)
button = tk.Button(root, text="Draw a chart!", command=select)
button.pack(side='right', padx=20, pady=10)
root.mainloop()