15
15
16
16
"""
17
17
18
- # TODO: Add tooltips
19
-
20
18
import tkinter as tk
21
19
from tkinter import ttk
22
20
from tkinter import messagebox as mbox
@@ -134,6 +132,16 @@ def show_traceback(self) -> bool:
134
132
except AttributeError :
135
133
return False
136
134
135
+ def add_tooltip (self , widget : tk .Widget , text : str ) -> None :
136
+ """
137
+ Add a tooltip to a widget.
138
+
139
+ :param widget: The widget to add to.
140
+ :param text: The text in the tooltip.
141
+ :return: None.
142
+ """
143
+ tooltip .Hovertip (anchor_widget = widget , text = text )
144
+
137
145
def create_config (self ) -> None :
138
146
"""
139
147
Re-create the config keys if they do not exist.
@@ -283,9 +291,11 @@ def create_new_project_location(self) -> None:
283
291
textvariable = self .project_location_var , width = 51 )
284
292
self .project_location_entry .initiate_right_click_menu ()
285
293
self .project_location_entry .grid (row = 0 , column = 1 , padx = 1 , pady = 1 , sticky = tk .NW )
294
+ self .add_tooltip (self .project_location_entry , "Where to put the new project." )
286
295
self .project_location_button = ttk .Button (master = self .project_location_frame , text = "Browse..." ,
287
296
command = self .open_new_project_directory )
288
297
self .project_location_button .grid (row = 0 , column = 2 , padx = 1 , pady = 0 , sticky = tk .NW )
298
+ self .add_tooltip (self .project_location_button , "Launch the directory selector." )
289
299
290
300
def create_new_project_details (self ) -> None :
291
301
"""
@@ -301,10 +311,12 @@ def create_new_project_details(self) -> None:
301
311
self .project_title_entry = EntryWithRightClick (master = self .project_details_frame , width = 40 , textvariable = self .project_title_var )
302
312
self .project_title_entry .initiate_right_click_menu ()
303
313
self .project_title_entry .grid (row = 0 , column = 1 , padx = 1 , pady = 1 , sticky = tk .NW )
314
+ self .add_tooltip (self .project_title_entry , "The title of the project." )
304
315
self .project_autogen_var = tk .BooleanVar (value = True )
305
316
self .project_autogen_checkbox = ttk .Checkbutton (master = self .project_details_frame , text = "Auto-generate a .gitignore" ,
306
317
variable = self .project_autogen_var )
307
318
self .project_autogen_checkbox .grid (row = 0 , column = 2 , padx = 1 , pady = 1 , sticky = tk .NW )
319
+ self .add_tooltip (self .project_autogen_checkbox , "Whether to auto-generate a .gitignore file for the Git VCS." )
308
320
self .project_description_label = ttk .Label (master = self .project_details_frame , text = "Project description: " )
309
321
self .project_description_label .grid (row = 1 , column = 0 , columnspan = 3 , padx = 1 , pady = 1 , sticky = tk .NW )
310
322
self .project_description_text = TextWithRightClick (master = self .project_details_frame , width = 60 , height = 10 )
@@ -352,9 +364,11 @@ def create_new_project_buttons(self) -> None:
352
364
self .make_new_project_button = ttk .Button (master = self .project_buttons_frame , text = "Make new project" ,
353
365
command = self .start_create_new_project_thread )
354
366
self .make_new_project_button .grid (row = 0 , column = 0 , padx = 1 , pady = 1 , sticky = tk .N )
367
+ self .add_tooltip (self .make_new_project_button , "Make a new project." )
355
368
self .cancel_new_project_button = ttk .Button (master = self .project_buttons_frame , text = "Cancel" ,
356
369
command = lambda : self .dismiss_dialog (self .new_project_window ))
357
370
self .cancel_new_project_button .grid (row = 0 , column = 1 , padx = 1 , pady = 1 , sticky = tk .N )
371
+ self .add_tooltip (self .cancel_new_project_button , "Close this dialog without creating a new project." )
358
372
self .update_new_project_buttons ()
359
373
360
374
def set_childrens_state (self , frame , enabled : bool = True ) -> None :
@@ -661,6 +675,7 @@ def make_title(self, title: str) -> None:
661
675
self .title_entry = EntryWithRightClick (master = self .title_frame , width = 29 , textvariable = self .title_var )
662
676
self .title_entry .initiate_right_click_menu ()
663
677
self .title_entry .grid (row = 0 , column = 1 , padx = 1 , pady = 1 , sticky = tk .NW )
678
+ self .add_tooltip (self .title_entry , "The title of the opened project." )
664
679
665
680
def make_description (self , description : str ) -> None :
666
681
"""
@@ -677,6 +692,8 @@ def make_description(self, description: str) -> None:
677
692
self .description_text .initiate_right_click_menu ()
678
693
self .description_text .grid (row = 1 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
679
694
self .description_text .insert ("1.0" , description )
695
+ # TODO: Tooltips for text doesn't work
696
+ self .add_tooltip (self .description_text , "The description of the opened project." )
680
697
681
698
def update_drives (self ) -> None :
682
699
"""
@@ -713,12 +730,15 @@ def make_drive_selector(self, drive: Path) -> None:
713
730
self .drive_selector_combobox = ComboboxWithRightClick (master = self .drive_selector_frame , width = 48 , textvariable = self .drive_selector_var )
714
731
self .drive_selector_combobox .initiate_right_click_menu ()
715
732
self .drive_selector_combobox .grid (row = 0 , column = 1 , padx = 1 , pady = 1 , sticky = tk .NW )
733
+ self .add_tooltip (self .drive_selector_combobox , "The CircuitPython device to sync to." )
716
734
self .drive_selector_refresh_btn = ttk .Button (master = self .drive_selector_frame , text = "↻" , width = 2 , command = self .update_drives )
717
735
self .drive_selector_refresh_btn .grid (row = 0 , column = 2 , padx = 1 , pady = 0 , sticky = tk .NW )
736
+ self .add_tooltip (self .drive_selector_refresh_btn , "Refresh the list of connected drives." )
718
737
self .drive_selector_show_all_var = tk .BooleanVar (value = False )
719
738
self .drive_selector_show_all_checkbtn = ttk .Checkbutton (master = self .drive_selector_frame , text = "Show all drives?" ,
720
739
variable = self .drive_selector_show_all_var , command = self .update_drives )
721
740
self .drive_selector_show_all_checkbtn .grid (row = 0 , column = 3 , padx = 1 , pady = 1 , sticky = tk .NW )
741
+ self .add_tooltip (self .drive_selector_show_all_checkbtn , "Whether to show all drives in the list of connected drives instead of just CircuitPython drives." )
722
742
self .update_drives ()
723
743
724
744
def update_listbox_context (self ):
@@ -752,6 +772,7 @@ def make_file_sync_listbox(self, to_sync: list[str], project_root: Path) -> None
752
772
self .to_sync_listbox .right_click_menu .add_command (label = "Add file" , command = self .add_file_to_sync )
753
773
self .to_sync_listbox .right_click_menu .add_command (label = "Add directory" , command = self .add_directory_to_sync )
754
774
self .to_sync_listbox .grid (row = 1 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
775
+ self .add_tooltip (self .to_sync_listbox , "The files and directories to sync to the CircuitPython device." )
755
776
self .to_sync_scrollbar = ttk .Scrollbar (master = self .to_sync_frame , command = self .to_sync_listbox .yview )
756
777
self .to_sync_scrollbar .grid (row = 1 , column = 1 , padx = 0 , pady = 1 , sticky = tk .NSEW )
757
778
self .to_sync_listbox .config (yscrollcommand = self .to_sync_scrollbar .set )
@@ -862,12 +883,15 @@ def make_file_sync_buttons(self) -> None:
862
883
self .to_sync_add_file_btn = ttk .Button (master = self .right_frame , text = "Add file" , width = 12 ,
863
884
command = self .add_file_to_sync )
864
885
self .to_sync_add_file_btn .grid (row = 0 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
886
+ self .add_tooltip (self .to_sync_add_file_btn , "Add a new file via the file selector." )
865
887
self .to_sync_add_directory_btn = ttk .Button (master = self .right_frame , text = "Add directory" ,
866
888
command = self .add_directory_to_sync )
867
889
self .to_sync_add_directory_btn .grid (row = 1 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
890
+ self .add_tooltip (self .to_sync_add_directory_btn , "Add a new directory via the directory selector." )
868
891
self .to_sync_remove_btn = ttk .Button (master = self .right_frame , text = "Remove" , width = 12 ,
869
892
command = self .remove_thing_to_sync )
870
893
self .to_sync_remove_btn .grid (row = 2 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
894
+ self .add_tooltip (self .to_sync_remove_btn , "Remove a file/directory from being synced." )
871
895
self .update_file_sync_buttons ()
872
896
873
897
def save_modified (self ) -> None :
@@ -975,10 +999,13 @@ def make_save_and_sync_buttons(self) -> None:
975
999
"""
976
1000
self .save_config_btn = ttk .Button (master = self .right_frame , text = "Save" , width = 12 , command = self .save_modified )
977
1001
self .save_config_btn .grid (row = 4 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
1002
+ self .add_tooltip (self .save_config_btn , "Save the .cpypmconfig file to disk." )
978
1003
self .discard_config_btn = ttk .Button (master = self .right_frame , text = "Discard" , width = 12 , command = self .discard_modified )
979
1004
self .discard_config_btn .grid (row = 5 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
1005
+ self .add_tooltip (self .discard_config_btn , "Discard changes and reload the .cpypmconfig file from disk" )
980
1006
self .sync_files_btn = ttk .Button (master = self .right_frame , text = "Sync" , width = 12 , command = self .start_sync_thread )
981
1007
self .sync_files_btn .grid (row = 6 , column = 0 , padx = 1 , pady = 1 , sticky = tk .NW )
1008
+ self .add_tooltip (self .sync_files_btn , "Sync the files to the CircuitPython drive." )
982
1009
self .check_sync_buttons ()
983
1010
984
1011
def update_main_gui (self ) -> None :
0 commit comments