-
Notifications
You must be signed in to change notification settings - Fork 0
/
notebook_app.py
97 lines (68 loc) · 2.43 KB
/
notebook_app.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from tkinter import *
from tkinter import ttk
from random import *
from math import *
from news_generator import generate_random_news
from equation_gen import quation_gen
def func_sqrt():
user_input = entry.get()
result_label3.config(text=str(sqrt(int(user_input))))
def func_random_gen():
user_input1 = entry2.get()
user_input2 = entry3.get()
num = randint(int(user_input1), int(user_input2))
result_label.config(text=str(num))
def func_random_news_gen():
result_label2.config(text=str(generate_random_news()), wraplength=400, font=("bold", 15))
def equation_gen():
custom_font = ("bold", 20)
result_label4.config(text=quation_gen(), font=custom_font)
# root window
root = Tk()
root.geometry('600x550')
root.title('Your Helper')
# create a notebook
notebook = ttk.Notebook(root)
notebook.pack(pady=10, expand=True)
# create/add frames
frame1 = ttk.Frame(notebook, width=600, height=550)
frame2 = ttk.Frame(notebook, width=600, height=550)
frame3 = ttk.Frame(notebook, width=600, height=550)
frame4 = ttk.Frame(notebook, width=600, height=550)
frame1.pack(fill='both', expand=True)
frame2.pack(fill='both', expand=True)
frame3.pack(fill='both', expand=True)
frame4.pack(fill='both', expand=True)
frame1.pack_propagate(False)
frame2.pack_propagate(False)
frame3.pack_propagate(False)
frame4.pack_propagate(False)
notebook.add(frame1, text='SQRT')
notebook.add(frame2, text='RANDOM')
notebook.add(frame3, text='EQUATION')
notebook.add(frame4, text='NEWS')
style = ttk.Style()
style.configure('TNotebook.Tab', font=('bold', 14))
entry = Entry(frame1, width=50)
entry.pack(pady=10)
entry2 = Entry(frame2, width=20)
entry2.pack(pady=10)
entry3 = Entry(frame2, width=20)
entry3.pack(pady=20)
result_label = Label(frame2, text="")
result_label.pack(pady=30)
result_label2 = Label(frame4, text="")
result_label2.pack(pady=35)
result_label3 = Label(frame1, text="")
result_label3.pack(pady=10)
result_label4 = Label(frame3, text="")
result_label4.pack(pady=10)
Btn1 = Button(frame1, text="Solve", command=func_sqrt, font=("bold", 15))
Btn1.pack()
Btn2 = Button(frame2, text="Find", command=func_random_gen, font=("bold", 15))
Btn2.pack()
Btn3 = Button(frame4, text="Find", command=func_random_news_gen, font=("bold", 15))
Btn3.pack()
Btn4 = Button(frame3, text="Find", command=equation_gen, font=("bold", 15))
Btn4.pack()
root.mainloop()