Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frames frames frames #53

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions app/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from enums.ModuleEnum import ModuleEnum
from modules.ModuleFactory import ModuleFactory

from controls.base.Frame import Frame
from controls.MainLabel import MainLabel
from controls.ModuleDropdown import ModuleDropdown

Expand All @@ -16,17 +17,23 @@ def __init__(self):

# Window
self.title("CTPlot")
self.w_width = 960
self.w_width = 1080
self.w_height = 720
self.create_window()

# Define main app columns
self.column_0_frame = Frame(self, row=0, col=0)
self.column_1_frame = Frame(self, row=0, col=1)
self.column_2_frame = Frame(self, row=0, col=2)

# Modules
self.current_module: BaseModule = DisplacementModule(self)
self.default_module = self.current_module.get_name()

# Controls
MainLabel(self)
self.dropdown = ModuleDropdown(self)
# Module controls
self.module_frame = Frame(self.column_0_frame, row=0, col=0)
MainLabel(self.module_frame)
self.dropdown = ModuleDropdown(self.module_frame, self)

# Functional
self.add_bindings()
Expand Down
7 changes: 3 additions & 4 deletions controls/ApplyButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@


class ApplyButton(SmallButton):
def __init__(self, module, row):
def __init__(self, window, module, row, col):
super().__init__(
module.app,
window,
text="Apply",
command=module.apply
)
self.grid(row=row, column=1, padx=10, sticky="ne")

self.grid(row=row, column=col, padx=10, sticky="ne")

# Binding Enter key to apply button
self.bind("<Return>", module.apply)
6 changes: 3 additions & 3 deletions controls/CloseButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@


class CloseButton(LargeButton):
def __init__(self, module, row):
def __init__(self, window, module, row, col):
self.is_disabled = False
self.__state = tk.DISABLED

super().__init__(
module.app,
window,
text="Close Plot",
command=module.plot.close_plot,
state=self.__state
)

self.grid(row=row, column=0, columnspan=2, padx=10, sticky="nw")
self.grid(row=row, column=col, columnspan=2, padx=10, sticky="nw")

def set_is_disabled(self, state: bool):
self.is_disabled = state
Expand Down
4 changes: 2 additions & 2 deletions controls/MainLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


class MainLabel(Label):
def __init__(self, app):
super().__init__(app, text="Choose calculation mode:", font=("Arial", 17))
def __init__(self, window):
super().__init__(window, text="Choose calculation mode:", font=("Arial", 15))
self.grid(row=0, column=0, columnspan=2, padx=10, pady=7, sticky="nw")
129 changes: 85 additions & 44 deletions controls/MinMaxFields.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,65 @@


class MinMaxFields:
def __init__(self, module):
def __init__(self, window, module, start_row, start_col):
self.sep_0 = Separator(window, row=start_row, col=start_col)

self.x_minmax_fields_1 = XMinMaxFields(
module, row=5, text=module.plot_1_y_title, min_value=module.plot.x_min, max_value=module.plot.x_max)
window,
start_row=start_row + 1,
start_col=start_col,
text=module.plot_1_y_title,
min_value=module.plot.x_min,
max_value=module.plot.x_max
)
self.y_minmax_fields_1 = YMinMaxFields(
module, row=7, text=module.plot_1_y_title, min_value=module.plot.y_min, max_value=module.plot.y_max)
self.sep_1 = Separator(module.app, row=9)
window,
start_row=start_row + 3,
start_col=start_col,
text=module.plot_1_y_title,
min_value=module.plot.y_min,
max_value=module.plot.y_max
)

self.sep_1 = Separator(window, row=start_row+5, col=start_col)

self.x_minmax_fields_2 = XMinMaxFields(
module, row=10, text=module.plot_2_y_title, min_value=module.plot.x_min_2, max_value=module.plot.x_max_2)
window,
start_row=start_row + 6,
start_col=start_col,
text=module.plot_2_y_title,
min_value=module.plot.x_min_2,
max_value=module.plot.x_max_2
)
self.y_minmax_fields_2 = YMinMaxFields(
module, row=12, text=module.plot_2_y_title, min_value=module.plot.y_min_2, max_value=module.plot.y_max_2)
self.sep_2 = Separator(module.app, row=14)
window,
start_row=start_row + 8,
start_col=start_col,
text=module.plot_2_y_title,
min_value=module.plot.y_min_2,
max_value=module.plot.y_max_2
)

