Skip to content

Commit

Permalink
BUGFIX: exit software when window close button is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Apr 15, 2024
1 parent 5777555 commit 95ff2f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions MethodicConfigurator/frontend_tkinter_connection_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class ConnectionSelectionWindow(BaseWindow):
def __init__(self, flight_controller: FlightController, connection_result_string: str):
super().__init__()
self.root.title("Flight controller connection")
self.root.geometry("400x500") # Set the window size
self.root.geometry("400x510") # Set the window size

# Explain why we are here
if flight_controller.comport is None:
Expand Down Expand Up @@ -243,7 +243,13 @@ def __init__(self, flight_controller: FlightController, connection_result_string
skip_fc_connection_button = tk.Button(option3_label_frame,
text="Skip FC connection, just edit the .param files on disk",
command=self.skip_fc_connection)
skip_fc_connection_button.pack(expand=False, fill=tk.X, padx=20, pady=6)
skip_fc_connection_button.pack(expand=False, fill=tk.X, padx=15, pady=6)

# Bind the close_connection_and_quit function to the window close event
self.root.protocol("WM_DELETE_WINDOW", self.close_and_quit)

def close_and_quit(self):
sys_exit(0)

def fc_autoconnect(self):
self.connection_selection_widgets.reconnect()
Expand Down
8 changes: 8 additions & 0 deletions MethodicConfigurator/frontend_tkinter_directory_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from argparse import ArgumentParser

from sys import exit as sys_exit

from copy import deepcopy

from logging import basicConfig as logging_basicConfig
Expand Down Expand Up @@ -187,6 +189,12 @@ def __init__(self, local_filesystem: LocalFilesystem):
"MyVehicleName")
self.create_option2_widgets()

# Bind the close_connection_and_quit function to the window close event
self.root.protocol("WM_DELETE_WINDOW", self.close_and_quit)

def close_and_quit(self):
sys_exit(0)

def create_option1_widgets(self, initial_template_dir: str, initial_base_dir: str, initial_new_dir: str):
# Option 1 - Create a new vehicle configuration directory based on a existing template
option1_label_frame = tk.LabelFrame(self.root, text="Option 1")
Expand Down

0 comments on commit 95ff2f3

Please sign in to comment.