def __init__(self, node, parent) :
		"""
		"""
		FrameAnimator.__init__(self, parent)
		NodeWidget.__init__(self, node)

		self.notify(node,("caption_modified",node.get_caption() ) )
    def __init__(self, node, parent):
        """
		"""
        QWidget.__init__(self, parent)
        NodeWidget.__init__(self, node)

        self._img_lab = InteractiveScalableLabel()
        self._img_lab.setCursor(QCursor(QPixmap(":cursor/pick.png"), 9, 10))

        self._col_picked_lab = QLabel("col")
        self._col_picked_lab.setPixmap(QPixmap(32, 32))
        self._col_picked_lab.pixmap().fill(QColor(0, 0, 0))

        self._col_current_lab = QLabel("col")
        self._col_current_lab.setPixmap(QPixmap(32, 32))
        self._col_current_lab.pixmap().fill(QColor(0, 0, 0))

        self._h_layout = QHBoxLayout()
        self._v_layout = QVBoxLayout()

        self._v_layout.addWidget(self._col_picked_lab)
        self._v_layout.addWidget(self._col_current_lab)
        self._v_layout.addStretch(5)

        self._h_layout.addLayout(self._v_layout)
        self._h_layout.addWidget(self._img_lab, 5)

        self.setLayout(self._h_layout)

        self.notify(node, ("caption_modified", node.get_caption()))
        self.notify(node, ("input_modified", 0))
        self.notify(node, ("input_modified", 1))

        QObject.connect(self._img_lab, SIGNAL("mouse_click"), self.mouse_click)
        QObject.connect(self._img_lab, SIGNAL("mouse_move"), self.mouse_move)
Example #3
0
            def __init__(self, node, parent):

                LPyWindow.__init__(self, parent)
                NodeWidget.__init__(self, node)
                QtCore.QObject.connect(self.codeeditor,
                                       QtCore.SIGNAL('textChanged()'),
                                       self.updateNode)
Example #4
0
    def __init__(self, node, parent):
        """
		"""
        FrameAnimator.__init__(self, parent)
        NodeWidget.__init__(self, node)

        self.notify(node, ("caption_modified", node.get_caption()))
	def __init__(self, node, parent) :
		"""
		"""
		QWidget.__init__(self, parent)
		NodeWidget.__init__(self, node)

		self._img_lab = InteractiveScalableLabel()
		self._img_lab.setCursor(QCursor(QPixmap(":cursor/pick.png"),9,10) )

		self._col_picked_lab = QLabel("col")
		self._col_picked_lab.setPixmap(QPixmap(32,32) )
		self._col_picked_lab.pixmap().fill(QColor(0,0,0) )

		self._col_current_lab = QLabel("col")
		self._col_current_lab.setPixmap(QPixmap(32,32) )
		self._col_current_lab.pixmap().fill(QColor(0,0,0) )

		self._h_layout = QHBoxLayout()
		self._v_layout = QVBoxLayout()

		self._v_layout.addWidget(self._col_picked_lab)
		self._v_layout.addWidget(self._col_current_lab)
		self._v_layout.addStretch(5)

		self._h_layout.addLayout(self._v_layout)
		self._h_layout.addWidget(self._img_lab,5)

		self.setLayout(self._h_layout)

		self.notify(node,("caption_modified",node.get_caption() ) )
		self.notify(node,("input_modified",0) )
		self.notify(node,("input_modified",1) )

		QObject.connect(self._img_lab,SIGNAL("mouse_click"),self.mouse_click)
		QObject.connect(self._img_lab,SIGNAL("mouse_move"),self.mouse_move)
Example #6
0
File: gui.py Project: openalea/mtg
 def __init__(self, node, parent):
     QtGui.QWidget.__init__(self, parent)
     NodeWidget.__init__(self, node)
     self.editor = GraphicalMtgFactory.create_view(None, parent=None)
     self.lay = QtGui.QVBoxLayout()
     self.lay.setSpacing(0)
     self.lay.setContentsMargins(0, 0, 0, 0)
     self.lay.addWidget(self.editor)
     self.setLayout(self.lay)
Example #7
0
 def __init__(self, node, parent):
     QtGui.QWidget.__init__(self, parent)
     NodeWidget.__init__(self, node)
     self.editor = GraphicalMtgFactory.create_view(None, parent=None)
     self.lay = QtGui.QVBoxLayout()
     self.lay.setSpacing(0)
     self.lay.setContentsMargins(0, 0, 0, 0)
     self.lay.addWidget(self.editor)
     self.setLayout(self.lay)
