@@ -49,15 +49,9 @@ def tenant_is_valid_for_save(tenant_id, tenant_name, local_directory):
4949
5050 if tenant_is_valid :
5151 return True
52- messagebox .showerror ("Error" , message )
53-
54- # Reload tree in order to reflect any changes in tenant name. Then re-set focus to same tenant.
55- tree_load_tenants ()
56- for child in tree .get_children ():
57- if tree .item (child )["values" ][1 ] == tenant_id :
58- tree .selection_set (child )
59- break
60- tenant_settings_buttons_normal_state ()
52+ else :
53+ messagebox .showerror ("Error" , message )
54+ return False
6155
6256
6357def tenant_is_valid_for_fetch (tenant ):
@@ -263,8 +257,13 @@ def click_button_save():
263257 local_directory = label_local_directory_path .cget ("text" )
264258
265259 if not tenant_is_valid_for_save (tenant_id , tenant_name , local_directory ):
260+ # Revert original tenant settings in tree
261+ selected_tenant = get_selected_tenant_in_tree ()
262+ load_tenant_settings_to_gui (selected_tenant )
263+ tenant_settings_buttons_normal_state ()
266264 return
267265
266+ # Proceed to update tenant in tenant_settings.json
268267 updated_tenant = {
269268 "id" : tenant_id ,
270269 "include_id" : e_include_id .get (),
@@ -276,6 +275,17 @@ def click_button_save():
276275 ts = TenantSettingsJson ()
277276 ts .update_tenant (updated_tenant )
278277
278+ tenant_settings_buttons_normal_state ()
279+ tree_load_tenants ()
280+
281+ # Reload tree in order to reflect any changes in tenant name. Then re-set focus to same tenant.
282+ tree_load_tenants ()
283+ for child in tree .get_children ():
284+ if tree .item (child )["values" ][1 ] == tenant_id :
285+ tree .selection_set (child )
286+ break
287+ tenant_settings_buttons_normal_state ()
288+
279289 @staticmethod
280290 def click_button_reset ():
281291 tenant : dict = get_selected_tenant_in_tree ()
@@ -560,6 +570,33 @@ def click_button_save_fetch_options(self):
560570 self .destroy ()
561571
562572
573+ def key (event ):
574+ char_pressed : str = event .char
575+ # With current selected tenant as starting point
576+ ts = TenantSettingsJson ()
577+
578+ tree_children : list = list (tree .get_children ())
579+ selected_tree_child : str = tree .selection ()[0 ]
580+ #print(selected_tree_child)
581+
582+ # values = tree.item(tree.selection()).get("values")
583+ # print(values)
584+ # if len(values) > 0:
585+ # tenant_id = values[1]
586+
587+
588+ # selected_tenant: dict = get_selected_tenant_in_tree()
589+ #
590+ # tree_children = tree.get_children()
591+ # print(tree_children)
592+ # #
593+ # # for child in tree.get_children():
594+ # # if tree.item(child)["values"][1] == tenant_id:
595+ # # tree.selection_set(child)
596+ # # break
597+ # #
598+ # # # Get next tenant starting with char_pressed
599+
563600class App (tk .Tk ):
564601 def __init__ (self ):
565602 super ().__init__ ()
@@ -571,11 +608,15 @@ def __init__(self):
571608
572609 self .create_widgets ()
573610 self .load_tenants ()
611+ self .key_binds ()
574612
575613 def create_widgets (self ):
576614 main_frame = MainFrame (self )
577615 main_frame .grid (column = 0 , row = 0 , padx = 10 )
578616
617+ def key_binds (self ):
618+ self .bind ("<Key>" , key )
619+
579620 @staticmethod
580621 def load_tenants ():
581622 """Loads all available tenants to left side tree(navbar),
0 commit comments