Skip to content

Commit

Permalink
created class 'Toolbar'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobsel committed Jan 10, 2025
1 parent 94dc2a1 commit 8b1049f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
15 changes: 4 additions & 11 deletions napytau/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
from napytau.gui.components.graph import Graph
from napytau.gui.components.logger import Logger
from napytau.gui.components.menu_bar import MenuBar
from napytau.gui.components.Toolbar import Toolbar

from napytau.import_export.model.datapoint import Datapoint
from napytau.util.model.value_error_pair import ValueErrorPair

from matplotlib.backends.backend_tkagg import NavigationToolbar2Tk

# Modes: "System" (standard), "Dark", "Light"
customtkinter.set_appearance_mode("System")
Expand Down Expand Up @@ -120,9 +121,7 @@ def __init__(self) -> None:
# Initialize the graph
self.graph = Graph(self)

self.create_toolbar()


self.toolbar = Toolbar(self)

# Initialize the control panel
self.control_panel = ControlPanel(self)
Expand Down Expand Up @@ -212,13 +211,7 @@ def update_data_checkboxes(self, new_datapoints: List[Datapoint]) -> None:
self.checkbox_panel.update_data_checkboxes_fitting()
self.checkbox_panel.update_data_checkboxes_calculation()

def create_toolbar(self) -> None:
toolbar_frame = tk.Frame(self)
toolbar_frame.config(bg="white")
toolbar_frame.grid(row=0, column=0, sticky="new") # Use grid for the frame
toolbar = NavigationToolbar2Tk(self.graph.canvas, toolbar_frame)
#toolbar.config(bg="white")# Pack inside the frame
toolbar.update()


"""
Function for testing purposes only!
Expand Down
16 changes: 16 additions & 0 deletions napytau/gui/components/Toolbar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from tkinter import Canvas
import tkinter as tk
from matplotlib.backends.backend_tkagg import NavigationToolbar2Tk


class Toolbar():
def __init__(self, parent,):
self.parent = parent


toolbar_frame = tk.Frame(parent)
toolbar_frame.config(bg="white")
toolbar_frame.grid(row=0, column=0, sticky="new") # Use grid for the frame
toolbar = NavigationToolbar2Tk(self.parent.graph.canvas, toolbar_frame)
#toolbar.config(bg="white")# Pack inside the frame
toolbar.update()
4 changes: 2 additions & 2 deletions napytau/gui/components/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import TYPE_CHECKING
import numpy as np


from napytau.gui.components.Toolbar import Toolbar
from napytau.gui.model.color import Color
from napytau.gui.model.marker_factory import generate_marker
from napytau.gui.model.marker_factory import generate_error_marker_path
Expand Down Expand Up @@ -46,7 +46,7 @@ def update_plot(self) -> None:
row=0, column=0, rowspan=2, padx=10, pady=10, sticky="nsew"
)
self.graph_frame.grid_propagate(False)
self.parent.create_toolbar()
self.parent.toolbar = Toolbar(self.parent)

def plot(self, appearance: str) -> Canvas:

Expand Down

0 comments on commit 8b1049f

Please sign in to comment.