Skip to content

Commit

Permalink
Merge pull request #367 from jchanvfx/property_bin_empty_tab_fix
Browse files Browse the repository at this point in the history
hide empty tab in properties bin widget.
  • Loading branch information
jchanvfx authored Aug 3, 2023
2 parents 4a5a5ce + 0eac001 commit f9e6802
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ def get_widget(self, name):
if item and name == item.widget().toolTip():
return item.widget()

def get_all_widgets(self):
"""
Returns the node property widgets.
Returns:
dict: {name: widget}
"""
widgets = {}
for row in range(self.__layout.rowCount()):
item = self.__layout.itemAtPosition(row, 1)
if not item:
continue
name = item.widget().toolTip()
widgets[name] = item.widget()
return widgets


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

# add "ports" tab connections.
ports_container = None
if node.inputs() or node.outputs():
ports_container = _PortConnectionsContainer(self, node=node)
self.__tab.addTab(ports_container, 'Ports')
return ports_container

# hide empty tabs with no property widgets.
tab_index = {
self.__tab.tabText(x): x for x in range(self.__tab.count())
}
for tab_name, prop_window in self.__tab_windows.items():
prop_widgets = prop_window.get_all_widgets()
if not prop_widgets:
self.__tab.setTabVisible(tab_index[tab_name], False)
self.__tab.setCurrentWidget(prop_window)

return ports_container

def node_id(self):
"""
Expand Down

0 comments on commit f9e6802

Please sign in to comment.