Skip to content

Commit 33df514

Browse files
committed
prop bin limit updates
1 parent cde28ac commit 33df514

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

NodeGraphQt/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@
3434
__status__ = 'Work in Progress'
3535
__license__ = 'MIT'
3636

37-
3837
__author__ = 'Johnny Chan'
3938
__email__ = 'http://chantasticvfx.com/contact'
4039

41-
4240
__module_name__ = 'NodeGraphQt'
4341
__url__ = 'https://github.com/jchanvfx/NodeGraphQt'
4442

4543

4644
try:
4745
from Qt import QtWidgets, QtGui, QtCore, QtCompat
4846
except ImportError as ie:
49-
print('Cannot import "Qt.py" module falling back on "NodeGraphQt.vendor.Qt"')
47+
print('Cannot import "Qt.py" shim falling back on "NodeGraphQt.vendor.Qt"')
48+
from .vendor.Qt import __version__ as qtpy_ver
5049
from .vendor.Qt import QtWidgets, QtGui, QtCore, QtCompat
50+
print('Qt.py version: {}'.format(qtpy_ver))
5151

5252
from .base.actions import setup_context_menu
5353
from .base.graph import NodeGraph

NodeGraphQt/widgets/properties_bin.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,43 @@ def __init__(self, parent=None):
5959
self.setWindowTitle('Properties Bin')
6060
self._prop_list = PropertiesList()
6161
self._limit = QtWidgets.QSpinBox()
62+
self._limit.setToolTip('Set node limit to display.')
6263
self._limit.setMaximum(10)
6364
self._limit.setMinimum(0)
65+
self._limit.setValue(10)
66+
self._limit.valueChanged.connect(self.__on_limit_changed)
6467
self.resize(400, 400)
6568

66-
btn_clr = QtWidgets.QPushButton('clear bin')
69+
btn_clr = QtWidgets.QPushButton('clear')
70+
btn_clr.setToolTip('Clear the properties bin.')
6771
btn_clr.clicked.connect(self.clear_bin)
6872

6973
top_layout = QtWidgets.QHBoxLayout()
70-
top_layout.addWidget(btn_clr)
71-
top_layout.addStretch(1)
72-
top_layout.addWidget(QtWidgets.QLabel('limit'))
7374
top_layout.addWidget(self._limit)
75+
top_layout.addStretch(1)
76+
top_layout.addWidget(btn_clr)
7477

7578
layout = QtWidgets.QVBoxLayout(self)
7679
layout.addLayout(top_layout)
7780
layout.addWidget(self._prop_list, 1)
7881

7982
def __on_prop_close(self, node_id):
8083
items = self._prop_list.findItems(node_id, QtCore.Qt.MatchExactly)
81-
if items:
82-
item = items[0]
83-
self._prop_list.removeRow(item.row())
84+
[self._prop_list.removeRow(i.row()) for i in items]
85+
86+
def __on_limit_changed(self, value):
87+
rows = self._prop_list.rowCount()
88+
if rows > value:
89+
self._prop_list.removeRow(rows - 1)
90+
91+
def limit(self):
92+
"""
93+
Returns the limit for how many nodes can be loaded into the bin.
94+
95+
Returns:
96+
int: node limit.
97+
"""
98+
return int(self._limit.value())
8499

85100
def add_node(self, node):
86101
"""
@@ -89,6 +104,13 @@ def add_node(self, node):
89104
Args:
90105
node (NodeGraphQt.Node): node object.
91106
"""
107+
if self.limit() == 0:
108+
return
109+
110+
rows = self._prop_list.rowCount()
111+
if rows >= self.limit():
112+
self._prop_list.removeRow(rows - 1)
113+
92114
itm_find = self._prop_list.findItems(node.id, QtCore.Qt.MatchExactly)
93115
if itm_find:
94116
self._prop_list.removeRow(itm_find[0].row())

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ writing a custom node graph framework. It's currently in a work in progress stat
1212
NodeGraphQt is a node graph framework that can be implemented and re purposed into
1313
applications that supports [PySide2](https://doc.qt.io/qtforpython/pysideapi2.html).
1414

15-
![screencap01](/docs/_images/screenshot.png)
15+
![screencap01](/docs/_images/screenshot.png | width=100)
1616

1717
#### Navigation
1818

0 commit comments

Comments
 (0)