diff --git a/toolbar/hermes_bridge.shelf b/toolbar/hermes_bridge.shelf index 464f0f8..16e727b 100644 --- a/toolbar/hermes_bridge.shelf +++ b/toolbar/hermes_bridge.shelf @@ -30,8 +30,8 @@ def save_config(cfg): def bridge_is_open(port): return f"Port {port} is open" in hou.hscript("openport")[0] -# ── Dialog ────────────────────────────────────────── -class HermesBridgeDialog(QtWidgets.QDialog): +# ── Window (QWidget, not QDialog — per SideFX HOM cookbook) ─ +class HermesBridgeWindow(QtWidgets.QWidget): def __init__(self, parent=None): super().__init__(parent) self.cfg = load_config() @@ -43,22 +43,17 @@ class HermesBridgeDialog(QtWidgets.QDialog): def _build_ui(self): self.setWindowTitle("Hermes Bridge") self.setMinimumWidth(420) - self.setAttribute(QtCore.Qt.WA_DeleteOnClose, False) - # Dark theme self.setStyleSheet(""" - QDialog { background: #1e1e1e; color: #e0e0e0; } - QLabel { color: #ccc; } + QWidget { background: #1e1e1e; color: #e0e0e0; font-size: 13px; } QLabel#title { font-size: 16px; font-weight: bold; color: #fff; } - QLabel#status { font-size: 14px; font-weight: bold; } QPushButton { border: none; border-radius: 4px; padding: 8px 16px; - font-weight: bold; font-size: 13px; } + font-weight: bold; } QPushButton#btnToggle { padding: 12px; font-size: 15px; } QPushButton#btnToggle[active="true"] { background: #5c1a1a; color: #ff7777; border: 1px solid #a44; } QPushButton#btnToggle[active="false"] { background: #1a4a1a; color: #77cc77; border: 1px solid #4a4; } - QPushButton#btnToggle:hover { opacity: 0.9; } QPushButton#btnCopy { background: #1565c0; color: #fff; } QPushButton#btnCopy:hover { background: #1976d2; } QSpinBox { background: #2d2d2d; border: 1px solid #555; color: #e0e0e0; @@ -71,17 +66,13 @@ class HermesBridgeDialog(QtWidgets.QDialog): layout.setSpacing(12) layout.setContentsMargins(20, 20, 20, 20) - # Title title = QtWidgets.QLabel("\U0001f916 Hermes Bridge") title.setObjectName("title") layout.addWidget(title) - # Status self.status_label = QtWidgets.QLabel() - self.status_label.setObjectName("status") layout.addWidget(self.status_label) - # Port port_row = QtWidgets.QHBoxLayout() port_row.addWidget(QtWidgets.QLabel("Port:")) self.port_spin = QtWidgets.QSpinBox() @@ -93,13 +84,11 @@ class HermesBridgeDialog(QtWidgets.QDialog): port_row.addStretch() layout.addLayout(port_row) - # Toggle button self.btn_toggle = QtWidgets.QPushButton() self.btn_toggle.setObjectName("btnToggle") self.btn_toggle.clicked.connect(self._toggle) layout.addWidget(self.btn_toggle) - # Prompt text layout.addWidget(QtWidgets.QLabel("Tell Hermes:")) prompt_row = QtWidgets.QHBoxLayout() self.prompt_field = QtWidgets.QLineEdit() @@ -128,7 +117,6 @@ class HermesBridgeDialog(QtWidgets.QDialog): "color: #ff5555; font-size: 14px; font-weight: bold;") self.btn_toggle.setText("Open Bridge") self.btn_toggle.setProperty("active", "false") - # Force style refresh self.btn_toggle.style().unpolish(self.btn_toggle) self.btn_toggle.style().polish(self.btn_toggle) self.prompt_field.setText( @@ -151,7 +139,6 @@ class HermesBridgeDialog(QtWidgets.QDialog): self.cfg["port"] = value save_config(self.cfg) if was_open: - hou.hscript(f"closeport {self.port}") hou.hscript(f"openport {self.port} 0.0.0.0") self._refresh() @@ -162,13 +149,6 @@ class HermesBridgeDialog(QtWidgets.QDialog): QtCore.QTimer.singleShot(2000, lambda: self.btn_copy.setText("Copy")) -# ── Show dialog (persist in hou.session per SideFX docs) ── -if not hasattr(hou.session, "hermes_bridge_dialog") or hou.session.hermes_bridge_dialog is None: - hou.session.hermes_bridge_dialog = HermesBridgeDialog(hou.ui.mainQtWindow()) -dialog = hou.session.hermes_bridge_dialog -dialog.show() -dialog.raise_() -dialog.activateWindow() -]]> - - +# ── Per SideFX docs: parent to main window to keep alive ── +win = HermesBridgeWindow(hou.ui.mainQtWindow()) +win.show()