@@ -221,7 +221,7 @@ def set_selected(self, selected=True):
221221 self .set_property ('selected' , selected )
222222
223223 def create_property (self , name , value , items = None , range = None ,
224- widget_type = NODE_PROP , tab = 'Properties' ):
224+ widget_type = NODE_PROP , tab = None ):
225225 """
226226 Creates a custom property to the node.
227227
@@ -397,15 +397,62 @@ def icon(self):
397397 """
398398 return self .model .icon
399399
400+ def add_combo_menu (self , name = '' , label = '' , items = None , tab = None ):
401+ """
402+ Embed a :class:`PySide2.QtWidgets.QComboBox` widget into the node.
403+
404+ Args:
405+ name (str): name for the custom property.
406+ label (str): label to be displayed.
407+ items (list[str]): items to be added into the menu.
408+ tab (str): name of the widget tab to display in.
409+ """
410+ items = items or []
411+ self .create_property (
412+ name , items [0 ], items = items , widget_type = NODE_PROP_QCOMBO , tab = tab )
413+ widget = self .view .add_combo_menu (name , label , items )
414+ widget .value_changed .connect (lambda k , v : self .set_property (k , v ))
415+
416+ def add_text_input (self , name = '' , label = '' , text = '' , tab = None ):
417+ """
418+ Embed a :class:`PySide2.QtWidgets.QLineEdit` widget into the node.
419+
420+ Args:
421+ name (str): name for the custom property.
422+ label (str): label to be displayed.
423+ text (str): pre filled text.
424+ tab (str): name of the widget tab to display in.
425+ """
426+ self .create_property (
427+ name , text , widget_type = NODE_PROP_QLINEEDIT , tab = tab )
428+ widget = self .view .add_text_input (name , label , text )
429+ widget .value_changed .connect (lambda k , v : self .set_property (k , v ))
430+
431+ def add_checkbox (self , name = '' , label = '' , text = '' , state = False , tab = None ):
432+ """
433+ Embed a :class:`PySide2.QtWidgets.QCheckBox` widget into the node.
434+
435+ Args:
436+ name (str): name for the custom property.
437+ label (str): label to be displayed.
438+ text (str): checkbox text.
439+ state (bool): pre-check.
440+ tab (str): name of the widget tab to display in.
441+ """
442+ self .create_property (
443+ name , state , widget_type = NODE_PROP_QCHECKBOX , tab = tab )
444+ widget = self .view .add_checkbox (name , label , text , state )
445+ widget .value_changed .connect (lambda k , v : self .set_property (k , v ))
446+
400447 def add_input (self , name = 'input' , multi_input = False , display_name = True ):
401448 """
402449 Add input :class:`Port` to node.
403450
404451 Args:
405- name (str): name for the input port.
452+ name (str): name for the input port.
406453 multi_input (bool): allow port to have more than one connection.
407454 display_name (bool): display the port name on the node.
408-
455+
409456 Returns:
410457 NodeGraphQt.Port: the created port object.
411458 """
@@ -426,10 +473,10 @@ def add_output(self, name='output', multi_output=True, display_name=True):
426473 Add output :class:`Port` to node.
427474
428475 Args:
429- name (str): name for the output port.
476+ name (str): name for the output port.
430477 multi_output (bool): allow port to have more than one connection.
431478 display_name (bool): display the port name on the node.
432-
479+
433480 Returns:
434481 NodeGraphQt.Port: the created port object.
435482 """
@@ -445,48 +492,6 @@ def add_output(self, name='output', multi_output=True, display_name=True):
445492 self .model .outputs [port .name ()] = port .model
446493 return port
447494
448- def add_combo_menu (self , name = '' , label = '' , items = None ):
449- """
450- Embed a :class:`PySide2.QtWidgets.QComboBox` widget into the node.
451-
452- Args:
453- name (str): name for the custom property.
454- label (str): label to be displayed.
455- items (list[str]): items to be added into the menu.
456- """
457- items = items or []
458- self .create_property (
459- name , items [0 ], items = items , widget_type = NODE_PROP_QCOMBO )
460- widget = self .view .add_combo_menu (name , label , items )
461- widget .value_changed .connect (lambda k , v : self .set_property (k , v ))
462-
463- def add_text_input (self , name = '' , label = '' , text = '' ):
464- """
465- Embed a :class:`PySide2.QtWidgets.QLineEdit` widget into the node.
466-
467- Args:
468- name (str): name for the custom property.
469- label (str): label to be displayed.
470- text (str): pre filled text.
471- """
472- self .create_property (name , text , widget_type = NODE_PROP_QLINEEDIT )
473- widget = self .view .add_text_input (name , label , text )
474- widget .value_changed .connect (lambda k , v : self .set_property (k , v ))
475-
476- def add_checkbox (self , name = '' , label = '' , text = '' , state = False ):
477- """
478- Embed a :class:`PySide2.QtWidgets.QCheckBox` widget into the node.
479-
480- Args:
481- name (str): name for the custom property.
482- label (str): label to be displayed.
483- text (str): checkbox text.
484- state (bool): pre-check.
485- """
486- self .create_property (name , state , widget_type = NODE_PROP_QCHECKBOX )
487- widget = self .view .add_checkbox (name , label , text , state )
488- widget .value_changed .connect (lambda k , v : self .set_property (k , v ))
489-
490495 def inputs (self ):
491496 """
492497 Returns all the input port for the node.
0 commit comments