updated amu UI - #296
updated amu UI#296
Conversation
There was a problem hiding this comment.
What's good
- Dropping the weight fields matches Happy Hare: its gate data has no weight field, so
_lbl_weightwas reading nothing. update_entrynow handles an empty colour and a leading#, whichdev'sQColor("#" + color[:6])does not._refresh_visibleusessetVisibleinstead of reparenting, andQBoxLayoutalready skips hidden widgets._make_btn/_make_fieldand_button_states_for_statusremove a lot of duplication.- Splitting tap and accept into
_on_list_item_tapped/_on_accept_clickedis clearer than the oldsender()check.
1. amuWidgets.py:468: filament_pos is one global MMU value applied to every gate
addSpool(gate_info, mmu_state.filament_pos) gives the same filament_pos to all four buttons, and the enable block only checks is_active_gate for en_purge and the badge text. With filament loaded from gate 0, selecting gate 3 shows Unload enabled and Load disabled, and with no encoder nothing notices the unload is meaningless. Gate the whole override on the active gate:
if not is_active_gate or filament_pos == FilamentPos.UNLOADED:
en_unload = False
else:
en_unload, en_load, en_purge = True, False, False
text = self._LOADED_TEXT if filament_pos == FilamentPos.LOADED else self._STUCK_TEXT2. filamentTab.py:673: _on_list_item_tapped lost the item is None guard
The old _on_spool_selected started with if item is None: return, and the other handlers (addSpoolPage._on_filament_selected, spoolmanPage.on_item_clicked) still guard. An AttributeError inside a pyqtSlot is qFatal() -> SIGABRT -> restart loop:
if not item:
return3. filamentTab.py:695: _on_accept_clicked reads the model selection, not the tapped item
Tapping "+ Add Spool" returns early without clearing the selection or disabling accept_btn, so a following Accept resolves _spool_id_map.get("+ Add Spool") -> None and silently does nothing. Reuse the item the tap handler already resolved:
self._selected_spool = spool # in _on_list_item_tapped, read it back in _on_accept_clicked4. amuWidgets.py:489: editable locks out empty gates
status != GateStatus.EMPTY means material/temp/colour can't be set on an empty gate, which is exactly when you'd configure it before loading. The spool_id == -1 half is right:
editable = gate_info is not None and spool_id == -15. amuWidgets.py:319: mousePressEvent monkey-patched onto a QLabel
Same pattern as #295: it swallows the event, gives no press feedback, and is the only way to reach the colour wheel. BlocksLabel already has clicked:
self._swatch = BlocksLabel(self)
self._swatch.clicked.connect(self.colorSwatchClicked)6. amuWidgets.py:346: _color_field is a hidden BlocksCustomLinEdit used as a value carrier
It's never added to a layout, it only carries text between the colour wheel and set_gate_color. A signal argument does the same without an orphan widget whose editingFinished depends on focus:
colorSelected = QtCore.pyqtSignal(str, name="color-selected")
# amuPage: self.info_panel.colorSelected.connect(lambda hx: self.amu_manager.set_gate_color(self.current_index, hx))7. amuWidgets.py:103: paintEvent draws nothing until the first resize
_text_rect/_strip_path are only built in resizeEvent. Build them lazily so the widget is correct whatever the event order:
if self._text_rect is None or self._strip_path is None:
self._rebuild_geometry()8. amuWidgets.py:118-123: the gate label doesn't dim with the rest of the button
setOpacity(self._UNCHECKED_OPACITY) runs after drawText, so an unselected gate keeps a full-brightness "Gate N" over a dimmed body. Move it above the text draw if the label should dim too.
9. amuWidgets.py:21: GateInfo = None is not an optional annotation
update_for_slot and _button_states_for_status both test gate_info is not None, so pyright flags it:
self.gate_info: GateInfo | None = NoneMinor
-
amuWidgets.py:485:"Spoll ID"typo in user-visible text:f" · Spool ID {spool_id}</span>"
-
amuWidgets.py:3: import not sorted:from devices.amu.models import FilamentPos, GateInfo, GateStatus
-
amuWidgets.py:88(optional): Happy Hare'sgate_colorcan also be a w3c name (red), which still parses as invalid and paints the grey hatch. Same ondev, so not a regression.GateInfo.color_rgbis Happy Hare's parsed form and is already ondev:
color = QtGui.QColor.fromRgbF(*gate_info.color_rgb)
has_color = bool(gate_info.color)
Description
BlocksScreen/lib/panels/widgets/amuWidgets.py
New
Old
BlocksScreen/lib/panels/widgets/amuPage.py
BlocksScreen/lib/panels/filamentTab.py