self.sep_2 = Separator(window, row=start_row+10, col=start_col)

self.x_minmax_fields_3 = XMinMaxFields(
module, row=15, text=module.plot_3_y_title, min_value=module.plot.x_min_3, max_value=module.plot.x_max_3)
window,
start_row=start_row + 11,
start_col=start_col,
text=module.plot_3_y_title,
min_value=module.plot.x_min_3,
max_value=module.plot.x_max_3
)
self.y_minmax_fields_3 = YMinMaxFields(
module, row=17, text=module.plot_3_y_title, min_value=module.plot.y_min_3, max_value=module.plot.y_max_3)
self.sep_3 = Separator(module.app, row=19)
window,
start_row=start_row + 13,
start_col=start_col,
text=module.plot_3_y_title,
min_value=module.plot.y_min_3,
max_value=module.plot.y_max_3
)

self.sep_3 = Separator(window, row=start_row+15, col=start_col)

def destroy(self):
self.x_minmax_fields_1.destroy()
Expand All @@ -38,12 +79,12 @@ def destroy(self):


class XMinMaxFields:
def __init__(self, module, row, text, min_value, max_value):
self.x_min_label = XMinLabel(module, row, text)
self.x_min_entry = XMinEntry(module, row, min_value)
def __init__(self, module, start_row, start_col, text, min_value, max_value):
self.x_min_label = XMinLabel(module, start_row, start_col, text)
self.x_min_entry = XMinEntry(module, start_row, start_col+1, min_value)

self.x_max_label = XMaxLabel(module, row+1, text)
self.x_max_entry = XMaxEntry(module, row+1, max_value)
self.x_max_label = XMaxLabel(module, start_row + 1, start_col, text)
self.x_max_entry = XMaxEntry(module, start_row + 1, start_col+1, max_value)

def destroy(self):
self.x_min_label.destroy()
Expand All @@ -54,12 +95,12 @@ def destroy(self):


class YMinMaxFields:
def __init__(self, module, row, text, min_value, max_value):
self.y_min_label = YMinLabel(module, row, text)
self.y_min_entry = YMinEntry(module, row, min_value)
def __init__(self, window, start_row, start_col, text, min_value, max_value):
self.y_min_label = YMinLabel(window, start_row, start_col, text)
self.y_min_entry = YMinEntry(window, start_row, start_col + 1, min_value)

self.y_max_label = YMaxLabel(module, row+1, text)
self.y_max_entry = YMaxEntry(module, row+1, max_value)
self.y_max_label = YMaxLabel(window, start_row + 1, start_col, text)
self.y_max_entry = YMaxEntry(window, start_row + 1, start_col + 1, max_value)

def destroy(self):
self.y_min_label.destroy()
Expand All @@ -70,50 +111,50 @@ def destroy(self):


class XMinLabel(TextLabel):
def __init__(self, module, row, text):
super().__init__(module.app, text=f'Xmin for {text}')
self.grid(row=row, column=0, padx=10, sticky="nw")
def __init__(self, window, row, col, text):
super().__init__(window, text=f'Xmin for {text}')
self.grid(row=row, column=col, padx=10, sticky="nw")


class XMinEntry(TextEntry):
def __init__(self, module, row, min_value):
super().__init__(module.app, min_value)
self.grid(row=row, column=1, padx=10, sticky="ne")
def __init__(self, window, row, col, min_value):
super().__init__(window, min_value)
self.grid(row=row, column=col, padx=10, sticky="ne")


class XMaxLabel(TextLabel):
def __init__(self, module, row, text):
super().__init__(module.app, text=f'Xmax for {text}')
self.grid(row=row, column=0, padx=10, sticky="nw")
def __init__(self, window, row, col, text):
super().__init__(window, text=f'Xmax for {text}')
self.grid(row=row, column=col, padx=10, sticky="nw")


class XMaxEntry(TextEntry):
def __init__(self, module, row, max_value):
super().__init__(module.app, max_value)
self.grid(row=row, column=1, padx=10, sticky="ne")
def __init__(self, window, row, col, max_value):
super().__init__(window, max_value)
self.grid(row=row, column=col, padx=10, sticky="ne")


