Initial commit: the FS25 Lua mod (live.json data export), the FS25-WebDashboard project (Node/web dashboard + PySide6 desktop variant), and FarmHUD (standalone PySide6 companion app with Discord Rich Presence, settings, and installer).
29 lines
993 B
Python
29 lines
993 B
Python
"""Small shared helpers used across FarmHUD's widgets."""
|
|
from __future__ import annotations
|
|
|
|
from PySide6.QtWidgets import QWidget
|
|
|
|
|
|
def style_role(widget: QWidget, role: str) -> QWidget:
|
|
widget.setProperty("role", role)
|
|
return widget
|
|
|
|
|
|
def clear_layout(layout) -> None:
|
|
"""Empties a layout so it can be rebuilt on the next poll tick.
|
|
|
|
Removing a widget from a layout with takeAt() does NOT hide it - it
|
|
keeps painting at its last geometry until deleteLater()'s deferred
|
|
deletion actually runs on a later event-loop pass. Every dynamic list
|
|
here (storage, missions, players, ...) gets rebuilt on every ~500ms
|
|
poll tick, so that lag would show up as visible flicker/ghosting.
|
|
Hiding immediately (synchronous, cheap) avoids that; deleteLater()
|
|
still runs afterwards to actually free it.
|
|
"""
|
|
while layout.count():
|
|
item = layout.takeAt(0)
|
|
w = item.widget()
|
|
if w is not None:
|
|
w.hide()
|
|
w.deleteLater()
|