Skip to content

BHoM Tkinter bug fixes and improvements#214

Open
Felix-Mallinder wants to merge 7 commits into
developfrom
Python_Toolkit-#213-TkinterReview
Open

BHoM Tkinter bug fixes and improvements#214
Felix-Mallinder wants to merge 7 commits into
developfrom
Python_Toolkit-#213-TkinterReview

Conversation

@Felix-Mallinder
Copy link
Copy Markdown
Contributor

@Felix-Mallinder Felix-Mallinder commented May 5, 2026

Issues addressed by this PR

Closes #213

General upgrade to the BHoM Tkinter tools, prompted by bugs in aesthetic and functionality issues identified in dependant toolkit(s).

Overview:

  • on_change callback implemented at toplevel, in bhom_base_widget, for consistent action of widgets in a form
  • Alignment improvements; for consistent use of align / sticky etc.
  • improved validation logic across some widgets
  • Upgrades to the cmap selector to work with custom colour collections
  • general bug fixing (in response to copilot review / testings)

Test files

~\Python_Toolkit\Python_Engine\Python\tests

Changelog

Additional comments

@Felix-Mallinder Felix-Mallinder self-assigned this May 5, 2026
@Felix-Mallinder Felix-Mallinder linked an issue May 5, 2026 that may be closed by this pull request
@Felix-Mallinder Felix-Mallinder added the type:bug Error or unexpected behaviour label May 5, 2026
@Felix-Mallinder
Copy link
Copy Markdown
Contributor Author

@BHoMBot check required

@bhombot-ci
Copy link
Copy Markdown

bhombot-ci Bot commented May 5, 2026

@Felix-Mallinder to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check core
  • check null-handling
  • check serialisation
  • check versioning
  • check installer

Copy link
Copy Markdown
Contributor

@Tom-Kingstone Tom-Kingstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review from cursory speed read, some things I noticed that I think need changing.

Comment thread Python_Engine/Python/src/python_toolkit/bhom/analytics.py Outdated
Comment on lines +269 to +270
except Exception:
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except Exception:
pass
except Exception:
CONSOLE_LOGGER.error("An error occurred when handling an `on_change` event.", exc_info=1)

please log exceptions

Comment on lines +413 to +416
try:
return mpl.colormaps[name]
except KeyError:
return None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try:
return mpl.colormaps[name]
except KeyError:
return None
return mpl.colormaps.get(name)

self._update_cmap_sample()
return
except Exception:
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please log exceptions


def set(self, value: str):
"""Set the selected value.
"""Set the selected value. Silently ignores values not in the current options.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't make this silent, it is better to have logs for such things (even if they are only for debug)

numeric_val = self._value_type(raw)
except (ValueError, TypeError):
label = "integer" if self._value_type == int else "number"
return getattr(self, "apply_validation")((False, f"Must be a valid {label}.", "error"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

investigate this, why are we using getattr? surely self.apply_validation(...) would work here?

@Tom-Kingstone
Copy link
Copy Markdown
Contributor

Tom-Kingstone commented May 11, 2026

@BHoMBot check installer

@bhombot-ci
Copy link
Copy Markdown

bhombot-ci Bot commented May 11, 2026

@Tom-Kingstone to confirm, the following actions are now queued:

  • check installer

@bhombot-ci
Copy link
Copy Markdown

bhombot-ci Bot commented May 11, 2026

The check installer has already been run previously and recorded as a successful check. This check has not been run again at this time.

applying suggestion mainly to trigger bot check. Most likely the try/except block is going to be removed entirely
ANALYTICS_LOGGER.info(
json.dumps(exec_metadata, default=str, indent=None)
)
try:
Copy link
Copy Markdown
Contributor

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.

@bhombot-ci
Copy link
Copy Markdown

bhombot-ci Bot commented May 11, 2026

@Tom-Kingstone to confirm, the following actions are now queued:

  • check installer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Error or unexpected behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tkinter bugs

2 participants