Skip to content

Commit

Permalink
new buttons to viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Aug 18, 2024
1 parent 66fd06e commit 84d76d5
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion viewer/feminos-viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __init__(self, _root):
self.button_frame = tk.Frame(self.root, bd=2)
self.button_frame.pack(pady=5)

self.prev_button = tk.Button(self.button_frame, text="First Event", command=self.first_event)
self.prev_button.pack(side=tk.LEFT, padx=20, pady=5)

self.prev_button = tk.Button(self.button_frame, text="Previous Event", command=self.prev_event)
self.prev_button.pack(side=tk.LEFT, padx=20, pady=5)

Expand All @@ -80,7 +83,10 @@ def __init__(self, _root):
self.entry_textbox.insert(0, "0")

self.next_button = tk.Button(self.button_frame, text="Next Event", command=self.next_event)
self.next_button.pack(side=tk.RIGHT, padx=20, pady=5)
self.next_button.pack(side=tk.LEFT, padx=20, pady=5)

self.prev_button = tk.Button(self.button_frame, text="Last Event", command=self.last_event)
self.prev_button.pack(side=tk.LEFT, padx=20, pady=5)

# bindings
self.root.bind("<Left>", lambda _: self.prev_event())
Expand Down Expand Up @@ -201,13 +207,19 @@ def plot_graph(self):
messagebox.showerror("Error", f"An error occurred while plotting: {str(e)}")

def prev_event(self):
if not self.event_tree:
return

if self.current_entry > 0:
self.current_entry -= 1
self.entry_textbox.delete(0, tk.END)
self.entry_textbox.insert(0, str(self.current_entry))
self.plot_graph()

def next_event(self):
if not self.event_tree:
return

if self.current_entry == self.event_tree.num_entries - 1:
self.load_file()

Expand All @@ -217,6 +229,25 @@ def next_event(self):
self.entry_textbox.insert(0, str(self.current_entry))
self.plot_graph()

def first_event(self):
if not self.event_tree:
return

self.current_entry = 0
self.entry_textbox.delete(0, tk.END)
self.entry_textbox.insert(0, str(self.current_entry))
self.plot_graph()

def last_event(self):
if not self.event_tree:
return

self.load_file() # Reload the file in case it's been updated
self.current_entry = self.event_tree.num_entries - 1
self.entry_textbox.delete(0, tk.END)
self.entry_textbox.insert(0, str(self.current_entry))
self.plot_graph()


if __name__ == "__main__":
root = tk.Tk()
Expand Down

0 comments on commit 84d76d5

Please sign in to comment.