Skip to content

Commit 1649cf1

Browse files
Add button to reset config
1 parent 93b0074 commit 1649cf1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

gui.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,28 @@ def make_open_readme_buttons(self) -> None:
912912
self.open_readme_button_location.grid(row=0, column=1, padx=1, pady=1, sticky=tk.NW)
913913
tooltip.Hovertip(self.open_readme_button_location, text="Open the README file location in the default file manager.")
914914

915+
def reset_config(self) -> None:
916+
"""
917+
Reset the configuration file.
918+
919+
:return: None.
920+
"""
921+
self.config_path.write_text("")
922+
self.create_config()
923+
924+
def confirm_reset_config(self) -> None:
925+
"""
926+
Show a pop up asking if you want to reset the configuration file and reset if yes.
927+
928+
:return: None.
929+
"""
930+
if mbox.askyesno(title="CircuitPython Bundle Manager: Confirm",
931+
message="Are you sure you want to clear the configuration file?",
932+
icon="question", default="no"):
933+
self.reset_config()
934+
mbox.showinfo(title="CircuitPython Bundle Manager: Info",
935+
message="Configuration file successfully reset!")
936+
915937
def make_open_config_buttons(self) -> None:
916938
"""
917939
Make the open config buttons.
@@ -932,6 +954,9 @@ def make_open_config_buttons(self) -> None:
932954
)
933955
self.open_config_button_location.grid(row=0, column=1, padx=1, pady=1, sticky=tk.NW)
934956
tooltip.Hovertip(self.open_config_button_location, text="Open the config file location in the default file manager.")
957+
self.reset_config_button = ttk.Button(master=self.config_frame, text="Reset config file", command=self.confirm_reset_config)
958+
self.reset_config_button.grid(row=1, column=0, columnspan=2, padx=1, pady=1, sticky=tk.NW)
959+
tooltip.Hovertip(self.reset_config_button, text="Reset the config file.")
935960

936961
def make_open_log_buttons(self) -> None:
937962
"""

0 commit comments

Comments
 (0)