Conversation
set all sub windows to inherit as type defaultroot, set all widgets to be frame object, with a parent frame to be packed into (expected default root content frame)
changes to mpl renderering and small tcl tweaks
…import of mpl agg backend
unsure about label
| def _on_click(self): | ||
| """Internal click handler increments counter and calls user callback.""" | ||
| self._click_count += 1 | ||
| if self._user_command: | ||
| try: | ||
| self._user_command() | ||
| except Exception: | ||
| # Keep widget robust; do not propagate callback errors | ||
| pass |
There was a problem hiding this comment.
It might not be ideal to just catch exceptions and ignore them with no output, I would be more comfortable if it were to catch and write the stack trace to a logging method for instance.
| def _on_click(self): | |
| """Internal click handler increments counter and calls user callback.""" | |
| self._click_count += 1 | |
| if self._user_command: | |
| try: | |
| self._user_command() | |
| except Exception: | |
| # Keep widget robust; do not propagate callback errors | |
| pass | |
| def _on_click(self): | |
| """Internal click handler increments counter and calls user callback.""" | |
| self._click_count += 1 | |
| if self._user_command: | |
| try: | |
| self._user_command() | |
| except Exception: | |
| CONSOLE_LOGGER.error("Unhandled exception when trying to perform button widget `on_click` command.", exc_info=1) | |
| # Keep widget robust; do not propagate callback errors | |
| pass |
(exc_info just adds the stack trace to the error message as if it was an exception readout)
You can add as much info as desired to the error log, for instance the component ID, the name of the command etc.
Another option would be to show an error box to the user, but that might be best left to the called method to handle, as far as I can tell this is just an extra fallback in case something drastic happens.
tmp_doc_audit.py
Outdated
There was a problem hiding this comment.
Please remove temporary files
tmp_label_test.py
Outdated
| def build( | ||
| self, | ||
| build_type: Literal['pack', 'grid', 'place'] = 'pack', | ||
| **kwargs | ||
| ): | ||
| """Place the widget in its parent container. | ||
|
|
||
| Args: | ||
| build_type: Geometry manager strategy (`pack`, `grid`, or `place`). | ||
| **kwargs: Additional geometry manager options. | ||
| """ | ||
| if build_type == 'pack': | ||
| self.pack(**self.packing_options.to_dict()) | ||
|
|
||
| elif build_type == 'grid': | ||
| raise NotImplementedError("Grid packing is not yet implemented for BHoMBaseWidget.") | ||
|
|
||
| elif build_type == 'place': | ||
| raise NotImplementedError("Place packing is not yet implemented for BHoMBaseWidget.") |
There was a problem hiding this comment.
I'm fine with this as is (I assume that the caller can still call .pack with grid or place anyway, just doesn't get the benefit of using packing_options), but it would be good to have an issue for grid at least as it's (in my opinion) the more useful of the not implemented methods.
There was a problem hiding this comment.
Grid is on the todo list, will implement before removing WIP from this PR
|
@BHoMBot check installer -force |
NOTE: Depends on
Issues addressed by this PR
Closes #202
Set up of BHoM standard approach for tkinter UIs
Test files
Can test by running any of the windows or widget objects - each has an example usage method in the file
Test script added to the test folder
Changelog
python_toolkit.bhom_tkinterfor a modular approach to tkinter usage in dependant bhom toolkits.BHoMBaseWindowhas been established as a base object for all tkinter UI tools to inherit from, this handles base attributes such as styling.bhom_tkinter.windowscontains a series of pre-produced window objects, for direct use, including loading windows, warning windows etc.bhom_tkinter.widgetsincludes a series of widgets to be used when building up a UI. these widgets inherit fromBHoMBaseWidgetfor handling of get, set, packing & build protocols.tclsheets have been set for bhom styling, in dark and light mode. widgets use bhom logos and iconsAdditional comments