Example #8
0
    def __init__(self, node, parent=None):
        ScalableLabel.__init__(self, parent)
        NodeWidget.__init__(self, node)

        self.setMouseTracking(True)

        self._mouse_ini_pos = None
        self._select_rect = QRect()

        self.notify(node, ("input_modified", 0))
    def __init__(self, node, parent):
        QtGui.QDialog.__init__(self, parent)
        NodeWidget.__init__(self, node)

        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)
        self.btGroup = QtGui.QButtonGroup()
        self.btGroup.setExclusive(True)

        self.widgets = []
        self.notify(node, ("input_modified", 0))
Example #10
0
    def __init__(self, node, parent):
        """
        """

        UI_ratp_Grid.__init__(self, parent)
        NodeWidget.__init__(self, node)
        self.window().setWindowTitle("Grid parameters")
        self.listSpinBox = []
        self.copyVal = None
        self.adjustUI()
        self.notify(node, ('input_modified', ))
    def __init__(self, node, parent=None):

        PointSelection.__init__(self)
        NodeWidget.__init__(self, node)

        self.notify(node, ('input_modified', ))

        self.connect(self, QtCore.SIGNAL("points_changed"), \
                     self.pointsChanged)

        self.window().setWindowTitle(node.get_caption())
 def __init__(self, node, parent):
     """
     """
     Curve2DEditor.__init__(self, parent)
     NodeWidget.__init__(self, node)
     
     self.notify(node, ('input_modified',))
     
     self.connect(self, QtCore.SIGNAL("valueChanged()"), \
                  self.valueChanged)
     
     self.window().setWindowTitle(node.get_caption())
Example #13
0
 def __init__(self, node, parent):
     """
     """
     Curve2DEditor.__init__(self, parent)
     NodeWidget.__init__(self, node)
     
     self.notify(node, ('input_modified',))
     
     self.connect(self, QtCore.SIGNAL("valueChanged()"), \
                  self.valueChanged)
     
     self.window().setWindowTitle(node.get_caption())
Example #14
0
    def __init__(self, node, parent):

        QtGui.QDialog.__init__(self, parent)
        NodeWidget.__init__(self, node)

        self.gridlayout = QtGui.QGridLayout(self)
        self.gridlayout.setContentsMargins(3, 3, 3, 3)
        self.gridlayout.setSpacing(5)

        self.package_lineedit_label = QtGui.QLabel('1. Set the package', self)
        self.gridlayout.addWidget(self.package_lineedit_label, 0, 0)

        self.package_lineedit = QtGui.QLineEdit(self)
        self.gridlayout.addWidget(self.package_lineedit, 0, 1, 1, 3)
        self.connect(self.package_lineedit, QtCore.SIGNAL("textChanged()"),
                     self.package_changed)

        self.datadir_lineedit = QtGui.QLineEdit(self)
        self.datadir_lineedit.setReadOnly(True)
        self.gridlayout.addWidget(self.datadir_lineedit, 1, 1, 1, 3)

        self.metadata_textedit = QtGui.QTextEdit('', self)
        self.metadata_textedit.setReadOnly(True)
        self.metadata_textedit.setTextInteractionFlags(
            QtCore.Qt.TextBrowserInteraction)
        self.gridlayout.addWidget(self.metadata_textedit, 2, 1, 1, 3)

        self.glob_lineedit_label = QtGui.QLabel(
            '2.Filter the data: (e.g., *.dat)', self)
        self.gridlayout.addWidget(self.glob_lineedit_label, 3, 0)

        self.glob_lineedit = QtGui.QLineEdit(self)
        self.gridlayout.addWidget(self.glob_lineedit, 3, 1, 1, 2)
        self.connect(self.glob_lineedit, QtCore.SIGNAL("textChanged()"),
                     self.glob_changed)

        self.filenames_combobox_label = QtGui.QLabel(
            '3. Select the data file:', self)
        self.gridlayout.addWidget(self.filenames_combobox_label, 4, 0)

        self.filenames_combobox = QtGui.QComboBox(self)
        self.connect(self.filenames_combobox, QtCore.SIGNAL("activated()"),
                     self.filename_changed)
        self.gridlayout.addWidget(self.filenames_combobox, 4, 1, 1, 3)

        self.setWindowTitle("SharedDatabrowser")
        self.setGeometry(250, 200, 350, 550)

        self.updating = False

        self.notify(node, ("input_modified", 0))
        self.notify(node, ("caption_modified", node.get_caption()))
    def __init__(self, node, parent):

        QtGui.QDialog.__init__(self, parent)
        NodeWidget.__init__(self, node)

        self.gridlayout = QtGui.QGridLayout(self)
        self.gridlayout.setContentsMargins(3, 3, 3, 3)
        self.gridlayout.setSpacing(5)

        self.package_lineedit_label = QtGui.QLabel('1. Set the package', self)
        self.gridlayout.addWidget(self.package_lineedit_label, 0, 0)
        
        self.package_lineedit = QtGui.QLineEdit(self)
        self.gridlayout.addWidget(self.package_lineedit, 0, 1, 1, 3)
        self.connect(self.package_lineedit, 
                     QtCore.SIGNAL("textChanged()"), 
                     self.package_changed)
        
        self.datadir_lineedit = QtGui.QLineEdit(self)
        self.datadir_lineedit.setReadOnly(True)
        self.gridlayout.addWidget(self.datadir_lineedit, 1, 1, 1, 3)

        self.metadata_textedit = QtGui.QTextEdit('', self)
        self.metadata_textedit.setReadOnly(True)
        self.metadata_textedit.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
        self.gridlayout.addWidget(self.metadata_textedit, 2, 1, 1, 3)

        self.glob_lineedit_label = QtGui.QLabel('2.Filter the data: (e.g., *.dat)', self)
        self.gridlayout.addWidget(self.glob_lineedit_label, 3, 0)

        self.glob_lineedit = QtGui.QLineEdit(self)
        self.gridlayout.addWidget(self.glob_lineedit, 3, 1, 1, 2)
        self.connect(self.glob_lineedit, 
                     QtCore.SIGNAL("textChanged()"), 
                     self.glob_changed)

        self.filenames_combobox_label = QtGui.QLabel('3. Select the data file:', self)
        self.gridlayout.addWidget(self.filenames_combobox_label, 4, 0)

        self.filenames_combobox = QtGui.QComboBox(self)
        self.connect(self.filenames_combobox,
                     QtCore.SIGNAL("activated()"), 
                     self.filename_changed)
        self.gridlayout.addWidget(self.filenames_combobox, 4, 1, 1, 3)

        self.setWindowTitle("SharedDatabrowser")
        self.setGeometry(250, 200, 350, 550)
        
        self.updating = False

        self.notify(node, ("input_modified", 0))
        self.notify(node, ("caption_modified", node.get_caption()))
