Skip to content

Commit c951513

Browse files
Clean up camera_tab
1 parent dabf9a9 commit c951513

File tree

1 file changed

+29
-49
lines changed

1 file changed

+29
-49
lines changed

src/navigate/view/main_window_content/camera_tab.py

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -118,56 +118,44 @@ def __init__(self, settings_tab, *args, **kwargs):
118118
Keyword arguments for ttk.LabelFrame
119119
"""
120120
# Init Frame
121-
text_label = "Camera Modes"
121+
text_label = "Camera Mode"
122122
ttk.Labelframe.__init__(self, settings_tab, text=text_label, *args, **kwargs)
123123

124-
# Formatting
125-
tk.Grid.columnconfigure(self, "all", weight=1)
126-
tk.Grid.rowconfigure(self, "all", weight=1)
127-
128-
# Holds dropdowns, this is done in case more widgets are to be added in a
129-
# different frame, these can be grouped together
130-
#: ttk.Frame: The parent frame for any widgets you add.
131-
content_frame = ttk.Frame(self)
132-
content_frame.grid(row=0, column=0, sticky=tk.NSEW, pady=5)
133-
134-
# Formatting
135-
tk.Grid.columnconfigure(content_frame, "all", weight=1)
136-
tk.Grid.rowconfigure(content_frame, "all", weight=1)
137-
138-
# Dictionary for all the variables, this will be used by the controller
139124
#: dict: Dictionary of all the widgets in the frame.
140125
self.inputs = {}
126+
141127
#: list: List of all the labels for the widgets.
142128
self.labels = ["Sensor Mode", "Readout Direction", "Number of Pixels"]
129+
143130
#: list: List of all the names for the widgets.
144131
self.names = ["Sensor", "Readout", "Pixels"]
145132

133+
for i in range(len(self.labels)):
134+
self.rowconfigure(i, weight=1, uniform="1")
135+
for i in range(2):
136+
self.columnconfigure(i, weight=1, uniform="1")
137+
146138
# Dropdown loop
147139
for i in range(len(self.labels)):
140+
label = ttk.Label(self, text=self.labels[i])
141+
label.grid(row=i, column=0, pady=3, padx=5, sticky=tk.W)
142+
148143
if i < len(self.labels) - 1:
149144
self.inputs[self.names[i]] = LabelInput(
150-
parent=content_frame,
151-
label=self.labels[i],
145+
parent=self,
152146
input_class=ttk.Combobox,
153147
input_var=tk.StringVar(),
154148
input_args={"width": 12},
155149
)
156-
self.inputs[self.names[i]].grid(row=i, column=0, pady=3, padx=5)
157150
else:
158151
self.inputs[self.names[i]] = LabelInput(
159-
parent=content_frame,
160-
label=self.labels[i],
152+
parent=self,
161153
input_class=ValidatedSpinbox,
162154
input_var=tk.StringVar(),
163155
input_args={"from_": 0, "to": 10000, "increment": 1, "width": 5},
164156
)
165-
self.inputs[self.names[i]].grid(row=i, column=0, pady=3, padx=5)
166-
167-
# Additional widget settings
168-
self.inputs["Sensor"].label.grid(padx=(0, 36))
169-
self.inputs["Readout"].label.grid(padx=(0, 10))
170-
self.inputs["Pixels"].label.grid(padx=(0, 15))
157+
self.inputs[self.names[i]].grid(
158+
row=i, column=1, pady=3, padx=5, sticky=tk.W)
171159

172160
def get_variables(self):
173161
"""Get Variables.
@@ -229,63 +217,55 @@ def __init__(self, settings_tab, *args, **kwargs):
229217
text_label = "Framerate Info"
230218
ttk.LabelFrame.__init__(self, settings_tab, text=text_label, *args, **kwargs)
231219

232-
# Holds widgets, this is done in case more widgets are to be
233-
# added in a different frame, these can be grouped together
234-
content_frame = ttk.Frame(self)
235-
content_frame.grid(row=0, column=0, sticky=tk.NSEW, pady=5, padx=5)
236-
237-
# Formatting
238-
tk.Grid.columnconfigure(self, "all", weight=1)
239-
tk.Grid.rowconfigure(self, "all", weight=1)
240-
tk.Grid.columnconfigure(content_frame, "all", weight=1)
241-
tk.Grid.rowconfigure(content_frame, "all", weight=1)
242-
243-
# Dictionary for all the variables, this will be used by the controller
244220
#: dict: Dictionary of all the widgets in the frame.
245221
self.inputs = {}
222+
246223
#: list: List of all the labels for the widgets.
247224
self.labels = [
248225
"Exposure Time (ms)",
249226
"Readout Time (ms)",
250227
"Framerate (Hz)",
251228
"Images to Average",
252229
]
230+
253231
#: list: List of all the names for the widget values.
254232
self.names = [
255233
"exposure_time",
256234
"readout_time",
257235
"max_framerate",
258236
"frames_to_average",
259237
]
238+
239+
for i in range(len(self.labels)):
240+
self.rowconfigure(i, weight=1, uniform="1")
241+
for i in range(2):
242+
self.columnconfigure(i, weight=1, uniform="1")
243+
260244
#: list: List of all the read only values for the widgets.
261245
self.read_only = [True, True, True, False]
262246

263247
# Dropdown loop
264248
for i in range(len(self.labels)):
249+
label = ttk.Label(self, text=self.labels[i])
250+
label.grid(row=i, column=0, pady=1, padx=5, sticky=tk.W)
251+
265252
if self.read_only[i]:
266253
self.inputs[self.names[i]] = LabelInput(
267-
parent=content_frame,
268-
label=self.labels[i],
254+
parent=self,
269255
input_class=ValidatedEntry,
270256
input_var=tk.DoubleVar(),
271257
input_args={"width": 6},
272258
)
273259
self.inputs[self.names[i]].widget["state"] = "readonly"
274-
self.inputs[self.names[i]].grid(row=i, column=0, pady=1)
275260
else:
276261
self.inputs[self.names[i]] = LabelInput(
277-
parent=content_frame,
278-
label=self.labels[i],
262+
parent=self,
279263
input_class=ValidatedSpinbox,
280264
input_var=tk.DoubleVar(),
281265
input_args={"from_": 1, "to": 1000, "increment": 1.0, "width": 6},
282266
)
283-
self.inputs[self.names[i]].grid(row=i, column=0, pady=1)
267+
self.inputs[self.names[i]].grid(row=i, column=1, pady=1, padx=5, sticky=tk.W)
284268

285-
self.inputs["exposure_time"].label.grid(padx=(0, 10))
286-
self.inputs["readout_time"].label.grid(padx=(0, 14))
287-
self.inputs["max_framerate"].label.grid(padx=(0, 10))
288-
self.inputs["frames_to_average"].label.grid(padx=(0, 16))
289269

290270
def get_variables(self):
291271
"""Get Variables

0 commit comments

Comments
 (0)