Skip to content

Commit

Permalink
Update camera_tab.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AdvancedImagingUTSW committed Dec 22, 2024
1 parent c951513 commit 1b080bf
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions src/navigate/view/main_window_content/camera_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# Third Party Imports

# Local Imports
import navigate
from navigate.view.custom_widgets.LabelInputWidgetFactory import LabelInput
from navigate.view.custom_widgets.validation import ValidatedSpinbox, ValidatedEntry

Expand All @@ -46,15 +47,20 @@
logger = logging.getLogger(p)


class CameraSettingsTab(tk.Frame):
class CameraSettingsTab(ttk.Frame):
"""
This class holds and controls the layout of the major label frames for the
camera settings tab in the settings notebook. Any imported classes are children
that makeup the content of the major frames. If you need to adjust anything in
the frames follow the children.
"""

def __init__(self, setntbk, *args, **kwargs):
def __init__(
self,
setntbk: "navigate.view.main_window_content.settings_notebook",
*args: tuple,
**kwargs: dict
) -> None:
"""Initialize the Camera Settings Tab
Parameters
Expand All @@ -67,15 +73,14 @@ def __init__(self, setntbk, *args, **kwargs):
Keyword arguments for ttk.Frame
"""
# Init Frame
tk.Frame.__init__(self, setntbk, *args, **kwargs)
ttk.Frame.__init__(self, setntbk, *args, **kwargs)

#: The index of the tab in the notebook
self.index = 1

# Formatting
tk.Grid.columnconfigure(self, "all", weight=1)
tk.Grid.rowconfigure(self, "all", weight=1)

# Camera Modes Frame
#: tk.Frame: The camera mode frame
self.camera_mode = CameraMode(self)
self.camera_mode.grid(row=0, column=0, sticky=tk.NSEW, padx=10, pady=10)
Expand Down Expand Up @@ -105,12 +110,17 @@ class CameraMode(ttk.Labelframe):
the widget directly or with the dictionary generated by get_variables.
"""

def __init__(self, settings_tab, *args, **kwargs):
def __init__(
self,
settings_tab: "CameraSettingsTab",
*args,
**kwargs
) -> None:
"""Initialize the Camera Mode Frame
Parameters
----------
settings_tab : ttk.Frame
settings_tab : CameraSettingsTab
The settings tab that the frame will be placed in.
*args : tuple
Positional arguments for ttk.LabelFrame
Expand Down Expand Up @@ -157,7 +167,7 @@ def __init__(self, settings_tab, *args, **kwargs):
self.inputs[self.names[i]].grid(
row=i, column=1, pady=3, padx=5, sticky=tk.W)

def get_variables(self):
def get_variables(self) -> dict:
"""Get Variables.
This function returns a dictionary of all the variables that are tied to each
Expand All @@ -175,7 +185,7 @@ def get_variables(self):
variables[key] = widget.get()
return variables

def get_widgets(self):
def get_widgets(self) -> dict:
"""Get Widgets.
This function returns the dictionary that holds the widgets.
Expand All @@ -201,12 +211,17 @@ class FramerateInfo(ttk.LabelFrame):
the dictionary generated by get_variables.
"""

def __init__(self, settings_tab, *args, **kwargs):
def __init__(
self,
settings_tab: CameraSettingsTab,
*args: tuple,
**kwargs: dict
) -> None:
"""Initialize the Framerate Info Frame
Parameters
----------
settings_tab : ttk.Frame
settings_tab : CameraSettingsTab
The settings tab that the frame will be placed in.
*args : tuple
Positional arguments for ttk.LabelFrame
Expand Down Expand Up @@ -267,7 +282,7 @@ def __init__(self, settings_tab, *args, **kwargs):
self.inputs[self.names[i]].grid(row=i, column=1, pady=1, padx=5, sticky=tk.W)


def get_variables(self):
def get_variables(self) -> dict:
"""Get Variables
This function returns a dictionary of all variables tied to each widget.
Expand All @@ -285,7 +300,7 @@ def get_variables(self):
variables[key] = widget.get()
return variables

def get_widgets(self):
def get_widgets(self) -> dict:
"""Get Widgets
This function returns the dictionary that holds the widgets.
Expand All @@ -311,12 +326,16 @@ class ROI(ttk.Labelframe):
get_variables.
"""

def __init__(self, settings_tab, *args, **kwargs):
def __init__(
self,
settings_tab: CameraSettingsTab,
*args: tuple,
**kwargs: dict) -> None:
"""Initialize the ROI Frame
Parameters
----------
settings_tab : ttk.Frame
settings_tab : CameraSettingsTab
The settings tab that the frame will be placed in.
*args : tuple
Positional arguments for ttk.LabelFrame
Expand Down Expand Up @@ -363,9 +382,9 @@ def __init__(self, settings_tab, *args, **kwargs):
tk.Grid.columnconfigure(self.roi_boundary_frame, "all", weight=1)
tk.Grid.rowconfigure(self.roi_boundary_frame, "all", weight=1)

# Dictionary for all the variables, this will be used by the controller
#: dict: Dictionary of all the widgets in the frame.
self.inputs = {}

#: dict: Dictionary of all the buttons in the frame.
self.buttons = {}

Expand All @@ -377,6 +396,7 @@ def __init__(self, settings_tab, *args, **kwargs):

roi_boundary_names = ["Top_X", "Top_Y", "Bottom_X", "Bottom_Y"]
roi_boundary_labels = ["X", "Y", "X", "Y"]

#: str: The binning label.
self.binning = "Binning"

Expand Down Expand Up @@ -451,18 +471,18 @@ def __init__(self, settings_tab, *args, **kwargs):
)
self.inputs[self.binning].grid(row=3, column=0, pady=5, padx=5)

# Additional formatting
# Number of Pixels
self.inputs["Width"].grid(pady=(10, 5))
self.inputs["Width"].label.grid(padx=(0, 13))
self.inputs["Height"].label.grid(padx=(0, 10))
self.inputs["Binning"].label.grid(padx=(0, 6))

# FOV
self.inputs["FOV_X"].grid(pady=(10, 5))
self.inputs["FOV_X"].label.grid(padx=(0, 10))
self.inputs["FOV_Y"].label.grid(padx=(0, 10))

def get_variables(self):
def get_variables(self) -> dict:
"""Get Variables.
This function returns a dictionary of all the variables that are tied to each
Expand All @@ -480,7 +500,7 @@ def get_variables(self):
variables[key] = widget.get()
return variables

def get_widgets(self):
def get_widgets(self) -> dict:
"""Get Widgets.
This function returns the dictionary that holds the widgets.
Expand All @@ -493,7 +513,7 @@ def get_widgets(self):
"""
return self.inputs

def get_buttons(self):
def get_buttons(self) -> dict:
"""Get Buttons.
This function returns the dictionary that holds the buttons.
Expand Down

0 comments on commit 1b080bf

Please sign in to comment.