Example #16
0
    def __init__(self, node, parent):
        """
        @param node
        @param parent
        """

        QtGui.QListWidget.__init__(self, parent)
        NodeWidget.__init__(self, node)
        self.connect(self, QtCore.SIGNAL("currentRowChanged(int)"),
                     self.changed)

        self.mode = None
        self.notify(node, ("input_modified", 0))
        self.notify(node, ("input_modified", 1))
Example #17
0
    def __init__(self, node, parent):
        """
        """

        UI_ratp_Vege.__init__(self, parent)
        NodeWidget.__init__(self, node)
        self.window().setWindowTitle("Vegetation parameters")
        self.listSpinBox = []
        ##        self.val = self.node.get_output(0)
        self.copyVal = None
        ##        self.initVal()

        self.adjustUI()
        self.notify(node, ('input_modified', ))
Example #18
0
    def __init__(self, node, parent):
        """
        @param node
        @param parent
        """

        QtGui.QListWidget.__init__(self, parent)
        NodeWidget.__init__(self, node)
        self.connect(self, QtCore.SIGNAL("currentRowChanged(int)"),
                     self.changed)

        self.mode = None
        self.notify(node, ("input_modified", 0))
        self.notify(node, ("input_modified", 1))
    def __init__(self, node, parent):

        QtGui.QDialog.__init__(self, parent)
        NodeWidget.__init__(self, node)

        #self.browser = QtGui.QTextBrowser()
        
        layout = QtGui.QVBoxLayout()
        #layout.addWidget(self.browser)
        self.setLayout(layout)

        self.in_list = []
        self.widgets = []
        self.notify(node, ("input_modified", 0))
Example #20
0
    def __init__(self, node, parent):

        QtGui.QDialog.__init__(self, parent)
        NodeWidget.__init__(self, node)

        #self.browser = QtGui.QTextBrowser()

        layout = QtGui.QVBoxLayout()
        #layout.addWidget(self.browser)
        self.setLayout(layout)

        self.in_list = []
        self.widgets = []
        self.notify(node, ("input_modified", 0))
