def __init__(self, parent): vLayout = qt.QVBoxLayout(parent) formLayout = qt.QFormLayout() self.nameEdit = qt.QLineEdit() formLayout.addRow("Name:", self.nameEdit) self.categoryEdit = qt.QLineEdit() formLayout.addRow("Category:", self.categoryEdit) self.descriptionEdit = qt.QTextEdit() self.descriptionEdit.acceptRichText = False formLayout.addRow("Description:", self.descriptionEdit) self.contributorsList = EditableTreeWidget() self.contributorsList.rootIsDecorated = False self.contributorsList.selectionBehavior = qt.QAbstractItemView.SelectRows self.contributorsList.selectionMode = qt.QAbstractItemView.ExtendedSelection self.contributorsList.setHeaderLabels(["Name", "Organization"]) formLayout.addRow("Contributors:", self.contributorsList) vLayout.addLayout(formLayout) vLayout.addStretch(1) self.buttonBox = qt.QDialogButtonBox() self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok | qt.QDialogButtonBox.Cancel) vLayout.addWidget(self.buttonBox)
def __init__(self, parent): vBoxLayout = qt.QVBoxLayout(parent) aiaaGroupBox = ctk.ctkCollapsibleGroupBox() aiaaGroupBox.title = 'AI-Assisted Annotation Server' aiaaGroupLayout = qt.QFormLayout(aiaaGroupBox) serverUrl = qt.QLineEdit() aiaaGroupLayout.addRow('Server address:', serverUrl) parent.registerProperty('NVIDIA-AIAA/serverUrl', serverUrl, 'text', str(qt.SIGNAL('textChanged(QString)'))) serverUrlHistory = qt.QLineEdit() aiaaGroupLayout.addRow('Server address history:', serverUrlHistory) parent.registerProperty('NVIDIA-AIAA/serverUrlHistory', serverUrlHistory, 'text', str(qt.SIGNAL('textChanged(QString)'))) compressDataCheckBox = qt.QCheckBox() compressDataCheckBox.checked = True compressDataCheckBox.toolTip = 'Enable this option on computer with slow network upload speed. Data compression reduces network transfer time but increases preprocessing time.' aiaaGroupLayout.addRow('Compress data:', compressDataCheckBox) compressDataMapper = ctk.ctkBooleanMapper( compressDataCheckBox, 'checked', str(qt.SIGNAL('toggled(bool)'))) parent.registerProperty('NVIDIA-AIAA/compressData', compressDataMapper, 'valueAsInt', str(qt.SIGNAL('valueAsIntChanged(int)'))) vBoxLayout.addWidget(aiaaGroupBox) vBoxLayout.addStretch(1)
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("New Package Priority")) self._window.setModal(True) #self._window.setMinimumSize(600, 400) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() table = qt.QGrid(2, vbox) table.setSpacing(10) table.show() label = qt.QLabel(_("Package Name:"), table) self._name = qt.QLineEdit(table) self._name.show() label = qt.QLabel(_("Channel Alias:"), table) self._alias = qt.QLineEdit(table) self._alias.setText("*") self._alias.show() label = qt.QLabel(_("Priority:"), table) self._priority = qt.QSpinBox(table) self._priority.setSteps(1, 10) self._priority.setRange(-100000,+100000) self._priority.show() sep = qt.QFrame(vbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(_("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) button = qt.QPushButton(_("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button.setDefault(True) vbox.adjustSize() self._window.adjustSize()
def __init__(self, parent, rcPath): vBoxLayout = qt.QVBoxLayout(parent) # Add generic settings genericGroupBox = ctk.ctkCollapsibleGroupBox() genericGroupBox.title = "Generic SlicerMorph settings" genericGroupBoxFormLayout = qt.QFormLayout(genericGroupBox) self.loadMorphPreferencesCheckBox = qt.QCheckBox() self.loadMorphPreferencesCheckBox.toolTip = ( "Customize SlicerMorph features such as hotkeys at startup" " (file can be customized in python for advanced users).", " Restart the app for changes to take effect.") toBool = slicer.util.toBool key = "MorphPreferences/customize" customize = slicer.util.settingsValue(key, False, converter=toBool) self.loadMorphPreferencesCheckBox.checked = customize genericGroupBoxFormLayout.addRow("Use SlicerMorph customizations:", self.loadMorphPreferencesCheckBox) hbox = qt.QHBoxLayout() label = qt.QLineEdit(rcPath) label.readOnly = True genericGroupBoxFormLayout.addRow("Customization file:", label) loadNowButton = qt.QPushButton("Load now") loadNowButton.toolTip = "Load the customization file now" hbox.addWidget(label) hbox.addWidget(loadNowButton) genericGroupBoxFormLayout.addRow("Customization file:", hbox) loadNowButton.connect( "clicked()", lambda rcPath=rcPath: MorphPreferences.loadRCFile(rcPath)) self.loadMorphPreferencesCheckBox.connect( "toggled(bool)", self.onLoadMorphPreferencesCheckBoxToggled) hbox = qt.QHBoxLayout() self.downloadDirectory = qt.QLineEdit() self.downloadDirectory.readOnly = True key = "MorphPreferences/downloadDirectory" downloadDirectory = slicer.util.settingsValue(key, "", converter=str) if downloadDirectory == "": self.downloadDirectory.setText("Defaults") else: self.downloadDirectory.setText(downloadDirectory) self.setDownloadDirectories(downloadDirectory) self.setDownloadDirectoryButton = qt.QPushButton("Set") self.setDownloadDirectoryButton.connect("clicked()", self.onSetDownloadDirectory) hbox.addWidget(self.downloadDirectory) hbox.addWidget(self.setDownloadDirectoryButton) genericGroupBoxFormLayout.addRow("Download directory:", hbox) vBoxLayout.addWidget(genericGroupBox) vBoxLayout.addStretch(1)
def open(self): self.studyLabel = qt.QLabel('Send %d items to destination' % len(self.files)) self.layout().addWidget(self.studyLabel) # Send Parameters self.dicomFrame = qt.QFrame(self) self.dicomFormLayout = qt.QFormLayout() self.dicomFrame.setLayout(self.dicomFormLayout) self.settings = qt.QSettings() self.protocolSelectorCombobox = qt.QComboBox() self.protocolSelectorCombobox.addItems(["DIMSE", "DICOMweb"]) self.protocolSelectorCombobox.setCurrentText( self.settings.value('DICOM/Send/Protocol', 'DIMSE')) self.protocolSelectorCombobox.currentIndexChanged.connect( self.onProtocolSelectorChange) self.dicomFormLayout.addRow("Protocol: ", self.protocolSelectorCombobox) self.serverAETitleEdit = qt.QLineEdit() self.serverAETitleEdit.setToolTip("AE Title") self.serverAETitleEdit.text = self.settings.value( 'DICOM/Send/AETitle', 'CTK') self.dicomFormLayout.addRow("AE Title: ", self.serverAETitleEdit) # Enable AET only for DIMSE self.serverAETitleEdit.enabled = self.protocolSelectorCombobox.currentText == 'DIMSE' self.serverAddressLineEdit = qt.QLineEdit() self.serverAddressLineEdit.setToolTip( "Address includes hostname and port number in standard URL format (hostname:port)." ) self.serverAddressLineEdit.text = self.settings.value( 'DICOM/Send/URL', '') self.dicomFormLayout.addRow("Destination Address: ", self.serverAddressLineEdit) self.layout().addWidget(self.dicomFrame) # button box self.bbox = qt.QDialogButtonBox(self) self.bbox.addButton(self.bbox.Ok) self.bbox.addButton(self.bbox.Cancel) self.bbox.accepted.connect(self.onOk) self.bbox.rejected.connect(self.onCancel) self.layout().addWidget(self.bbox) self.progressBar = qt.QProgressBar(self.parent().window()) self.progressBar.hide() self.dicomFormLayout.addRow(self.progressBar) qt.QDialog.open(self)
def __init__(self, *args): BlissWidget.__init__(self, *args) self.addProperty("mnemonic", "string", "") self.addProperty("icons", "string", "") self.addProperty("formatString", "formatString", "###.##") self.beamstop_hwobj = None self.top_gbox = qt.QHGroupBox("Beamstop distance", self) self.top_gbox.setInsideMargin(4) self.top_gbox.setInsideSpacing(2) self.params_widget = qt.QWidget(self.top_gbox) qt.QGridLayout(self.params_widget, 2, 3, 0, 2) label1 = qt.QLabel("Current:", self.params_widget) label1.setFixedWidth(70) self.params_widget.layout().addWidget(label1, 0, 0) self.current_position_ledit = qt.QLineEdit(self.params_widget) self.current_position_ledit.setReadOnly(True) self.params_widget.layout().addWidget(self.current_position_ledit, 0, 1) label2 = qt.QLabel("Set to:", self.params_widget) label2.setFixedWidth(70) self.params_widget.layout().addWidget(label2, 1, 0) self.new_position_ledit = qt.QLineEdit(self.params_widget) self.new_position_ledit.setAlignment(qt.QWidget.AlignRight) self.params_widget.layout().addWidget(self.new_position_ledit, 1, 1) self.new_position_ledit.setValidator(qt.QDoubleValidator(self)) self.new_position_ledit.setPaletteBackgroundColor( BeamstopDistanceBrick.CONNECTED_COLOR) qt.QObject.connect(self.new_position_ledit, qt.SIGNAL("returnPressed()"), self.change_position) qt.QObject.connect( self.new_position_ledit, qt.SIGNAL("textChanged(const QString &)"), self.input_field_changed, ) self.instanceSynchronize("new_position_ledit") qt.QVBoxLayout(self) self.layout().addWidget(self.top_gbox)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # a text input field for the input of patient's path. get path with self.displayText # self.pathListInputBox = qt.QLineEdit() parametersFormLayout.addRow("Patient Paths", self.pathListInputBox) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) # Add vertical spacer self.layout.addStretch(1)
def createReadOnlyLineEdit(): le = qt.QLineEdit() le.readOnly = True le.frame = False le.styleSheet = "QLineEdit { background:transparent; }" le.cursor = qt.QCursor(qt.Qt.IBeamCursor) return le
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)
def setup(self): scale = self.getDefaultValue('scales') scales = 1 - scale, 1 + scale self.scalesSlider = self.makeRangeWidget(0.5, *scales, 2, 0.01, 'scales') self.layout.addRow('Scales: ', self.scalesSlider) degrees = self.getDefaultValue('degrees') self.degreesSlider = self.makeRangeWidget(-180, -degrees, degrees, 180, 1, 'degrees') self.layout.addRow('Degrees: ', self.degreesSlider) translation = self.getDefaultValue('translation') self.translationSlider = self.makeRangeWidget(-50, -translation, translation, 50, 0.5, 'translation') self.layout.addRow('Translation: ', self.translationSlider) self.interpolationComboBox = self.makeInterpolationComboBox() self.layout.addRow('Interpolation: ', self.interpolationComboBox) self.isotropicCheckBox = qt.QCheckBox('Isotropic') self.layout.addWidget(self.isotropicCheckBox) arg = 'default_pad_value' self.padLineEdit = qt.QLineEdit(self.getDefaultValue(arg)) self.padLineEdit.setToolTip(self.getArgDocstring(arg)) self.layout.addRow('Padding: ', self.padLineEdit)
def open(self): self.studyLabel = qt.QLabel('Send %d items to destination' % len(self.files)) self.layout().addWidget(self.studyLabel) # Send Parameters self.dicomFrame = qt.QFrame(self) self.dicomFormLayout = qt.QFormLayout() self.dicomFrame.setLayout(self.dicomFormLayout) self.dicomEntries = {} self.dicomParameters = { "Destination Address": self.sendAddress, "Destination Port": self.sendPort } for label in self.dicomParameters.keys(): self.dicomEntries[label] = qt.QLineEdit() self.dicomEntries[label].text = self.dicomParameters[label] self.dicomFormLayout.addRow(label + ": ", self.dicomEntries[label]) self.layout().addWidget(self.dicomFrame) # button box bbox = qt.QDialogButtonBox(self) bbox.addButton(bbox.Ok) bbox.addButton(bbox.Cancel) bbox.accepted.connect(self.onOk) bbox.rejected.connect(self.onCancel) self.layout().addWidget(bbox) qt.QDialog.open(self)
def __init__(self, parent, title, editable=True, orientation=Horizontal): qt.QWidget.__init__(self, parent) self.title = title self.orientation = orientation self.editable = editable if self.orientation == QubValue.Horizontal: self.layout = qt.QHBoxLayout(self) else: self.layout = qt.QVBoxLayout(self) self.titleWidget = qt.QLabel(title, self) self.layout.addWidget(self.titleWidget) self.layout.addSpacing(5) if self.editable: self.valueWidget = qt.QLineEdit(self) self.connect(self.valueWidget, qt.SIGNAL("returnPressed()"), self.__returnPressed) else: self.valueWidget = qt.QLabel(self) self.valueWidget.setFrameShape(qt.QFrame.Box) self.valueWidget.setFrameShadow(qt.QFrame.Plain) self.layout.addWidget(self.valueWidget)
def _buildLists(self, w): """Create the frame that contains list of files and text entry""" listsFrame = qt.QFrame(w, "listsFrame") listsFrame.setSizePolicy(_ANCHOR) # create the directories and files list frames dirFrame, self._dirList = _getLabeledList(listsFrame, oogui.DIRS_LABEL, self._directorySelected) fileFrame, self._fileList = _getLabeledList(listsFrame, oogui.FILES_LABEL, self._fileSelected) # construct the lists side by side listsBox = qt.QHBoxLayout() listsBox.setSpacing(oogui.BORDER) listsBox.addWidget(dirFrame, 1) listsBox.addWidget(fileFrame, 1) # create a variable to use for filename entry filenameFrame = _getLabeledFrame(listsFrame, oogui.FILENAME_LABEL) self._filename = qt.QLineEdit(filenameFrame, 'filenameEntry') self.connect(self._filename, SIGNAL("returnPressed()"), self._setFile) # put the lists and filename entry frames together vbox = qt.QVBoxLayout(listsFrame) vbox.setSpacing(oogui.BORDER) vbox.addLayout(listsBox, 1) vbox.addWidget(filenameFrame, 0) return listsFrame
def segmentationLayout(self): self.segmentationFrame = qt.QFrame() segmentationFormLayout = qt.QFormLayout(self.segmentationFrame) self.segmentationLabellingMethodComboBox = qt.QComboBox() self.segmentationLabellingMethodComboBox.addItems( ["Unlabelled", "From Segmentation"]) self.labellingMethod = self.segmentationLabellingMethodComboBox.currentText segmentationFormLayout.addWidget( self.segmentationLabellingMethodComboBox) self.segmentationLabelTypeLineEdit = qt.QLineEdit("Label Title") segmentationFormLayout.addWidget(self.segmentationLabelTypeLineEdit) self.segmentationLabelTypeLineEdit.visible = False self.inputSegmentationSelector = qt.QComboBox() self.inputSegmentationSelector.addItems(["Select Input Segmentation"]) segmentationNodes = slicer.util.getNodesByClass( "vtkMRMLSegmentationNode") segmentationNodeNames = [] for segNode in segmentationNodes: segmentationNodeNames.append(segNode.GetName()) self.inputSegmentationSelector.addItems(segmentationNodeNames) segmentationFormLayout.addWidget(self.inputSegmentationSelector) self.inputSegmentationSelector.visible = False self.segmentationLabellingMethodComboBox.connect( 'currentIndexChanged(int)', self.onLabellingMethodSelected)
def open(self): # main dialog self.dialog = qt.QDialog(slicer.util.mainWindow()) self.dialog.setWindowTitle('Send DICOM Study') self.dialog.setWindowModality(1) layout = qt.QVBoxLayout() self.dialog.setLayout(layout) self.studyLabel = qt.QLabel('Send %d items to destination' % len(self.files)) layout.addWidget(self.studyLabel) # Send Parameters self.dicomFrame = qt.QFrame(self.dialog) self.dicomFormLayout = qt.QFormLayout() self.dicomFrame.setLayout(self.dicomFormLayout) self.dicomEntries = {} self.dicomParameters = { "Destination Address": self.sendAddress, "Destination Port": self.sendPort } for label in self.dicomParameters.keys(): self.dicomEntries[label] = qt.QLineEdit() self.dicomEntries[label].text = self.dicomParameters[label] self.dicomFormLayout.addRow(label+": ", self.dicomEntries[label]) layout.addWidget(self.dicomFrame) # button box bbox = qt.QDialogButtonBox(self.dialog) bbox.addButton(bbox.Ok) bbox.addButton(bbox.Cancel) bbox.connect('accepted()', self.onOk) bbox.connect('rejected()', self.onCancel) layout.addWidget(bbox) self.dialog.open()
def onCreatePresetPressed(self): if self.registrationPresetSelector.currentIndex != self.newPresetIndex: return self.newPresetBox = qt.QDialog() self.customPresetLayout = qt.QVBoxLayout() self.addParameterFile() addPresetButton = qt.QPushButton("Add more presets...") addPresetButton.connect("clicked(bool)", self.addParameterFile) self.customPresetLayout.addWidget(addPresetButton) self.newPresetBox.setLayout(self.customPresetLayout) # Add fields to specify descriptions, etc... for that preset (to be included in the XML file) groupBox = qt.QGroupBox() formLayout = qt.QFormLayout() self.contentBox = qt.QLineEdit() formLayout.addRow("Content: ", self.contentBox) self.descriptionBox = qt.QLineEdit() formLayout.addRow("Description: ", self.descriptionBox) self.idBox = qt.QLineEdit() formLayout.addRow("Id: ", self.idBox) self.modalityBox = qt.QLineEdit() formLayout.addRow("Modality: ", self.modalityBox) self.publicationsBox = qt.QPlainTextEdit() formLayout.addRow("Publications: ", self.publicationsBox) groupBox.setLayout(formLayout) self.customPresetLayout.addWidget(groupBox) # Add Ok/Cancel buttons and connect them to the main dialog buttonBox = qt.QDialogButtonBox() buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok | qt.QDialogButtonBox.Cancel) buttonBox.setCenterButtons(True) buttonBox.connect("accepted()", self.newPresetBox.accept) buttonBox.connect("rejected()", self.newPresetBox.reject) self.customPresetLayout.addWidget(buttonBox) response = self.newPresetBox.exec_() if response: self.createPreset()
def __init__(self, parent): vBoxLayout = qt.QVBoxLayout(parent) # AIAA settings aiaaGroupBox = ctk.ctkCollapsibleGroupBox() aiaaGroupBox.title = "AI-Assisted Annotation Server" aiaaGroupLayout = qt.QFormLayout(aiaaGroupBox) serverUrl = qt.QLineEdit() aiaaGroupLayout.addRow("Server address:", serverUrl) parent.registerProperty("NVIDIA-AIAA/serverUrl", serverUrl, "text", str(qt.SIGNAL("textChanged(QString)"))) serverUrlHistory = qt.QLineEdit() aiaaGroupLayout.addRow("Server address history:", serverUrlHistory) parent.registerProperty("NVIDIA-AIAA/serverUrlHistory", serverUrlHistory, "text", str(qt.SIGNAL("textChanged(QString)"))) compressDataCheckBox = qt.QCheckBox() compressDataCheckBox.checked = True compressDataCheckBox.toolTip = ( "Enable this option on computer with slow network upload speed." " Data compression reduces network transfer time but increases preprocessing time." ) aiaaGroupLayout.addRow("Compress data:", compressDataCheckBox) compressDataMapper = ctk.ctkBooleanMapper( compressDataCheckBox, "checked", str(qt.SIGNAL("toggled(bool)"))) parent.registerProperty("NVIDIA-AIAA/compressData", compressDataMapper, "valueAsInt", str(qt.SIGNAL("valueAsIntChanged(int)"))) useSessionCheckBox = qt.QCheckBox() useSessionCheckBox.checked = False useSessionCheckBox.toolTip = ( "Enable this option to make use of AIAA sessions." " Volume is uploaded to AIAA as part of session once and it makes segmentation/dextr3d/deepgrow operations faster." ) aiaaGroupLayout.addRow("AIAA Session:", useSessionCheckBox) useSessionMapper = ctk.ctkBooleanMapper( useSessionCheckBox, "checked", str(qt.SIGNAL("toggled(bool)"))) parent.registerProperty("NVIDIA-AIAA/aiaaSession", useSessionMapper, "valueAsInt", str(qt.SIGNAL("valueAsIntChanged(int)"))) vBoxLayout.addWidget(aiaaGroupBox) vBoxLayout.addStretch(1)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Input Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Input URL # self.InputURLText = qt.QLineEdit() self.InputURLText.setToolTip("Copy and paste the URL in this box") parametersFormLayout.addRow("URL: ", self.InputURLText) # # File Names # self.FileNameText = qt.QLineEdit() self.FileNameText.setToolTip("Enter the file name") parametersFormLayout.addRow("File name: ", self.FileNameText) # # Node Names # self.NodeNameText = qt.QLineEdit() self.NodeNameText.setToolTip("Enter the node names") parametersFormLayout.addRow("Node name: ", self.NodeNameText) # # Import button # self.ImportButton = qt.QPushButton("Import data") self.ImportButton.toolTip = "Import data from URL" self.ImportButton.enabled = False parametersFormLayout.addRow(self.ImportButton) # Connections self.InputURLText.connect('textChanged(const QString &)', self.onEnterURL) self.ImportButton.connect('clicked(bool)', self.onImport)
def add_textbox(default_text, select_function=None): text_box = qt.QLineEdit() text_box.text = default_text if select_function is not None: text_box.connect('textChanged(const QString &)', select_function) return text_box
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())
def __init__(self, infile): qt.QWidget.__init__(self) layout = qt.QGridLayout() # load parameters with open(infile) as f: self.pars = pars = yaml.load(f, Loader=yaml.FullLoader) self.images = ImageContainer(pars) def getOnChanged(idx): def func(vals): self.images.radii[idx] = vals[0] self.images.weights[idx] = vals[1] self.redraw() return func def getEditChanged(cntrl, idx): def func(): text = cntrl.text() try: self.images.scales[idx] = float(text) except ValueError: cntrl.setText(str(self.images.scales[idx])) return self.redraw() return func def getCheck(idx, cntrl): def func(): self.images.scales[idx] = -self.images.scales[idx] cntrl.setText(str(self.images.scales[idx])) self.redraw() return func for i in range(len(self.images.images)): radii = self.images.radii[i] weights = self.images.weights[i] # print('r', radii) # print('w', weights) cntrl = curvecontrol.CurveView([radii, weights]) cntrl.changed.connect( getOnChanged(i) ) layout.addWidget(cntrl, i, 0) l = qt.QLineEdit() l.setText(str(self.images.scales[i])) l.editingFinished.connect( getEditChanged(l, i) ) layout.addWidget(l, i, 1) c = qt.QCheckBox() c.clicked.connect( getCheck(i, l) ) layout.addWidget(c, i, 2) self.setLayout(layout) self.redraw()
def create(self): super(MakeModelEffectOptions, self).create() self.goToModelMaker = qt.QPushButton("Go To Model Maker", self.frame) self.goToModelMaker.setToolTip( "The Model Maker interface contains a whole range of options for building sets of models and controlling the parameters." ) self.frame.layout().addWidget(self.goToModelMaker) self.widgets.append(self.goToModelMaker) self.smooth = qt.QCheckBox("Smooth Model", self.frame) self.smooth.checked = True self.smooth.setToolTip( "When smoothed, the model will look better, but some details of the label map will not be visible on the model. When not smoothed you will see individual voxel boundaries in the model. Smoothing here corresponds to Decimation of 0.25 and Smooting iterations of 10." ) self.frame.layout().addWidget(self.smooth) self.widgets.append(self.smooth) # # model name # self.nameFrame = qt.QFrame(self.frame) self.nameFrame.setLayout(qt.QHBoxLayout()) self.frame.layout().addWidget(self.nameFrame) self.widgets.append(self.nameFrame) self.modelNameLabel = qt.QLabel("Model Name: ", self.nameFrame) self.modelNameLabel.setToolTip( "Select the name for the newly created model.") self.nameFrame.layout().addWidget(self.modelNameLabel) self.widgets.append(self.modelNameLabel) self.modelName = qt.QLineEdit(self.nameFrame) self.modelName.setText(self.getUniqueModelName( EditUtil.getLabelName())) self.nameFrame.layout().addWidget(self.modelName) self.widgets.append(self.modelName) self.apply = qt.QPushButton("Apply", self.frame) self.apply.objectName = self.__class__.__name__ + 'Apply' self.apply.setToolTip( "Build a model for the current label value of the label map being edited in the Red slice window. Model will be created in the background." ) self.frame.layout().addWidget(self.apply) self.widgets.append(self.apply) HelpButton( self.frame, "Use this tool build a model. A subset of model building options is provided here. Go to the Model Maker module to expose a range of parameters. Use Merge and Build button in the Advanced... tab to quickly make a model of all defined structures in the merge label map." ) # Add vertical spacer self.frame.layout().addStretch(1) self.connections.append((self.apply, 'clicked()', self.onApply)) self.connections.append( (self.goToModelMaker, 'clicked()', self.onGoToModelMaker))
def __init__(self, parent=None, name=None, fl=0): CreateTaskBase.__init__(self, parent, name, fl, "XRF-spectrum") self.count_time = None # Data attributes self.init_models() xrfspectrum_model = queue_model_objects.XRFSpectrum() self.xrfspectrum_mib = DataModelInputBinder(xrfspectrum_model) # Layout v_layout = qt.QVBoxLayout(self, 2, 6, "main_v_layout") self._data_path_gbox = qt.QVGroupBox("Data location", self, "data_path_gbox") self._data_path_widget = DataPathWidget( self._data_path_gbox, data_model=self._path_template, layout="vertical" ) parameters_hor_gbox = qt.QHGroupBox("Parameters", self) self.count_time_label = qt.QLabel("Count time", parameters_hor_gbox) self.count_time_label.setFixedWidth(83) self.count_time_ledit = qt.QLineEdit( "1.0", parameters_hor_gbox, "count_time_ledit" ) self.count_time_ledit.setFixedWidth(50) self.xrfspectrum_mib.bind_value_update( "count_time", self.count_time_ledit, float ) # , spacer = qt.QWidget(parameters_hor_gbox) spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed) v_layout.addWidget(self._data_path_gbox) v_layout.addWidget(parameters_hor_gbox) v_layout.addStretch() self.connect( self._data_path_widget.data_path_widget_layout.child("run_number_ledit"), qt.SIGNAL("textChanged(const QString &)"), self._run_number_ledit_change, ) self.connect( self._data_path_widget.data_path_widget_layout.child("prefix_ledit"), qt.SIGNAL("textChanged(const QString &)"), self._prefix_ledit_change, ) self.connect( self._data_path_widget, qt.PYSIGNAL("path_template_changed"), self.handle_path_conflict, )
def onConnectDirectlyButton(self): for elem in self.removeListGuiReset: self.delete_element(elem) self.removeListGuiReset = [] self.urlBoxDirectConnection = qt.QLineEdit() self.urlBoxDirectConnection.text = "http://localhost:9000" self.connectionFormLayout.addRow("Server URL: ", self.urlBoxDirectConnection) self.removeListGuiReset += [self.urlBoxDirectConnection]
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # Select landmark folder to import # self.inputDirectory = ctk.ctkDirectoryButton() self.inputDirectory.directory = qt.QDir.homePath() self.inputDirectory.setToolTip('Select Directory with fcsv lanmark files') parametersFormLayout.addRow("Input Directory:", self.inputDirectory) # # output directory selector # self.outputDirectory = ctk.ctkDirectoryButton() self.outputDirectory.directory = qt.QDir.homePath() parametersFormLayout.addRow("Output Directory:", self.outputDirectory) # # enter filename for output # self.outputFileName = qt.QLineEdit() self.outputFileName.text = "morphoJOutput" parametersFormLayout.addRow("Name of output file:", self.outputFileName) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the compiling." self.applyButton.enabled = False parametersFormLayout.addRow(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onApplyButton) self.inputDirectory.connect('validInputChanged(bool)', self.onSelectInput) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelectInput()
def __init__(self, master, text, length, cmd): self.this = qt.QLineEdit(master.group[-1][0]) if length > 0: fm = self.this.fontMetrics() self.this.setMinimumWidth(length * fm.width('X')) if text != '': text = self.this.setText(text) self.master = master self.code = cmd master.win.connect(self.this, qt.SIGNAL("returnPressed()"), self.dostuff)
def populateColumn(self, colNum, values, colours=None): """Fill values into column, extending if necessary""" if len(values) > self.numRows(): self.setNumRows(len(values)) for rowNum, text in enumerate(values): wdg = qt.QLineEdit(self) wdg.setFont(qt.QFont("Courier")) wdg.setReadOnly(True) wdg.setText(text) if colours: colour = colours[rowNum] if colour: wdg.setPaletteBackgroundColor(getattr(qt.Qt, colour)) self.setCellWidget(rowNum, colNum, wdg)
def createFrameText(self, frameLayout, title, width, tooltip): # TODO: crear validador de entrada a campo para filtrar valores no permitidos pFrameText = qt.QLineEdit() #validator = qt.QIntValidator(1,100,pFrameText); #pFrameText.setValidator(validator); pFrameText.setMaximumWidth(width) #pFrameText.focusPolicy(qt.StrongFocus) pFrameLabel = qt.QLabel(title) pFrameLabel.setMaximumWidth(width) pFrameText.setToolTip(tooltip) pFrameLabel.setToolTip(tooltip) frameLayout.addWidget(pFrameLabel) frameLayout.addWidget(pFrameText) return (pFrameText)
def __init__(self, parent=None): self._window = qt.QDialog(parent) self._window.setIcon(getPixmap("smart")) self._window.setCaption(_("New Target")) self._window.setModal(True) #self._window.setMinimumSize(600, 400) vbox = qt.QVBox(self._window) vbox.setMargin(10) vbox.setSpacing(10) vbox.show() table = qt.QGrid(2, vbox) table.setSpacing(10) table.show() label = qt.QLabel(_("Target:"), table) self._target = qt.QLineEdit(table) self._target.setMaxLength(40) self._target.show() blank = qt.QWidget(table) label = qt.QLabel( _("Examples: \"pkgname\", \"pkgname = 1.0\" or " "\"pkgname <= 1.0\""), table) sep = qt.QFrame(vbox) sep.setFrameShape(qt.QFrame.HLine) sep.setFrameShadow(qt.QFrame.Sunken) sep.show() bbox = qt.QHBox(vbox) bbox.setSpacing(10) bbox.layout().addStretch(1) bbox.show() button = qt.QPushButton(bbox.tr("OK"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("accept()")) button = qt.QPushButton(bbox.tr("Cancel"), bbox) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self._window, qt.SLOT("reject()")) vbox.adjustSize() self._window.adjustSize()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... self.webWidget = None self.logic = MorphoSourceLogic() # Collapsible button self.loginCollapsibleButton = ctk.ctkCollapsibleButton() self.loginCollapsibleButton.text = "MorphoSource Login" self.layout.addWidget(self.loginCollapsibleButton) self.formLayout = qt.QFormLayout(self.loginCollapsibleButton) # # Login info # username, password = self.logic.getLogin() self.username = qt.QLineEdit() self.username.text = username self.formLayout.addRow("Username", self.username) self.password = qt.QLineEdit() self.password.setEchoMode(qt.QLineEdit.Password) self.password.text = password self.formLayout.addRow("Password", self.password) # # Open Button # self.applyButton = qt.QPushButton("Open MorphoSource") self.applyButton.toolTip = "Open the MorphoSource site." self.formLayout.addWidget(self.applyButton) # connections self.applyButton.connect('clicked(bool)', self.onOpen) # Add vertical spacer self.layout.addStretch(1)