SideFX Houdini customization package
git clone https://git.lucas.co/hou-control.git
hc: let HC Panel control rows be as tall as their widgets
A fixed 24px row squashed the checkboxes and dropdowns: Houdini's
stylesheet makes a checkbox 35px and a combo box 45px. Each control row
now takes its widget's height, floored at a plain text row's so the list
does not ripple.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
python3.13libs/hc/hcwidgets.py | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/python3.13libs/hc/hcwidgets.py b/python3.13libs/hc/hcwidgets.py
index 77c44e5..3b89d8a 100644
--- a/python3.13libs/hc/hcwidgets.py
+++ b/python3.13libs/hc/hcwidgets.py
@@ -3,7 +3,7 @@ import traceback
from fuzzyfinder import fuzzyfinder
from importlib import reload
from PySide6 import QtWidgets
-from PySide6.QtCore import QEvent, QSize, Qt
+from PySide6.QtCore import QEvent, Qt
class HCWidgets:
@@ -121,8 +121,6 @@ class HCWidgets:
class SelectionDialog(QtWidgets.QDialog):
- ROW_HEIGHT = 24
-
def __init__(self, window_title, list_dict, anchor_geometry=None):
super().__init__(hou.qt.mainWindow())
self.resize(900, 600)
@@ -251,6 +249,7 @@ class HCWidgets:
row.refresh()
def populate(self, item_list):
+ control_items = []
for label in item_list:
item = QtWidgets.QListWidgetItem()
item.setData(Qt.UserRole, label)
@@ -261,14 +260,27 @@ class HCWidgets:
# make the Replace Node picker, with every node type in
# it, take seconds to open.
item.setText(label)
- item.setSizeHint(QSize(0, self.ROW_HEIGHT))
self.list.addItem(item)
continue
row = HCWidgets.ControlRow(entry, self._runInPlace)
- item.setSizeHint(QSize(row.sizeHint().width(), self.ROW_HEIGHT))
self.list.addItem(item)
self.list.setItemWidget(item, row)
self.rows[label] = row
+ control_items.append((item, row))
+
+ # A control row is as tall as its control wants -- Houdini's
+ # stylesheet makes a checkbox 35px and a combo box 45px, and a
+ # fixed row height squashed both -- but never shorter than a
+ # plain text row, so the list does not ripple.
+ base = 0
+ for i in range(self.list.count()):
+ if self.list.item(i).text():
+ base = self.list.sizeHintForRow(i)
+ break
+ for item, row in control_items:
+ hint = row.sizeHint()
+ hint.setHeight(max(hint.height(), base))
+ item.setSizeHint(hint)
row.refresh()