Example #21
0
    def __init__(self, node, parent=None, autonomous=False):

        qt.QtGui.QWidget.__init__(self, parent)
        NodeWidget.__init__(self, node)

        vboxlayout = qt.QtGui.QVBoxLayout(self)
        self.vboxlayout = vboxlayout

        self.node = node

        # Container
        self.container = qt.QtGui.QTabWidget(self)
        vboxlayout.addWidget(self.container)

        if (autonomous):
            self.set_autonomous()
            return

        # empty_io is a flag to define if the composite widget add only io widgets

        # Trey to create a standard node widget for inputs
        default_widget = DefaultNodeWidget(node, parent)

        if (default_widget.is_empty()):
            default_widget.close()
            default_widget.destroy()
            del default_widget
            empty_io = True

        else:
            empty_io = False
            self.container.addTab(default_widget, "Inputs")

        # Add subwidgets (Need to sort widget)
        for id in node.vertices():

            subnode = node.node(id)

            # Do not display widget if hidden
            hide = subnode.internal_data.get('hide', False)
            user_app = subnode.internal_data.get('user_application', False)
            if (hide and not empty_io): continue

            if (not user_app):
                # ignore node with all input connected
                states = [
                    bool(subnode.get_input_state(p) == "connected")
                    for p in xrange(subnode.get_nb_input())
                ]

                if (all(states)): continue

            # Add tab
            try:
                factory = subnode.get_factory()
                widget = factory.instantiate_widget(subnode, self)
                assert widget
            except:
                continue

            if (widget.is_empty()):
                widget.close()
                del widget
            else:
                # Add as tab
                caption = "%s" % (subnode.caption)
                self.container.addTab(widget, caption)
