@@ -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 ())
0 commit comments