fix(xrayeye): defer control-panel width-fixing until after first show
CI for csaxs_bec / test (push) Successful in 2m17s
CI for csaxs_bec / test (push) Successful in 2m17s
_init_ui() locked the control panel to a fixed width computed from sizeHint() called synchronously during construction -- before the widget had ever been shown/laid out, with no real screen geometry and fonts not fully resolved yet (worse over a remote desktop session). Reported live: the widget opens correctly sized for a moment, then the image area visibly collapses down to a sliver as the (wrong) fixed width gets applied, recoverable only by manually resizing the window (which doesn't fix the wrong width itself, just gives the image enough leftover space to look normal again despite it). Defer the actual sizeHint()/setFixedWidth() call via QTimer.singleShot(0, ...) so it runs on the next event-loop iteration, after the widget has actually been shown/laid out at least once -- same effect a manual resize was achieving, but automatic and correct the first time. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3KffiFyyDMKT8vvPENUW
This commit is contained in:
1 parent
3d0686329a
commit
10b02ca2f1
1 file changed
+16
-4
@@ -580,11 +580,15 @@ class OMNY_XRayEye(BECWidget, QWidget):
|
||||
self._update_calibration_readout()
|
||||
self.control_panel_layout.addLayout(form)
|
||||
|
||||
# Fix panel width and allow vertical expansion
|
||||
self.control_panel.adjustSize()
|
||||
p_hint = self.control_panel.sizeHint()
|
||||
self.control_panel.setFixedWidth(p_hint.width())
|
||||
# Fix panel width and allow vertical expansion. The actual width-fixing
|
||||
# is deferred (see _fix_control_panel_width()) rather than computed
|
||||
# here -- sizeHint() called before the widget has ever been shown/laid
|
||||
# out is unreliable (no real screen geometry yet, fonts not fully
|
||||
# resolved -- worse over a remote desktop session), which froze
|
||||
# control_panel at a wrong width until the operator manually resized
|
||||
# the window (forcing Qt to redo layout with correct geometry).
|
||||
self.control_panel.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Expanding)
|
||||
QTimer.singleShot(0, self._fix_control_panel_width)
|
||||
|
||||
# Core Layout: image (expanding) | control panel (fixed)
|
||||
self.core_layout.addWidget(self.image)
|
||||
@@ -741,6 +745,14 @@ class OMNY_XRayEye(BECWidget, QWidget):
|
||||
sep.setLineWidth(1)
|
||||
return sep
|
||||
|
||||
def _fix_control_panel_width(self):
|
||||
"""Lock the control panel to its natural width. Scheduled via
|
||||
QTimer.singleShot(0, ...) from _init_ui() to run on the next event-loop
|
||||
iteration, after the widget has actually been shown/laid out at least
|
||||
once -- sizeHint() is not reliable before that point."""
|
||||
self.control_panel.adjustSize()
|
||||
self.control_panel.setFixedWidth(self.control_panel.sizeHint().width())
|
||||
|
||||
def _init_gui_trigger(self):
|
||||
self.dev.omny_xray_gui.read()
|
||||
self.dev.fsh.read()
|
||||
|
||||
Reference in new issue
Block a user