def __init__(self, parent):
    self.vLayout = qt.QVBoxLayout(parent)
    self.formLayout = qt.QFormLayout()

    self.componentName = qt.QLineEdit()
    self.formLayout.addRow("Name:", self.componentName)

    self.componentNameValidator = qt.QRegExpValidator(
        qt.QRegExp(r"^[a-zA-Z_][a-zA-Z0-9_]*$"))
    self.componentName.setValidator(self.componentNameValidator)

    self.componentType = qt.QComboBox()
    self.formLayout.addRow("Type:", self.componentType)

    self.destination = ctk.ctkPathLineEdit()
    self.destination.filters = ctk.ctkPathLineEdit.Dirs
    self.formLayout.addRow("Destination:", self.destination)

    self.vLayout.addLayout(self.formLayout)
    self.vLayout.addStretch(1)

    self.buttonBox = qt.QDialogButtonBox()
    self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok |
                                      qt.QDialogButtonBox.Cancel)
    self.vLayout.addWidget(self.buttonBox)
Beispiel #2
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = CartoExportLogic()

        frame = qt.QFrame()
        lay = qt.QFormLayout()
        frame.setLayout(lay)
        self.layout.addWidget(frame)

        self.vtkModelSelector = slicer.qMRMLNodeComboBox()
        self.vtkModelSelector.nodeTypes = ["vtkMRMLModelNode"]
        self.vtkModelSelector.noneEnabled = True
        self.vtkModelSelector.renameEnabled = True
        self.vtkModelSelector.setMRMLScene(slicer.mrmlScene)
        self.vtkModelSelector.setToolTip(
            "VTK model node that needs to be converted")

        self.firstNameLineEdit = qt.QLineEdit(self.logic.FIRST)
        self.lastNameLineEdit = qt.QLineEdit(self.logic.LAST)
        self.mrnLineEdit = qt.QLineEdit(self.logic.ID)
        self.mrnLineEdit.setValidator(
            qt.QRegExpValidator(qt.QRegExp("[0-9]*"), self.mrnLineEdit))
        self.exportButton = qt.QPushButton("Export ...")
        self.exportButton.enabled = False

        lay.addRow("VTK Model Node:", self.vtkModelSelector)
        lay.addRow("First name:", self.firstNameLineEdit)
        lay.addRow("Last name:", self.lastNameLineEdit)
        lay.addRow("MRN:", self.mrnLineEdit)
        lay.addWidget(self.exportButton)

        self.vtkModelSelector.connect("currentNodeChanged(vtkMRMLNode*)",
                                      self.onCurrentModelNodeChanged)
        self.exportButton.clicked.connect(self.onSaveClicked)
        self.firstNameLineEdit.editingFinished.connect(
            lambda: setattr(self.logic, "FIRST", self.firstNameLineEdit.text))
        self.lastNameLineEdit.editingFinished.connect(
            lambda: setattr(self.logic, "LAST", self.lastNameLineEdit.text))
        self.mrnLineEdit.editingFinished.connect(
            lambda: setattr(self.logic, "ID", self.mrnLineEdit.text))

        self.layout.addStretch(1)

        self.onCurrentModelNodeChanged(self.vtkModelSelector.currentNode())