Example #22
0
    def __init__(self, node, parent):

        QDialog.__init__(self, parent)
        NodeWidget.__init__(self, node)

        self.gridlayout = QGridLayout(self)
        self.gridlayout.setMargin(3)
        self.gridlayout.setSpacing(5)

        self.package_lineedit_label = QLabel('1. Set the package', self)
        self.gridlayout.addWidget(self.package_lineedit_label, 0, 0)

        self.package_lineedit = QLineEdit(self)
        self.cursorPosition_package_lineedit = self.package_lineedit.cursorPosition(
        )
        self.gridlayout.addWidget(self.package_lineedit, 0, 1, 1, 4)
        self.connect(self.package_lineedit, SIGNAL("textChanged(QString)"),
                     self.package_changed)

        self.select_files_label = QLabel(
            '2. Set the patterns and select the \
files', self)
        self.gridlayout.addWidget(self.select_files_label, 1, 0, 1, 4)

        self.nb_of_inputs = node.get_nb_input()
        self.nb_of_files = (self.nb_of_inputs - 1) / 2

        self.methods_mapping = {}
        self.files_mapping = {}

        for i in range(self.nb_of_files):
            pattern_input_number = i + 1
            filename_input_number = pattern_input_number + self.nb_of_files
            pattern_input_port = node.get_input_port(pattern_input_number)
            name = pattern_input_port['name']
            self.methods_mapping[pattern_input_number] = {}

            def pattern_changed(self, pattern_input_number):
                pattern = self.files_mapping[pattern_input_number][
                    'pattern_lineedit'].text()
                self.files_mapping[pattern_input_number][
                    'pattern_lineedit_cursorPosition'] = self.files_mapping[
                        pattern_input_number][
                            'pattern_lineedit'].cursorPosition()
                self.node.set_input(pattern_input_number, str(pattern))

            self.methods_mapping[pattern_input_number][
                'pattern_changed'] = pattern_changed

            def filename_changed(self, pattern_input_number):
                filename_input_number = pattern_input_number + self.nb_of_files
                filename = self.files_mapping[pattern_input_number][
                    'filenames_combobox'].currentText()
                self.node.set_input(filename_input_number, str(filename))

            self.methods_mapping[pattern_input_number][
                'filename_changed'] = filename_changed

            @lock_notify
            def update_pattern_input(self, pattern_input_number):
                pattern = self.node.get_input(pattern_input_number)
                if self.updating or pattern is None: return
                self.updating = True
                self.files_mapping[pattern_input_number][
                    'pattern_lineedit'].setText(pattern)
                self.updating = False

            self.methods_mapping[pattern_input_number][
                'update_pattern_input'] = update_pattern_input

            @lock_notify
            def update_filenames_combobox(self, pattern_input_number):
                package_name = self.node.get_input(0)
                pattern = self.node.get_input(pattern_input_number)
                if package_name is None or pattern is None: return
                directory_path = path.path(node._pd([package_name])[0])
                if self.updating: return
                self.updating = True
                self.files_mapping[pattern_input_number][
                    'filenames_combobox'].clear()
                self.files_mapping[pattern_input_number][
                    'filename2filepath_mapping'].clear()
                if directory_path.isdir():
                    paths = directory_path.glob(pattern)
                else:
                    paths = []
                filenames = [a_path.name for a_path in paths]
                self.files_mapping[pattern_input_number]['filename2filepath_mapping']\
                    .update(dict(zip(filenames, paths)))
                self.files_mapping[pattern_input_number]['filenames_combobox']\
                    .addItems(self.files_mapping[pattern_input_number]['filename2filepath_mapping'].keys())
                self.updating = False
            self.methods_mapping[pattern_input_number]['update_filenames_combobox'] \
                = update_filenames_combobox

            @lock_notify
            def update_filepath_output(self, pattern_input_number):
                output_filepath = None
                package_name = self.node.get_input(0)
                filename_input_number = pattern_input_number + self.nb_of_files
                input_filename = self.node.get_input(filename_input_number)
                if package_name is None or input_filename is None: return
                if self.updating: return
                self.updating = True
                input_filename_index = \
                    self.files_mapping[pattern_input_number]['filenames_combobox']\
                        .findText(input_filename)
                self.files_mapping[pattern_input_number]['filenames_combobox']\
                    .setCurrentIndex(input_filename_index)
                output_filepath = \
                    self.files_mapping[pattern_input_number]['filename2filepath_mapping']\
                        .get(input_filename)
                self.node.set_output(i, output_filepath)
                self.updating = False
            self.methods_mapping[pattern_input_number]['update_filepath_output'] \
                = update_filepath_output

            self.files_mapping[pattern_input_number] = {}
            self.files_mapping[pattern_input_number]['label'] = QLabel(
                name, self)
            self.gridlayout.addWidget(
                self.files_mapping[pattern_input_number]['label'], i + 2, 0)
            self.files_mapping[pattern_input_number][
                'pattern_lineedit'] = QLineEdit(self)
            self.files_mapping[pattern_input_number][
                'pattern_lineedit_cursorPosition'] = self.files_mapping[
                    pattern_input_number]['pattern_lineedit'].cursorPosition()
            self.gridlayout.addWidget(
                self.files_mapping[pattern_input_number]['pattern_lineedit'],
                i + 2, 1, 1, 2)
            self.pattern_lineedit_signal_mapper = QSignalMapper(self)
            self.connect(
                self.files_mapping[pattern_input_number]['pattern_lineedit'],
                SIGNAL("textChanged(QString)"),
                self.pattern_lineedit_signal_mapper, SLOT("map()"))
            self.pattern_lineedit_signal_mapper.setMapping(
                self.files_mapping[pattern_input_number]['pattern_lineedit'],
                pattern_input_number)
            self.connect(self.pattern_lineedit_signal_mapper,
                         SIGNAL("mapped(int)"), self.map_to_pattern_method)
            self.files_mapping[pattern_input_number][
                'filenames_combobox'] = QComboBox(self)
            self.gridlayout.addWidget(
                self.files_mapping[pattern_input_number]['filenames_combobox'],
                i + 2, 3, 1, 2)
            self.filenames_combobox_signal_mapper = QSignalMapper(self)
            self.connect(
                self.files_mapping[pattern_input_number]['filenames_combobox'],
                SIGNAL("currentIndexChanged(QString)"),
                self.filenames_combobox_signal_mapper, SLOT("map()"))
            self.filenames_combobox_signal_mapper.setMapping(
                self.files_mapping[pattern_input_number]['filenames_combobox'],
                pattern_input_number)
            self.connect(self.filenames_combobox_signal_mapper,
                         SIGNAL("mapped(int)"), self.map_to_filenames_method)
            self.files_mapping[pattern_input_number][
                'filename2filepath_mapping'] = {}

        self.setWindowTitle("select_multiple_files")
        self.setGeometry(250, 200, 350, 550)
        self.updating = False

        self.notify(node, ("input_modified", 'all'))
        self.notify(node, ("caption_modified", node.get_caption()))
    def __init__(self, node, parent):
        """
        @param node
        @param parent
        """
        QtGui.QWidget.__init__(self, parent)
        NodeWidget.__init__(self, node)

        # -- imitate DefaultNodeWidget : refactor DefaultNodeWidget??? --
        # this is because we reuse the same code from DefaultNodeWidget
        # to build the UI.
        self.widgets = []
        self.empty   = True
        # -- end of imitate DefaultNodeWidget --

        # -- own custom layout
        self.setMinimumSize(100, 20)
        # self.setSizePolicy(QtGui.QSizePolicy.Preferred,
        #                    QtGui.QSizePolicy.Preferred)
        self._mainLayout = QtGui.QVBoxLayout(self)
        self._mainLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
        self._mainLayout.setContentsMargins(3, 3, 3, 3)
        self._mainLayout.setSpacing(2)

        # -- the method name selection group box -- #
        self.__methodGBox = QtGui.QGroupBox("Method to wrap")
        # self.__methodGBox.setSizePolicy(QtGui.QSizePolicy.Preferred,
        #                                 QtGui.QSizePolicy.Preferred)
        self._mainLayout.addWidget(self.__methodGBox, 0, QtCore.Qt.AlignTop)

        methNameLayout = QtGui.QHBoxLayout()
        methNameLayout.setContentsMargins(3, 3, 3, 3)
        methNameLayout.setSpacing(2)

        methNameLabel  = QtGui.QLabel("Method name:")
        self.__methodComboBox = QtGui.QComboBox()
        self.__lockChoice     = QtGui.QPushButton()
        style = QtGui.QApplication.style()
        self.__lockChoice.setCheckable(True)
        self.__lockChoice.setIcon(style.standardIcon(QtGui.QStyle.SP_DialogApplyButton))
        self.__lockChoice.toggled.connect(self._methodChosen)
        methNameLayout.addWidget(methNameLabel, 0, QtCore.Qt.AlignLeft)
        methNameLayout.addWidget(self.__methodComboBox)
        methNameLayout.addWidget(self.__lockChoice, 0, QtCore.Qt.AlignLeft)

        self.__methodGBox.setLayout(methNameLayout)

        # -- The method's inputs widget --
        self.__vboxlayout = QtGui.QVBoxLayout()
        self._mainLayout.addLayout(self.__vboxlayout, 0)

        # -- map between string and combobox index --
        self.map_index = {}

        # -- initialisation --
        self.notify(node, ("input_modified", 0))
        self.__isInit =True
        toggled = bool(self.node.internal_data["methodName"] and
                       self.node.internal_data["methodSig"])
        self.__lockChoice.setChecked(toggled)
        self.__isInit =False
    def __init__(self, node, parent=None, autonomous=False):

        qt.QtGui.QWidget.__init__(self, parent)
        NodeWidget.__init__(self, node)

        vboxlayout = qt.QtGui.QVBoxLayout(self)
        self.vboxlayout = vboxlayout

        self.node = node

        # Container
        self.container = qt.QtGui.QTabWidget(self)
        vboxlayout.addWidget(self.container)


        if(autonomous):
            self.set_autonomous()
            return

        # empty_io is a flag to define if the composite widget add only io widgets

        # Trey to create a standard node widget for inputs
        default_widget = DefaultNodeWidget(node, parent)

        if(default_widget.is_empty()):
            default_widget.close()
            default_widget.destroy()
            del default_widget
            empty_io = True

        else:
            empty_io = False
            self.container.addTab(default_widget, "Inputs")


        # Add subwidgets (Need to sort widget)
        for id in node.vertices():

            subnode = node.node(id)

            # Do not display widget if hidden
            hide = subnode.internal_data.get('hide', False)
            user_app = subnode.internal_data.get('user_application', False)
            if(hide and not empty_io): continue

            if(not user_app):
                # ignore node with all input connected
                states = [ bool(subnode.get_input_state(p)=="connected")
                           for p in xrange(subnode.get_nb_input())]

                if(all(states)): continue

            # Add tab
            try:
                factory = subnode.get_factory()
                widget = factory.instantiate_widget(subnode, self)
                assert widget
            except:
                continue

            if(widget.is_empty()) :
                widget.close()
                del widget
            else :
                # Add as tab
                caption = "%s"%(subnode.caption)
                self.container.addTab(widget, caption)
