-
Notifications
You must be signed in to change notification settings - Fork 1
BHoM Tkinter bug fixes and improvements #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Felix-Mallinder
wants to merge
7
commits into
develop
Choose a base branch
from
Python_Toolkit-#213-TkinterReview
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f70a772
fixed user entered path being mismatched to the var
Felix-Mallinder c2315f9
bug review, for null / get / set / validation issues
Felix-Mallinder 54d1bd1
fix alignment / visual bugs
Felix-Mallinder f393d6a
log file bug
Felix-Mallinder 30c871f
cmap selector can be initialised with colours and cmaps rather than s…
Felix-Mallinder ccec381
ensure the trace / on change commands are consistent
Felix-Mallinder ea57c5e
Apply suggestion from @Tom-Kingstone
Tom-Kingstone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,7 @@ def __init__( | |||||||||
| custom_validation: Optional[Callable[[object], Tuple[bool, Optional[str], Optional[Literal['info', 'warning', 'error']]]]] = None, | ||||||||||
| disable_validation: bool = False, | ||||||||||
| build_options: BuildOptions = PackingOptions(), | ||||||||||
| on_change: Optional[Callable] = None, | ||||||||||
| **kwargs): | ||||||||||
| """ | ||||||||||
| Initialize the widget base. | ||||||||||
|
|
@@ -46,6 +47,10 @@ def __init__( | |||||||||
| Receives the current widget value and must return | ||||||||||
| `(is_valid, message, severity)`. | ||||||||||
| disable_validation: When `True`, all validation returns valid. | ||||||||||
| on_change: Optional callback invoked whenever the widget value | ||||||||||
| changes. The current value is passed as the single argument. | ||||||||||
| Supported by all widgets; supplements widget-specific ``command`` | ||||||||||
| parameters where those exist. | ||||||||||
| **kwargs: Additional Frame options | ||||||||||
| """ | ||||||||||
| super().__init__(parent, **kwargs) | ||||||||||
|
|
@@ -57,6 +62,7 @@ def __init__( | |||||||||
| self.fill_extents = self._normalise_bool(fill_extents) | ||||||||||
| self.custom_validation = custom_validation | ||||||||||
| self.disable_validation = bool(disable_validation) | ||||||||||
| self.on_change: Optional[Callable] = on_change | ||||||||||
|
|
||||||||||
| if id is None: | ||||||||||
| self.id = str(uuid4()) | ||||||||||
|
|
@@ -212,10 +218,11 @@ def align_child_text(self, widget: tk.Widget, alignment: Optional[Literal['left' | |||||||||
| if alignment is not None: | ||||||||||
| self.alignment = self._normalise_alignment(alignment) | ||||||||||
|
|
||||||||||
| self._apply_text_alignment(widget) | ||||||||||
|
|
||||||||||
| if alignment is not None: | ||||||||||
| self.alignment = previous_alignment | ||||||||||
| try: | ||||||||||
| self._apply_text_alignment(widget) | ||||||||||
| finally: | ||||||||||
| if alignment is not None: | ||||||||||
| self.alignment = previous_alignment | ||||||||||
|
|
||||||||||
| def set_alignment(self, alignment: Literal['left', 'center', 'right']) -> None: | ||||||||||
| """Set widget-wide alignment and refresh built-in labels. | ||||||||||
|
|
@@ -247,6 +254,21 @@ def set_fill_extents(self, fill_extents: bool) -> None: | |||||||||
| label.pack_configure(anchor=self._pack_anchor) | ||||||||||
| self._apply_text_alignment(label) | ||||||||||
|
|
||||||||||
| def _fire_on_change(self, value: object) -> None: | ||||||||||
| """Invoke the ``on_change`` callback with the current widget value. | ||||||||||
|
|
||||||||||
| This is called internally by each widget subclass whenever its value | ||||||||||
| changes. It is safe to call even when ``on_change`` is ``None``. | ||||||||||
|
|
||||||||||
| Args: | ||||||||||
| value: The current widget value to pass to the callback. | ||||||||||
| """ | ||||||||||
| if self.on_change is not None: | ||||||||||
| try: | ||||||||||
| self.on_change(value) | ||||||||||
| except Exception: | ||||||||||
| pass | ||||||||||
|
Comment on lines
+269
to
+270
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
please log exceptions |
||||||||||
|
|
||||||||||
| @abstractmethod | ||||||||||
| def get(self): | ||||||||||
| """Get the current value of the widget.""" | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potentially remove this try/except as it was originally added when you were locally testing in the wrong environment.