Skip to content
This repository was archived by the owner on Aug 24, 2024. It is now read-only.

Commit b133b56

Browse files
authored
Update pie_chart_creator.py
1 parent 105b1ab commit b133b56

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

pie_chart_creator.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
# This program can be used, but some features aren't completely ready yet. I'll update this soon to fix all bugs.
32
import matplotlib.pyplot as plt
43
import tkinter as tk
54

@@ -22,6 +21,9 @@ def isfloat(self):
2221

2322

2423
window = tk.Tk()
24+
for _ in range(8):
25+
window.columnconfigure(_, weight=1)
26+
window.rowconfigure(_, weight=1)
2527

2628
pcc_logo = tk.PhotoImage(file="PCC_Logo.png")
2729
pcc_logo_lbl = tk.Label(window, image=pcc_logo)
@@ -32,6 +34,20 @@ def isfloat(self):
3234
explode = []
3335

3436

37+
def instructions():
38+
instructions_file = open("instructions.txt")
39+
instructions = tk.Tk()
40+
def exit_instructions():
41+
instructions.destroy()
42+
instruction_lbl = tk.Label(
43+
master=instructions,
44+
text=instructions_file.read()
45+
)
46+
instruction_lbl.grid(row=1, column=1, sticky="W")
47+
back_to_pcc_btn = tk.Button(master=instructions, text="Back to Pie Chart Creator", command=exit_instructions)
48+
back_to_pcc_btn.grid(row=2, column=1, pady=5)
49+
50+
3551
def append():
3652
def exit_not_appended():
3753
not_appended.destroy()
@@ -55,10 +71,11 @@ def exit_not_appended():
5571
not_appended = tk.Tk()
5672
not_appended_label = tk.Label(
5773
master=not_appended,
58-
text=f"Values not added to register\nbecause {percentage_entry.get()} is not a\nvalid decimal number.\nPress any key to exit this\nwarning menu."
74+
text=f"Values not added to register\nbecause \"{percentage_entry.get()}\" is not a\nvalid decimal number.\nPress any key to exit this\nwarning menu."
5975
)
60-
not_appended_label.bind('<KeyPress>', exit_not_appended)
6176
not_appended_label.pack()
77+
back_btn = tk.Button(master=not_appended, text="Back to Pie Chart Creator", command=exit_not_appended)
78+
back_btn.pack(fill=tk.X)
6279

6380

6481
def show_register():
@@ -179,19 +196,19 @@ def back_to_pcc():
179196
item_entry = tk.Entry()
180197

181198
item_entry_lbl.grid(row=1, column=1, sticky="W")
182-
item_entry.grid(row=1, column=2, columnspan=2, sticky="WE")
199+
item_entry.grid(row=1, column=2, sticky="WE")
183200

184201
percentage_entry_lbl = tk.Label(text="Percentage:")
185202
percentage_entry = tk.Entry()
186203

187204
percentage_entry_lbl.grid(row=2, column=1, sticky="W")
188-
percentage_entry.grid(row=2, column=2, columnspan=2, sticky="WE")
205+
percentage_entry.grid(row=2, column=2, sticky="WE")
189206

190207
explode_entry_lbl = tk.Label(text="Enable emphasis(Y/N):")
191208
explode_entry = tk.Entry()
192209

193210
explode_entry_lbl.grid(row=3, column=1, sticky="W")
194-
explode_entry.grid(row=3, column=2, columnspan=2, sticky="WE")
211+
explode_entry.grid(row=3, column=2, sticky="WE")
195212

196213
append_btn = tk.Button(
197214
text="Add values to register",
@@ -213,11 +230,16 @@ def back_to_pcc():
213230
text="View register",
214231
command=show_register
215232
)
233+
instructions_btn = tk.Button(
234+
text="Read Instructions",
235+
command=instructions
236+
)
216237

217238
append_btn.grid(row=4, column=1, sticky="WE", padx=1, pady=1)
218-
show_register_btn.grid(row=4, column=2, columnspan=2, sticky="WE", padx=1, pady=1)
239+
show_register_btn.grid(row=4, column=2, sticky="WE", padx=1, pady=1)
219240
clear_btn.grid(row=5, column=1, sticky="WE", padx=1, pady=1)
220-
exit_btn.grid(row=5, column=2, columnspan=2, sticky="WE", padx=1, pady=1)
221-
make_chart_btn.grid(row=6, column=1, columnspan=3, sticky="WE", padx=1, pady=1)
241+
exit_btn.grid(row=5, column=2, sticky="WE", padx=1, pady=1)
242+
make_chart_btn.grid(row=7, column=1, columnspan=2, sticky="WE", padx=1, pady=1)
243+
instructions_btn.grid(row=6, column=1, columnspan=2, sticky="WE", padx=1, pady=1)
222244

223245
window.mainloop()

0 commit comments

Comments
 (0)