Example #25
0
    def __init__(self, node, parent):

        QDialog.__init__(self, parent)
        NodeWidget.__init__(self, node)
        
        self.gridlayout = QGridLayout(self)
        self.gridlayout.setMargin(3)
        self.gridlayout.setSpacing(5)

        self.package_lineedit_label = QLabel('1. Set the package', self)
        self.gridlayout.addWidget(self.package_lineedit_label, 0, 0)
        
        self.package_lineedit = QLineEdit(self)
        self.cursorPosition_package_lineedit = self.package_lineedit.cursorPosition()
        self.gridlayout.addWidget(self.package_lineedit, 0, 1, 1, 4)
        self.connect(self.package_lineedit, 
                     SIGNAL("textChanged(QString)"), 
                     self.package_changed)

        self.select_files_label = QLabel('2. Set the patterns and select the \
files', self)
        self.gridlayout.addWidget(self.select_files_label, 1, 0, 1, 4)

        self.nb_of_inputs = node.get_nb_input()
        self.nb_of_files = (self.nb_of_inputs - 1) / 2
        
        self.methods_mapping = {}
        self.files_mapping = {}
        
        for i in range(self.nb_of_files):
            pattern_input_number = i + 1
            filename_input_number = pattern_input_number + self.nb_of_files
            pattern_input_port = node.get_input_port(pattern_input_number)
            name = pattern_input_port['name']
            self.methods_mapping[pattern_input_number] = {}
            def pattern_changed(self, pattern_input_number):
                pattern = self.files_mapping[pattern_input_number]['pattern_lineedit'].text()
                self.files_mapping[pattern_input_number]['pattern_lineedit_cursorPosition'] = self.files_mapping[pattern_input_number]['pattern_lineedit'].cursorPosition()
                self.node.set_input(pattern_input_number, str(pattern))
            self.methods_mapping[pattern_input_number]['pattern_changed'] = pattern_changed
            def filename_changed(self, pattern_input_number):
                filename_input_number = pattern_input_number + self.nb_of_files
                filename = self.files_mapping[pattern_input_number]['filenames_combobox'].currentText()
                self.node.set_input(filename_input_number, str(filename))
            self.methods_mapping[pattern_input_number]['filename_changed'] = filename_changed
            @lock_notify
            def update_pattern_input(self, pattern_input_number):
                pattern = self.node.get_input(pattern_input_number)
                if self.updating or pattern is None: return
                self.updating = True
                self.files_mapping[pattern_input_number]['pattern_lineedit'].setText(pattern)
                self.updating = False
            self.methods_mapping[pattern_input_number]['update_pattern_input'] = update_pattern_input
            @lock_notify
            def update_filenames_combobox(self, pattern_input_number):
                package_name = self.node.get_input(0)
                pattern = self.node.get_input(pattern_input_number)
                if package_name is None or pattern is None: return
                directory_path = path.path(node._pd([package_name])[0])
                if self.updating: return
                self.updating = True
                self.files_mapping[pattern_input_number]['filenames_combobox'].clear()
                self.files_mapping[pattern_input_number]['filename2filepath_mapping'].clear()
                if directory_path.isdir():
                    paths = directory_path.glob(pattern)
                else:
                    paths = []
                filenames = [a_path.name for a_path in paths]        
                self.files_mapping[pattern_input_number]['filename2filepath_mapping']\
                    .update(dict(zip(filenames, paths)))
                self.files_mapping[pattern_input_number]['filenames_combobox']\
                    .addItems(self.files_mapping[pattern_input_number]['filename2filepath_mapping'].keys())
                self.updating = False
            self.methods_mapping[pattern_input_number]['update_filenames_combobox'] \
                = update_filenames_combobox    
            @lock_notify
            def update_filepath_output(self, pattern_input_number):
                output_filepath = None
                package_name = self.node.get_input(0)
                filename_input_number = pattern_input_number + self.nb_of_files
                input_filename = self.node.get_input(filename_input_number)
                if package_name is None or input_filename is None: return
                if self.updating: return
                self.updating = True
                input_filename_index = \
                    self.files_mapping[pattern_input_number]['filenames_combobox']\
                        .findText(input_filename)
                self.files_mapping[pattern_input_number]['filenames_combobox']\
                    .setCurrentIndex(input_filename_index)
                output_filepath = \
                    self.files_mapping[pattern_input_number]['filename2filepath_mapping']\
                        .get(input_filename)
                self.node.set_output(i, output_filepath)
                self.updating = False
            self.methods_mapping[pattern_input_number]['update_filepath_output'] \
                = update_filepath_output
 
            self.files_mapping[pattern_input_number] = {}
            self.files_mapping[pattern_input_number]['label'] = QLabel(name, self)
            self.gridlayout.addWidget(self.files_mapping[pattern_input_number]['label'], i+2, 0)
            self.files_mapping[pattern_input_number]['pattern_lineedit'] = QLineEdit(self)
            self.files_mapping[pattern_input_number]['pattern_lineedit_cursorPosition'] = self.files_mapping[pattern_input_number]['pattern_lineedit'].cursorPosition()
            self.gridlayout.addWidget(self.files_mapping[pattern_input_number]['pattern_lineedit'], i+2, 1, 1, 2)
            self.pattern_lineedit_signal_mapper = QSignalMapper(self)
            self.connect(self.files_mapping[pattern_input_number]['pattern_lineedit'], 
                         SIGNAL("textChanged(QString)"), 
                         self.pattern_lineedit_signal_mapper,
                         SLOT("map()"))
            self.pattern_lineedit_signal_mapper.setMapping(self.files_mapping[pattern_input_number]['pattern_lineedit'], 
                                          pattern_input_number);
            self.connect(self.pattern_lineedit_signal_mapper, 
                         SIGNAL("mapped(int)"), 
                         self.map_to_pattern_method)
            self.files_mapping[pattern_input_number]['filenames_combobox'] = QComboBox(self)
            self.gridlayout.addWidget(self.files_mapping[pattern_input_number]['filenames_combobox'], i+2, 3, 1, 2)
            self.filenames_combobox_signal_mapper = QSignalMapper(self)
            self.connect(self.files_mapping[pattern_input_number]['filenames_combobox'], 
                         SIGNAL("currentIndexChanged(QString)"), 
                         self.filenames_combobox_signal_mapper,
                         SLOT("map()"))
            self.filenames_combobox_signal_mapper.setMapping(self.files_mapping[pattern_input_number]['filenames_combobox'], 
                                          pattern_input_number);
            self.connect(self.filenames_combobox_signal_mapper, 
                         SIGNAL("mapped(int)"), 
                         self.map_to_filenames_method)
            self.files_mapping[pattern_input_number]['filename2filepath_mapping'] = {}
        
        self.setWindowTitle("select_multiple_files")
        self.setGeometry(250, 200, 350, 550)
        self.updating = False

        self.notify(node, ("input_modified", 'all'))
        self.notify(node, ("caption_modified", node.get_caption()))
