Skip to content

Commit

Permalink
Modified to display error messages in the GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
nishimura5 committed Nov 14, 2024
1 parent 74cd90c commit 405f386
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app_previewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ def __init__(self, master):
)
export_svg_button.pack(padx=5, side=tk.LEFT)

# error message frame
msg_frame = ttk.Frame(send_timer_frame)
msg_frame.pack(padx=10,fill=tk.X, side=tk.LEFT)
self.msg_label = ttk.Label(msg_frame, text="")
self.msg_label.pack()

# body frame
body_frame = ttk.Frame(master)
body_frame.pack(fill=tk.BOTH, expand=True)
Expand Down Expand Up @@ -385,6 +391,7 @@ def create_file(self):
self.load_file()

def select_file(self):
self.msg_label.config(text="")
csv_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
if not csv_path:
return
Expand All @@ -395,7 +402,11 @@ def load_file(self):
self.file_path_label.config(text=self.csv_path)
timetable_csv_str = self.read_file(self.csv_path)
timetable = csv_to_timetable.TimeTable()
timetable.load_csv_str(timetable_csv_str)
try:
timetable.load_csv_str(timetable_csv_str)
except Exception as e:
self.msg_label.config(text=f"ERROR: {e}")
return

self.stage_list = []
for row in timetable.get_timetable():
Expand All @@ -417,6 +428,8 @@ def load_file(self):
self.tree.set_stages(self.stage_list)
self.draw_stages()

self.msg_label.config(text="Successfully loaded.")

def read_file(self, tar_path):
try:
with open(tar_path, "r", encoding="utf-8") as f:
Expand Down

0 comments on commit 405f386

Please sign in to comment.