@@ -44,6 +44,7 @@ def __init__(
4444 show_submit : bool = True ,
4545 submit_text : str = "Submit" ,
4646 submit_command : Optional [Callable ] = None ,
47+ close_on_submit : bool = True ,
4748 show_close : bool = True ,
4849 close_text : str = "Close" ,
4950 close_command : Optional [Callable ] = None ,
@@ -112,6 +113,7 @@ def __init__(
112113 self .fixed_height = height
113114 self .center_on_screen = center_on_screen
114115 self .submit_command = submit_command
116+ self .close_on_submit = close_on_submit
115117 self .close_command = close_command
116118 self .result = None
117119 self ._is_exiting = False
@@ -591,7 +593,23 @@ def _exit(self, result: str, callback: Optional[Callable] = None) -> None:
591593
592594 def _on_submit (self ) -> None :
593595 """Handle submit button click."""
594- self ._exit ("submit" , self .submit_command )
596+ if self .close_on_submit :
597+ self ._exit ("submit" , self .submit_command )
598+ return
599+
600+ self .result = "submit"
601+ try :
602+ if self .submit_command :
603+ self .submit_command ()
604+ except tk .TclError as ex :
605+ message = str (ex ).lower ()
606+ if not ("image" in message and "doesn't exist" in message ):
607+ print (f"Warning: Exit callback raised an exception: { ex } " )
608+ except Exception as ex :
609+ print (f"Warning: Exit callback raised an exception: { ex } " )
610+ finally :
611+ self ._cached_widget_values = self ._collect_widget_values ()
612+
595613
596614 def _on_close (self ) -> None :
597615 """Handle close button click."""
0 commit comments