Example #26
0
        def __init__(self, node, parent):

            LPyWindow.__init__(self, parent)
            NodeWidget.__init__(self, node)
            QtCore.QObject.connect(self.codeeditor,QtCore.SIGNAL('textChanged()'),self.updateNode)
    def __init__(self, node, parent):
        """
        @param node
        @param parent
        """
        QtGui.QWidget.__init__(self, parent)
        NodeWidget.__init__(self, node)

        # -- imitate DefaultNodeWidget : refactor DefaultNodeWidget??? --
        # this is because we reuse the same code from DefaultNodeWidget
        # to build the UI.
        self.widgets = []
        self.empty = True
        # -- end of imitate DefaultNodeWidget --

        # -- own custom layout
        self.setMinimumSize(100, 20)
        # self.setSizePolicy(QtGui.QSizePolicy.Preferred,
        #                    QtGui.QSizePolicy.Preferred)
        self._mainLayout = QtGui.QVBoxLayout(self)
        self._mainLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
        self._mainLayout.setContentsMargins(3, 3, 3, 3)
        self._mainLayout.setSpacing(2)

        # -- the method name selection group box -- #
        self.__methodGBox = QtGui.QGroupBox("Method to wrap")
        # self.__methodGBox.setSizePolicy(QtGui.QSizePolicy.Preferred,
        #                                 QtGui.QSizePolicy.Preferred)
        self._mainLayout.addWidget(self.__methodGBox, 0, QtCore.Qt.AlignTop)

        methNameLayout = QtGui.QHBoxLayout()
        methNameLayout.setContentsMargins(3, 3, 3, 3)
        methNameLayout.setSpacing(2)

        methNameLabel = QtGui.QLabel("Method name:")
        self.__methodComboBox = QtGui.QComboBox()
        self.__lockChoice = QtGui.QPushButton()
        style = QtGui.QApplication.style()
        self.__lockChoice.setCheckable(True)
        self.__lockChoice.setIcon(
            style.standardIcon(QtGui.QStyle.SP_DialogApplyButton))
        self.__lockChoice.toggled.connect(self._methodChosen)
        methNameLayout.addWidget(methNameLabel, 0, QtCore.Qt.AlignLeft)
        methNameLayout.addWidget(self.__methodComboBox)
        methNameLayout.addWidget(self.__lockChoice, 0, QtCore.Qt.AlignLeft)

        self.__methodGBox.setLayout(methNameLayout)

        # -- The method's inputs widget --
        self.__vboxlayout = QtGui.QVBoxLayout()
        self._mainLayout.addLayout(self.__vboxlayout, 0)

        # -- map between string and combobox index --
        self.map_index = {}

        # -- initialisation --
        self.notify(node, ("input_modified", 0))
        self.__isInit = True
        toggled = bool(self.node.internal_data["methodName"]
                       and self.node.internal_data["methodSig"])
        self.__lockChoice.setChecked(toggled)
        self.__isInit = False