-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtk.py
69 lines (56 loc) · 1.91 KB
/
tk.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
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
import tkinter as tk
import webbrowser as wb
class Ticker(tk.Frame):
links = {
"zacks": "https://www.zacks.com/stock/quote/{0}",
"finviz": "https://finviz.com/quote.ashx?t={0}",
"openinsider": "http://openinsider.com/search?q={0}",
"earningswhispers": "https://earningswhispers.com/stocks/{0}",
"shortsqueeze": "http://shortsqueeze.com/?symbol={0}"
}
def __init__(self, master=None):
super().__init__(master)
self.pack()
self.create_widgets()
def create_widgets(self):
self.create_buttons()
self.build_label()
self.create_text_box()
def create_buttons(self):
pass
# self.hi_there = tk.Button(self)
# self.hi_there["text"] = "Click here to open new tabs"
# self.hi_there["command"] = self.openall
# self.hi_there.pack(side="top")
# self.quit = tk.Button(self, text="QUIT", fg="red",
# command=root.destroy)
# self.quit.pack(side="bottom")
def build_label(self):
self.box_label = tk.Label(
self,
font=("Lucida Console", 20),
text="Enter stock symbol\r\nHit Enter to search."
)
self.box_label.pack(side="top")
def create_text_box(self):
self.text_box = tk.Entry(
self,
font=("Lucida Console", 24),
width=8,
justify="center",
)
self.text_box.pack(side="bottom")
self.text_box.bind('<Return>', self.run_search)
self.text_box.delete(0, 'end')
self.text_box.focus()
def run_search(self, event=None):
symbol = self.text_box.get()
self.text_box.delete(0, 'end')
self.text_box.focus()
for link in self.links.values():
wb.open(link.format(symbol))
root = tk.Tk()
root.title('Ticker')
root.geometry("500x500")
app = Ticker(master=root)
app.mainloop()