Skip to content

Hide and show a field's label with the field - #16

Merged
ctoth merged 2 commits into
masterfrom
fix/hidden-label-13
Nov 5, 2026
Merged

ctoth merged 2 commits into
masterfrom
fix/hidden-label-13

Conversation

@ctoth

@ctoth ctoth commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Fixes #13.

WXWidget.hide() and show() now hide and show label_control with the control, then call Layout() on every ancestor up to the top-level window. Rendering with hidden=True goes through hide(), so it's covered.

Why every ancestor: when only the parent was laid out, a nested panel stayed at its old height and clipped the next field. Laying out only the top-level window broke the flat case: a plain wx.Frame has no sizer, so the panel never re-laid out.

Verified on Windows (wx 4.3.2 msw, private desktop, UIA via pywinauto):

  • A SizedPanel with fields.Text(label="Notes", multiline=True, hidden=True) reads Edit "Email address" → Text "Kind", with no stray Text "Notes", in both the form and vertical layouts.
  • After show(), the label is at (3, 3), the control at (3, 25), and the next label moves to (3, 69). After hide(), the next label returns to (3, 3).

The nested case was checked on Linux (wx 4.2.1 gtk3, Xvfb) only.

ctoth and others added 2 commits November 4, 2026 22:57
WXWidget.hide()/show() acted only on the control, so a field declared
hidden=True (or hidden later) left its label visible and announced by
screen readers. Also hide/show label_control, and lay out the parent so
the remaining controls reposition.

Fixes #13
Laying out only the parent left a nested panel at its old size, so showing
a field in it clipped the controls below. Laying out only the top-level
window misses the flat case: a plain wx.Frame just resizes its sole child
to the same size, which does not re-lay out the panel. Walk up instead.

Refs #13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SeWnvmhxfidv6uFB5MxaYG
@ctoth
ctoth merged commit ca1042e into master Nov 5, 2026
3 checks passed
@ctoth
ctoth deleted the fix/hidden-label-13 branch November 5, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hiding a field leaves its label visible and read by screen readers

2 participants