Skip to content

Commit f9e6802

Browse files
authored
Merge pull request #367 from jchanvfx/property_bin_empty_tab_fix
hide empty tab in properties bin widget.
2 parents 4a5a5ce + 0eac001 commit f9e6802

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

NodeGraphQt/custom_widgets/properties_bin/node_property_widgets.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ def get_widget(self, name):
134134
if item and name == item.widget().toolTip():
135135
return item.widget()
136136

137+
def get_all_widgets(self):
138+
"""
139+
Returns the node property widgets.
140+
141+
Returns:
142+
dict: {name: widget}
143+
"""
144+
widgets = {}
145+
for row in range(self.__layout.rowCount()):
146+
item = self.__layout.itemAtPosition(row, 1)
147+
if not item:
148+
continue
149+
name = item.widget().toolTip()
150+
widgets[name] = item.widget()
151+
return widgets
152+
137153

138154
class _PortConnectionsContainer(QtWidgets.QWidget):
139155
"""
@@ -426,10 +442,22 @@ def _read_node(self, node):
426442
self.type_wgt.setText(model.get_property('type_') or '')
427443

428444
# add "ports" tab connections.
445+
ports_container = None
429446
if node.inputs() or node.outputs():
430447
ports_container = _PortConnectionsContainer(self, node=node)
431448
self.__tab.addTab(ports_container, 'Ports')
432-
return ports_container
449+
450+
# hide empty tabs with no property widgets.
451+
tab_index = {
452+
self.__tab.tabText(x): x for x in range(self.__tab.count())
453+
}
454+
for tab_name, prop_window in self.__tab_windows.items():
455+
prop_widgets = prop_window.get_all_widgets()
456+
if not prop_widgets:
457+
self.__tab.setTabVisible(tab_index[tab_name], False)
458+
self.__tab.setCurrentWidget(prop_window)
459+
460+
return ports_container
433461

434462
def node_id(self):
435463
"""

0 commit comments

Comments
 (0)