Utilities#
import_class#
gui_except#
- tkclasswiz.utilities.gui_except(window=None)#
Function that returns a decorator. The decorator returns a callable wrapper object.
When the wrapper is called, it calls the original callee, and in case an exception is raised, the exception is displayed through a popup window. If no exception is raised, the callee’s result is returned.
- Parameters:
window (Optional[Any]) – Optional parent widget, if not provided, the owner of callee method will be used.
Example
class MyWindow(tk.TopLevel): @gui_except() def raise_exceptions(self): raise ValueError("Test")
gui_confirm_action#
- tkclasswiz.utilities.gui_confirm_action(parent=None)#
Function that returns a decorator. The decorator returns a callable wrapper object.
When the wrapper is called, the user is asked to confirm the action and if the user confirms, the original function is called and the wrapper returns the result. If action is cancelled, None is returned by the wrapper.
- Parameters:
parent (Optional[Any]) – Optional parent widget, if not provided, the owner of callee method will be used.
Example
class Database(tk.Widget): @gui_confirm_action() def delete_database(self): print("Deleting database")