class YMinLabel(TextLabel):
def __init__(self, module, row, text):
super().__init__(module.app, text=f'Ymin for {text}')
self.grid(row=row, column=0, padx=10, sticky="nw")
def __init__(self, window, row, col, text):
super().__init__(window, text=f'Ymin for {text}')
self.grid(row=row, column=col, padx=10, sticky="nw")


class YMinEntry(TextEntry):
def __init__(self, module, row, min_value):
super().__init__(module.app, min_value)
self.grid(row=row, column=1, padx=10, sticky="ne")
def __init__(self, window, row, col, min_value):
super().__init__(window, min_value)
self.grid(row=row, column=col, padx=10, sticky="ne")


class YMaxLabel(TextLabel):
def __init__(self, module, row, text):
super().__init__(module.app, text=f'Ymax for {text}')
self.grid(row=row, column=0, padx=10, sticky="nw")
def __init__(self, window, row, col, text):
super().__init__(window, text=f'Ymax for {text}')
self.grid(row=row, column=col, padx=10, sticky="nw")


class YMaxEntry(TextEntry):
def __init__(self, module, row, max_value):
super().__init__(module.app, max_value)
self.grid(row=row, column=1, padx=10, sticky="ne")
def __init__(self, window, row, col, max_value):
super().__init__(window, max_value)
self.grid(row=row, column=col, padx=10, sticky="ne")


4 changes: 2 additions & 2 deletions controls/ModuleDropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


class ModuleDropdown(Dropdown):
def __init__(self, app):
def __init__(self, window, app):
self.app = app

self.selected_module = tk.StringVar()
self.selected_module.set(self.app.default_module.value)
self.all_modules = [m.value for m in ModuleEnum]

super().__init__(app, self.selected_module, self.all_modules)
super().__init__(window, self.selected_module, self.all_modules)

self.grid(row=1, column=0, columnspan=2, padx=10, pady=10, sticky="nw")
self.bind("<Button>", self.handle_dropdown_focused)
Expand Down
6 changes: 3 additions & 3 deletions controls/OpenCSVButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@


class OpenCSVButton(LargeButton):
def __init__(self, module, row):
def __init__(self, window, module, row, col):
self.module = module

super().__init__(
self.module.app,
window,
text="Open CSV File",
command=self.open
)

self.grid(row=row, column=0, columnspan=2, padx=10, sticky="nw")
self.grid(row=row, column=col, columnspan=2, padx=10, sticky="nw")
self.focus()
self.bind("<Return>", self.open)

Expand Down
16 changes: 7 additions & 9 deletions controls/SpanField.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@


class SpanField:
def __init__(self, module, row):
self.span_label = SpanLabel(module, row)
self.span_entry = SpanEntry(module, row)
def __init__(self, window, module, row):
self.span_label = SpanLabel(window, row)
self.span_entry = SpanEntry(window, module, row)

def destroy(self):
self.span_label.destroy()
self.span_entry.destroy()


class SpanLabel(TextLabel):
def __init__(self, module, row):
super().__init__(module.app, text="Span")
def __init__(self, window, row):
super().__init__(window, text="Span")
self.grid(row=row, column=0, padx=10, sticky="nw")




class SpanEntry(TextEntry):
def __init__(self, module, row):
super().__init__(module.app, module.plot.custom_span)
def __init__(self, window, module, row):
super().__init__(window, module.plot.custom_span)
self.grid(row=row, column=1, padx=10, sticky="ne")

7 changes: 7 additions & 0 deletions controls/base/Frame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import tkinter as tk


class Frame(tk.Frame):
def __init__(self, window, row, col, rowspan=1, colspan=1, sticky="nw"):
super().__init__(window)
self.grid(row=row, column=col, rowspan=rowspan, columnspan=colspan, sticky=sticky)
2 changes: 1 addition & 1 deletion controls/base/LargeButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, window, text, command, state=tk.NORMAL):
text=text,
command=command,
font=("Arial", 15, "bold"),
width=20,
width=17,
height=2,
state=state
)
4 changes: 2 additions & 2 deletions controls/base/Separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


class Separator(ttk.Separator):
def __init__(self, app, row):
def __init__(self, app, row, col):
super().__init__(app, orient="horizontal")
self.grid(row=row, column=0, columnspan=2, padx=10, pady=10, sticky="ew")
self.grid(row=row, column=col, columnspan=2, padx=10, pady=10, sticky="ew")
Loading
Loading