Repository navigation
Add form.refresh() to re-apply labels, titles, menus, tooltips, choices and fonts - #17
Merged
Merged
Conversation
Walks the rendered fields (nested forms included) and converts each declared value with str() again, so lazy translated labels pick up a language change: labels, frame/dialog titles, notebook page labels, menu and menu item text, menu item help, tooltips, choices and stock button labels. An optional font is set on every existing control, with InvalidateBestSize, before each form is laid out again. - ChoiceField keeps its original choice objects, converts them at render, and records items given to set_items so a refresh does not bring back the constructor choices. Refresh relabels in place with SetString, keeping the selection. - Menu and MenuItem get working set_label methods (MenuBar.SetMenuLabel, parent item SetItemLabel, hotkey kept). - A lazy help_message no longer crashes MenuItem rendering, and set_title accepts lazy strings. Refs #15 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SeWnvm6tXs9sNdwx2o8mup
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #15.
BaseForm.refresh(font=None)walks the rendered fields, including nested forms, and re-applies what each one declared:wx.GetStockLabel;font=, the font on every existing control.Labels go through
str(), so i18n_core lazy strings re-translate. Choices now keep their original objects and are converted at render.Verified on Windows (wx 4.3.2 msw, private desktop, UIA via pywinauto). Lazy labels whose
str()follows a language switch, en → de, thenframe.refresh(font=<2×>):Open\tCtrl+O→Öffnen\tCtrl+O. Its help text (now allowed to be lazy) and the tooltip were translated.SizedDialog, afterwx.Locale(de)+wxstd,dlg.refresh()changed Cancel → Abbrechen and the static text to its translation.Still to do for #15: once the responsive panel (#14) lands,
refresh()calls its layout re-check on each panel it walks.