Skip to content

Commit e4143a8

Browse files
fix recursive state setter (#39)
1 parent a9411de commit e4143a8

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

client/gui.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,6 @@ def __init__(
178178
separator = Separator(main_window, orient=tkinter.HORIZONTAL)
179179
separator.grid(row=main_window.grid_size()[1], column=0, sticky='ew')
180180

181-
plot_frame = tkinter.Frame(main_window)
182-
plot_frame.grid(row=main_window.grid_size()[1], column=0, pady=10)
183-
self.__frames['plots'] = plot_frame
184-
185-
plot_variables = ['altitude', 'ascent_rate', 'ground_speed']
186-
self.__plot_toggles = {}
187-
row = plot_frame.grid_size()[1]
188-
for plot_index, plot in enumerate(plot_variables):
189-
boolean_var = tkinter.BooleanVar()
190-
plot_checkbox = tkinter.Checkbutton(
191-
plot_frame, text=plot, variable=boolean_var,
192-
)
193-
plot_checkbox.grid(row=row, column=plot_index, sticky='nsew')
194-
self.__plot_toggles[plot] = boolean_var
195-
196-
separator = Separator(main_window, orient=tkinter.HORIZONTAL)
197-
separator.grid(row=main_window.grid_size()[1], column=0, sticky='ew')
198-
199181
control_frame = tkinter.Frame(main_window)
200182
control_frame.grid(row=main_window.grid_size()[1], column=0, pady=10)
201183
self.__frames['controls'] = control_frame
@@ -686,7 +668,6 @@ def toggle(self):
686668
del self.__plots[variable]
687669

688670
set_child_states(self.__frames['configuration'], tkinter.DISABLED)
689-
set_child_states(self.__frames['plots'], tkinter.DISABLED)
690671

691672
for callsign in self.packet_tracks:
692673
set_child_states(self.__windows[callsign], tkinter.DISABLED)
@@ -702,7 +683,6 @@ def toggle(self):
702683
LOGGER.error(error)
703684
self.__active = False
704685
set_child_states(self.__frames['configuration'], tkinter.NORMAL)
705-
set_child_states(self.__frames['plots'], tkinter.NORMAL)
706686

707687
self.retrieve_packets()
708688
else:
@@ -717,7 +697,6 @@ def toggle(self):
717697
for callsign in self.packet_tracks:
718698
set_child_states(self.__windows[callsign], tkinter.DISABLED)
719699
set_child_states(self.__frames['configuration'], tkinter.NORMAL)
720-
set_child_states(self.__frames['plots'], tkinter.NORMAL)
721700

722701
self.__toggle_text.set('Start')
723702
self.__active = False
@@ -963,7 +942,7 @@ def retrieve_packets(self):
963942
if window.focus_get() is None:
964943
window.focus_force()
965944

966-
set_child_states(window)
945+
set_child_states(window, tkinter.NORMAL)
967946

968947
self.replace_text(
969948
self.__elements[f'{callsign}.packets'], len(packet_track)
@@ -1088,7 +1067,7 @@ def set_child_states(frame: tkinter.Frame, state: str = None, types: [type] = No
10881067
state = tkinter.NORMAL
10891068
for child in frame.winfo_children():
10901069
if isinstance(child, tkinter.Frame):
1091-
set_child_states(child)
1070+
set_child_states(child, state, types)
10921071
else:
10931072
if types is None or any(
10941073
isinstance(child, selected_type) for selected_type in types

0 commit comments

Comments
 (0)