def setDetailsPopup(self, detailsPopup): if self.detailsPopup == detailsPopup: return if self.detailsPopup is not None: self.detailsPopup.closed.disconnect(self.onDetailsPopupClosed) oldDetailsPopup = self.detailsPopup self.detailsPopup = detailsPopup self.detailsPopup.setAutoFillBackground(True) self.detailsPopup.closed.connect(self.onDetailsPopupClosed) self.detailsPopup.browserPersistentButton.hide() self.detailsPopup.horizontalViewCheckBox.hide() expandButton = self.detailsPopup.findChild("ctkExpandButton", "") if expandButton is not None: expandButton.hide() if self.viewWidget is None: self.viewWidget = qt.QWidget() self.viewWidget.setAutoFillBackground(True) self.viewFactory.setWidget(self.viewWidget) layout = qt.QVBoxLayout() self.viewWidget.setLayout(layout) label = qt.QLabel("DICOM database") label.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed) layout.addWidget(label) font = qt.QFont() font.setBold(True) font.setPointSize(12) label.setFont(font) elif not oldDetailsPopup is None: self.viewWidget.layout().removeWidget(oldDetailsPopup) self.viewWidget.layout().addWidget(self.detailsPopup)
def __init__(self, *args): qt.QWidget.__init__(self, *args) hSliderLayout = Layout(qt.Qt.Vertical) for i in (0, 1, 2): hSliderLayout.addWidget(Slider(self, i)) hSliderLayout.addStretch() vSliderLayout = Layout(qt.Qt.Horizontal) for i in (3, 4, 5): vSliderLayout.addWidget(Slider(self, i)) vTitle = qt.QLabel("Vertical Sliders", self) vTitle.setFont(qt.QFont("Helvetica", 14, qt.QFont.Bold)) vTitle.setAlignment(qt.Qt.AlignHCenter) layout1 = Layout(qt.Qt.Vertical) layout1.addWidget(vTitle, 0) layout1.addLayout(vSliderLayout, 10) hTitle = qt.QLabel("Horizontal Sliders", self) hTitle.setFont(vTitle.font()) hTitle.setAlignment(qt.Qt.AlignHCenter) layout2 = Layout(qt.Qt.Vertical) layout2.addWidget(hTitle, 0) layout2.addLayout(hSliderLayout, 10) mainLayout = Layout(qt.Qt.Horizontal, self) mainLayout.addLayout(layout1) mainLayout.addLayout(layout2, 10)
def __init__(self, title, main_app, model_controller, plugin_manager): qt.QMainWindow.__init__(self, None, title, qt.Qt.WDestructiveClose) self.setWindowState(qt.Qt.WindowMaximized) self.setCaption(title) self.setIcon( qt.QPixmap(os.path.join(CONF.getIconsPath(), 'faraday_icon.png'))) self._main_app = main_app self._model_controller = model_controller self._mainArea = qt.QHBox(self) self.setCentralWidget(self._mainArea) self._vb_splitter = qt.QSplitter(self._mainArea) self._vb_splitter.setOrientation(qt.QSplitter.Vertical) self._hb_splitter = qt.QSplitter(self._vb_splitter) self._hb_splitter.setOrientation(qt.QSplitter.Horizontal) self.statusBar().setSizeGripEnabled(False) self._shell_widgets = [] self._notifications = [] self._tab_manager = TabManager(self._hb_splitter) self._perspective_manager = PerspectiveManager(self._hb_splitter, self._main_app) self._hosts_treeview = HostsBrowser(self._perspective_manager, self._model_controller, 'Hosts') notifier.registerWidget(self._hosts_treeview) self._perspective_manager.registerPerspective(self._hosts_treeview, default=True) wtw = WorkspaceTreeWindow(self._perspective_manager, 'Workspaces', self._main_app.getWorkspaceManager()) self._perspective_manager.registerPerspective(wtw) self._workspaces_treeview = wtw self._log_console = LogConsole(self._vb_splitter, 'Console') self._actions = dict() self._setupActions() self._menues = {} self._setupMenues() self.main_toolbar = qt.QToolBar(self, 'main toolbar') self._setupMainToolbar() self.location_toolbar = LocationToolbar(self, 'location toolbar') self.location_toolbar.setOffset(1500) self._status_bar_widgets = dict() self._setupStatusBar() self._is_shell_maximized = False self.shell_font = qt.QFont() self.shell_font.setRawName(CONF.getFont()) self.setSizeFont()
def setShellFont(self): self.shell_font=qt.QFont() CONF.setFont("-Misc-Fixed-medium-r-normal-*-"+str(self._sizes[self._size])+"-100-100-100-c-70-iso8859-1") CONF.saveConfig() self.shell_font.setRawName(CONF.getFont()) for shell in self._shell_widgets: shell.setVTFont(self.shell_font)
def main(args): app = Qt.QApplication(args) fonts = Qt.QFontDatabase() if Qt.QString('Verdana') in fonts.families(): app.setFont(Qt.QFont('Verdana')) demo = make() app.setMainWidget(demo) sys.exit(app.exec_loop())
def font(self, style): """font(style) -> the qt font to display for the indicated style """ font = util.appConfig('Fonts').readFontEntry('code', qt.QFont('fixed')) if style in (5, 8, 9): # (Keyword, ClassName, FunctionMethodName,) font.setBold(True) return font
def plotAxis(self, orientation, options, title): self.enableAxis(orientation) self.setAxisOptions(orientation, options) if options & Logarithmic: self.setAxisMaxMinor(orientation, 8) if title: self.setAxisTitle(orientation, title) self.setAxisTitleFont( orientation, qt.QFont(self.font().family(), 12, qt.QFont.Bold)) self.clearZoomStack()
def __init__(self, parent=None, name=None, fl=0): qt.QWidget.__init__(self, parent, name, fl) # AsyncResult to return values self._async_result = None # Layout qt.QVBoxLayout(self) main_layout = self.layout() main_layout.setSpacing(10) main_layout.setMargin(6) self.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) self.setCaption("GPhL Workflow parameters") # Info box self.info_gbox = qt.QVGroupBox("Info", self, "info_gbox") main_layout.addWidget(self.info_gbox) self.info_text = qt.QTextEdit(self.info_gbox, "info_text") self.info_text.setTextFormat(0) # PlainText self.info_text.setFont(qt.QFont("Courier")) self.info_text.setReadOnly(True) # Special parameter box self.cplx_gbox = qt.QVGroupBox("Indexing solution", self, "cplx_gbox") main_layout.addWidget(self.cplx_gbox) self.cplx_widget = None # Parameter box self.parameter_gbox = qt.QVGroupBox("Parameters", self, "parameter_gbox") main_layout.addWidget(self.parameter_gbox) self.params_widget = None # Button bar button_layout = qt.QHBoxLayout(None, 0, 6, "button_layout") hspacer = qt.QSpacerItem(1, 20, qt.QSizePolicy.Expanding, qt.QSizePolicy.Minimum) button_layout.addItem(hspacer) self.continue_button = qt.QPushButton("Continue", self, "continue_button") button_layout.addWidget(self.continue_button) self.cancel_button = qt.QPushButton("Abort", self, "cancel_button") button_layout.addWidget(self.cancel_button) main_layout.addLayout(button_layout) qt.QObject.connect(self.continue_button, qt.SIGNAL("clicked()"), self.continue_button_click) qt.QObject.connect(self.cancel_button, qt.SIGNAL("clicked()"), self.cancel_button_click) self.resize(qt.QSize(1018, 472).expandedTo(self.minimumSizeHint())) self.clearWState(qt.Qt.WState_Polished)
def setSizeFont(self): if re.search("fixed",str(self.shell_font.family()),re.IGNORECASE) is None: self.shell_font=qt.QFont() CONF.setFont("-Misc-Fixed-medium-r-normal-*-12-100-100-100-c-70-iso8859-1") CONF.saveConfig() self.shell_font.setRawName(CONF.getFont()) self._sizes = [6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,36] i=0 self._size=6 for f_i in self._sizes: if f_i == self.shell_font.pixelSize(): self._size=i i+=1
def __init__(self, master, dims, font, ww, wp, editable): self.this = qt.QMultiLineEdit(master.group[-1][0]) self.master = master self.this.setWordWrap(ww) self.this.setWrapPolicy(wp) if font: self.this.setFont(qt.QFont(font)) if dims != (0, 0): fm = self.this.fontMetrics() if dims[0] != 0: self.this.setMinimumWidth(dims[0] * fm.width('X')) if dims[1] != 0: self.this.setMinimumHeight(dims[1] * fm.height()) self.set_editable(editable)
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 __init__(self, parent=None, name="selection_table", header=None): qttable.QTable.__init__(self, parent, name) if not header: raise ValueError("DisplayTable must be initialised with header") self.setNumCols(len(header)) self.setSelectionMode(qttable.QTable.SingleRow) self.horizontalHeader().setFont(qt.QFont("Courier")) self.horizontalHeader().setStretchEnabled(True, -1) for ii, text in enumerate(header): self.horizontalHeader().setLabel(ii, text) self.setColumnReadOnly(ii, True) # self.setColumnStretchable(ii, True) # self.setSizePolicy(qt.QSizePolicy.Expanding, # qt.QSizePolicy.Expanding) self.horizontalHeader().adjustHeaderSize()
def addSummary(self, key): """ addSummary(key) -> add a summary label and lcd to the layout """ label = qt.QLabel(key, self) font = qt.QFont(label.font()) font.setBold(True) label.setFont(font) lcd = LCDNumber(self) layout = self.layout() layout.addWidget(label) layout.addWidget(lcd) layout.setStretchFactor(lcd, 100) self.readLcd(key, lcd) self.summaries[key] = (label, lcd) self.writeLcd(key, lcd)
def drawContents(self, painter): # draw curves r = self.contentsRect() dy = r.height() / len(self.curves) r.setHeight(dy) for curve in self.curves: self.xMap.setPaintInterval(r.left(), r.right()) self.yMap.setPaintInterval(r.top(), r.bottom()) curve.draw(painter, self.xMap, self.yMap, r) self.shiftDown(r, dy) # draw titles r = self.contentsRect() r.setHeight(dy) painter.setFont(Qt.QFont('Helvetica', 8)) painter.setPen(Qt.Qt.black) for title in self.titles: painter.drawText(0, r.top(), r.width(), painter.fontMetrics().height(), Qt.Qt.AlignTop | Qt.Qt.AlignHCenter, title) self.shiftDown(r, dy)
def dialogBoxFunction(self): self.deleteAllMsgBox = qt.QDialog(slicer.util.mainWindow()) # self.deleteAllMsgBox.setWindowTitle("Delete All Fiducials?") self.deleteAllMsgBox.setFixedSize(200, 100) self.deleteAllMsgBox.show() self.deleteAllMsgBox.setLayout(qt.QVBoxLayout()) messageLabel = qt.QLabel("Delete All Fiducials?") font = qt.QFont() font.setPointSize(10) messageLabel.setFont(font) self.deleteAllMsgBox.layout().addWidget(messageLabel, 0, 4) yesNoBox = qt.QFrame() yesNoBox.setLayout(qt.QHBoxLayout()) self.deleteAllMsgBox.layout().addWidget(yesNoBox, 0, 4) # # OK button # okButton = qt.QPushButton() okButton.setText("YES") okButton.enabled = True okIcon = qt.QIcon(":/Icons/AnnotationOkDone.png") okButton.setIcon(okIcon) yesNoBox.layout().addWidget(okButton) # # NO button # noButton = qt.QPushButton() noButton.setText("NO") noButton.enabled = True noIcon = qt.QIcon(":/Icons/AnnotationCancel.png") noButton.setIcon(noIcon) yesNoBox.layout().addWidget(noButton) # Connections okButton.connect("clicked()", self.onDeleteAllButton) noButton.connect("clicked()", self.deleteAllMsgBox.hide)
def setBrowserWidgetInDICOMLayout(self, browserWidget): """Set DICOM browser widget in the custom view layout""" if self.browserWidget == browserWidget: return if self.browserWidget is not None: self.browserWidget.closed.disconnect(self.onBrowserWidgetClosed) oldBrowserWidget = self.browserWidget self.browserWidget = browserWidget self.browserWidget.setAutoFillBackground(True) if slicer.util.mainWindow(): # For some reason, we cannot disconnect this event connection if # main window, and not disconnecting would cause crash on application shutdown, # so we only connect when main window is present. self.browserWidget.closed.connect(self.onBrowserWidgetClosed) if self.viewWidget is None: self.viewWidget = qt.QWidget() self.viewWidget.setAutoFillBackground(True) self.viewFactory.setWidget(self.viewWidget) layout = qt.QVBoxLayout() self.viewWidget.setLayout(layout) label = qt.QLabel("DICOM database") label.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed) layout.addWidget(label) font = qt.QFont() font.setBold(True) font.setPointSize(12) label.setFont(font) if oldBrowserWidget is not None: self.viewWidget.layout().removeWidget(oldBrowserWidget) if self.browserWidget: self.viewWidget.layout().addWidget(self.browserWidget)
def __init__(self, parent, node): #, flags=0): # flags = flags | Qt.WDestructiveClose qtext.QextScintilla.__init__(self, parent) self.lexer = SourceBrowserLexer(self) self.setLexer(self.lexer) self.setIndentationGuides(True) self.setWhitespaceVisibility(1) self.setMarginsFont(qt.QFont('fixed')) self.setMarginLineNumbers(0, 1) self.setFolding(qtext.QextScintilla.BoxedTreeFoldStyle) self.setMarginWidth(0, "abcd") self.setReadOnly(False) node = node.item try: txt_lines, lineno = inspect.findsource(node.__class__) txt = str.join('', txt_lines) except (IOError, TypeError): txt = 'Unable to get source.' lineno = 0 self.setText(txt) self.setCursorPosition(lineno, 0) self.ensureLineVisible(lineno) self.setReadOnly(True)
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # parametersCollapsibleButton = ctk.ctkCollapsibleButton() parametersCollapsibleButton.text = "Parameters" parametersCollapsibleButton.setFont(qt.QFont("Times", 12)) self.layout.addWidget(parametersCollapsibleButton) # Layout within the dummy collapsible button parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton) # # input volume selector # self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.inputSelector.selectNodeUponCreation = True self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.noneEnabled = False self.inputSelector.showHidden = False self.inputSelector.showChildNodeTypes = False self.inputSelector.setMRMLScene(slicer.mrmlScene) self.inputSelector.setToolTip("Pick the input to the algorithm.") parametersFormLayout.addRow("Input Volume: ", self.inputSelector) # # ROI selector # self.ROISelector = slicer.qMRMLNodeComboBox() self.ROISelector.nodeTypes = ["vtkMRMLAnnotationROINode"] self.ROISelector.selectNodeUponCreation = True self.ROISelector.addEnabled = False self.ROISelector.removeEnabled = True self.ROISelector.noneEnabled = True self.ROISelector.showHidden = False self.ROISelector.showChildNodeTypes = False self.ROISelector.setMRMLScene(slicer.mrmlScene) self.ROISelector.setToolTip("Pick the ROI to the algorithm.") parametersFormLayout.addRow("Select ROI: ", self.ROISelector) # # Pectoral Smoothing Iterations Spin Box # self.pectoralSmoothingIterationSpinBox = qt.QSpinBox() self.pectoralSmoothingIterationSpinBox.setRange(0, 20000) self.pectoralSmoothingIterationSpinBox.setSingleStep(500) self.pectoralSmoothingIterationSpinBox.setValue(4000) parametersFormLayout.addRow("Pectoral Smoothing Iterations: ", self.pectoralSmoothingIterationSpinBox) # # Breast Implants Collapsible Button # breastImplantsCollapsibleButton = ctk.ctkCollapsibleButton() breastImplantsCollapsibleButton.text = "Breast Implants" breastImplantsCollapsibleButton.setFont(qt.QFont("Times", 12)) breastImplantsCollapsibleButton.collapsed = True self.layout.addWidget(breastImplantsCollapsibleButton) # Layout within the dummy collapsible button breastImplantsFormLayout = qt.QFormLayout( breastImplantsCollapsibleButton) # # Breast implants algorithm hint label # self.breastImplantsHintLabel = qt.QLabel() self.breastImplantsHintLabel.setText( "Please pick one point for one side or two points for both sides.") # Align Center self.breastImplantsHintLabel.setAlignment(4) self.breastImplantsHintLabel.setFrameStyle(qt.QFrame.WinPanel) self.breastImplantsHintLabel.setFrameShadow(qt.QFrame.Sunken) self.breastImplantsHintLabel.setMargin(2) self.breastImplantsHintLabel.setFont( qt.QFont("Times", 14, qt.QFont.Black)) breastImplantsFormLayout.addRow(self.breastImplantsHintLabel) # # GACM initial point selector # self.pointSelector = slicer.qMRMLNodeComboBox() self.pointSelector.nodeTypes = ["vtkMRMLMarkupsFiducialNode"] self.pointSelector.selectNodeUponCreation = True self.pointSelector.addEnabled = True self.pointSelector.removeEnabled = True self.pointSelector.noneEnabled = True self.pointSelector.showHidden = False self.pointSelector.showChildNodeTypes = False self.pointSelector.baseName = "P" self.pointSelector.setMRMLScene(slicer.mrmlScene) self.pointSelector.setToolTip("Pick the initial points for GACM.") breastImplantsFormLayout.addRow("Initial Points: ", self.pointSelector) # # Place the fiducial point(s) on screen # self.markupPointWidget = slicer.qSlicerMarkupsPlaceWidget() self.markupPointWidget.setMRMLScene(slicer.mrmlScene) self.markupPointWidget.setPlaceModePersistency(False) breastImplantsFormLayout.addRow(self.markupPointWidget) # # Estimate Volume Button # self.estimateButton = qt.QPushButton("Estimate Volume") self.estimateButton.toolTip = "Run the algorithm." self.estimateButton.enabled = False self.estimateButton.setFont(qt.QFont("Times", 24, qt.QFont.Black)) self.layout.addWidget(self.estimateButton) # # Spacer # self.spacer = qt.QLabel() self.layout.addWidget(self.spacer) # # Editting Segmentation # segmentationEditorCollapsibleButton = ctk.ctkCollapsibleButton() segmentationEditorCollapsibleButton.text = "Editting Segmentation" segmentationEditorCollapsibleButton.setFont(qt.QFont("Times", 12)) segmentationEditorCollapsibleButton.collapsed = True self.layout.addWidget(segmentationEditorCollapsibleButton) # Layout within the dummy collapsible button segmentationEditorFormLayout = qt.QFormLayout( segmentationEditorCollapsibleButton) self.segmentationEditorWidget = slicer.qMRMLSegmentEditorWidget() self.segmentationEditorWidget.setMaximumNumberOfUndoStates(10) self.parameterSetNode = None self.selectParameterNode() self.segmentationEditorWidget.setSwitchToSegmentationsButtonVisible( False) self.segmentationEditorWidget.setUndoEnabled(True) self.segmentationEditorWidget.setMRMLScene(slicer.mrmlScene) segmentationEditorFormLayout.addWidget(self.segmentationEditorWidget) # # Calculate Statistics Button # self.statButton = qt.QPushButton("Calculate Statistics") self.statButton.toolTip = "Calculate statistics." self.statButton.enabled = True self.statButton.setFont(qt.QFont("Times", 24, qt.QFont.Black)) segmentationEditorFormLayout.addWidget(self.statButton) # connections self.estimateButton.connect('clicked(bool)', self.onEstimateButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.pointSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.setPoint) self.segmentationEditorWidget.connect( "masterVolumeNodeChanged(vtkMRMLVolumeNode*)", self.saveState) self.statButton.connect('clicked(bool)', self.calculateStatistics) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) self.setTitle('Frequency Response of a 2<sup>nd</sup>-order System') self.setCanvasBackground(Qt.Qt.darkBlue) # legend legend = Qwt.QwtLegend() legend.setFrameStyle(Qt.QFrame.Box | Qt.QFrame.Sunken) legend.setItemMode(Qwt.QwtLegend.ClickableItem) self.insertLegend(legend, Qwt.QwtPlot.BottomLegend) # grid self.grid = Qwt.QwtPlotGrid() self.grid.enableXMin(True) self.grid.setMajPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.DotLine)) self.grid.setMinPen(Qt.QPen(Qt.Qt.gray, 0 , Qt.Qt.DotLine)) self.grid.attach(self) # axes self.enableAxis(Qwt.QwtPlot.yRight) self.setAxisTitle(Qwt.QwtPlot.xBottom, u'\u03c9/\u03c9<sub>0</sub>') self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Amplitude [dB]') self.setAxisTitle(Qwt.QwtPlot.yRight, u'Phase [\u00b0]') self.setAxisMaxMajor(Qwt.QwtPlot.xBottom, 6) self.setAxisMaxMinor(Qwt.QwtPlot.xBottom, 10) self.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) # curves self.curve1 = Qwt.QwtPlotCurve('Amplitude') self.curve1.setPen(Qt.QPen(Qt.Qt.yellow)) self.curve1.setYAxis(Qwt.QwtPlot.yLeft) self.curve1.attach(self) self.curve2 = Qwt.QwtPlotCurve('Phase') self.curve2.setPen(Qt.QPen(Qt.Qt.cyan)) self.curve2.setYAxis(Qwt.QwtPlot.yRight) self.curve2.attach(self) # alias fn = self.fontInfo().family() # marker self.dB3Marker = m = Qwt.QwtPlotMarker() m.setValue(0.0, 0.0) m.setLineStyle(Qwt.QwtPlotMarker.VLine) m.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignBottom) m.setLinePen(Qt.QPen(Qt.Qt.green, 2, Qt.Qt.DashDotLine)) text = Qwt.QwtText('') text.setColor(Qt.Qt.green) text.setBackgroundBrush(Qt.QBrush(Qt.Qt.red)) text.setFont(Qt.QFont(fn, 12, Qt.QFont.Bold)) m.setLabel(text) m.attach(self) self.peakMarker = m = Qwt.QwtPlotMarker() m.setLineStyle(Qwt.QwtPlotMarker.HLine) m.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignBottom) m.setLinePen(Qt.QPen(Qt.Qt.red, 2, Qt.Qt.DashDotLine)) text = Qwt.QwtText('') text.setColor(Qt.Qt.red) text.setBackgroundBrush(Qt.QBrush(self.canvasBackground())) text.setFont(Qt.QFont(fn, 12, Qt.QFont.Bold)) m.setLabel(text) m.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Diamond, Qt.QBrush(Qt.Qt.yellow), Qt.QPen(Qt.Qt.green), Qt.QSize(7,7))) m.attach(self) # text marker m = Qwt.QwtPlotMarker() m.setValue(0.1, -20.0) m.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignBottom) text = Qwt.QwtText( u'[1-(\u03c9/\u03c9<sub>0</sub>)<sup>2</sup>+2j\u03c9/Q]' '<sup>-1</sup>' ) text.setFont(Qt.QFont(fn, 12, Qt.QFont.Bold)) text.setColor(Qt.Qt.blue) text.setBackgroundBrush(Qt.QBrush(Qt.Qt.yellow)) text.setBackgroundPen(Qt.QPen(Qt.Qt.red, 2)) m.setLabel(text) m.attach(self) self.setDamp(0.01)
def font(self, f, item, i): result = Qt.QFont(f) result.setPointSize(int(f.pointSize()*1.25)) return result
def __init__(self, *args): """Constructor. Usage: plot = Plot([pattern,] *args) Plot takes any number of optional arguments. The interpretation of each optional argument depend on its data type: (1) Axis -- enables the axis. (2) Curve -- plots a curve. (3) str or qt.QString -- sets the title. (4) integer -- attaches a set of mouse events to the zoomer actions (5) tuples of 2 integer -- sets the size. (6) qt.QWidget -- parent widget. """ self.size = (600, 400) # get an optional parent widget parent = None for arg in args: if isinstance(arg, qt.QWidget): parent = arg self.size = None Qwt.QwtPlot.__init__(self, parent) # font font = qt.QFont('Verdana') if font.exactMatch(): self.setFont(font) # user interface self.setCanvasBackground(qt.Qt.white) self.setOutlinePen(qt.QPen(qt.Qt.black)) self.setAutoLegend(1) self.setLegendPos(Qwt.Qwt.Right) # zooming self.zoomers = [] zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.DragSelection, Qwt.QwtPicker.AlwaysOff, self.canvas()) zoomer.setRubberBandPen(qt.QPen(Black)) self.zoomers.append(zoomer) zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xTop, Qwt.QwtPlot.yRight, Qwt.QwtPicker.DragSelection, Qwt.QwtPicker.AlwaysOff, self.canvas()) zoomer.setRubberBand(Qwt.QwtPicker.NoRubberBand) self.zoomers.append(zoomer) self.setZoomerMouseEventSet(0) # initialization for arg in args: if isinstance(arg, Axis): self.plotAxis(arg.orientation, arg.options, arg.title) elif isinstance(arg, Curve): self.plotCurve(arg) elif (isinstance(arg, str) or isinstance(arg, qt.QString)): self.setTitle(arg) self.setTitleFont( qt.QFont(self.font().family(), 14, qt.QFont.Bold)) elif isinstance(arg, int): self.setZoomerMouseEventSet(arg) elif (isinstance(arg, tuple) and len(tuple) == 2 and isinstance(arg[0], int) and isinstance(arg[1], int)): self.size = arg elif (isinstance(arg, qt.QWidget)): pass else: print "Plot() fails to accept %s." % arg if self.size: self.resize(self.size[0], self.size[1]) # connections self.connect(self, qt.SIGNAL("legendClicked(long)"), self.toggleCurve) # finalize self.show()
def configChanged(self, config): config.setGroup(util.groups.fonts) font = config.readFontEntry('shell', qt.QFont('fixed')) self.setFont(font)
def _getMinimumTextWidth(self, text): fm = qt.QFontMetrics(qt.QFont(text, 0)) width = fm.width(text) return width
def setup(self): self.detailsPopup = None self.setDetailsPopup(self.getSavedDICOMDetailsWidgetType()()) # XXX Slicer 4.5 - Remove these. Here only for backward compatibility. self.dicomBrowser = self.detailsPopup.dicomBrowser self.tables = self.detailsPopup.tables layoutManager = slicer.app.layoutManager() if layoutManager is not None: layoutManager.layoutChanged.connect(self.onLayoutChanged) # connect to the 'Show DICOM Browser' button self.showBrowserButton = qt.QPushButton('Show DICOM database browser') self.showBrowserButton.setCheckable(True) self.layout.addWidget(self.showBrowserButton) self.showBrowserButton.setStyleSheet("font:Bold;" "font-size:12px") self.showBrowserButton.connect('clicked()', self.toggleDetailsPopup) self.loadedDataLabel = qt.QLabel("Loaded data") self.loadedDataLabel.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed) self.layout.addWidget(self.loadedDataLabel) font = qt.QFont() font.setBold(True) font.setPointSize(12) self.loadedDataLabel.setFont(font) self.layout.addWidget(self.loadedDataLabel) self.subjectHierarchyTree = slicer.qMRMLSubjectHierarchyTreeView() self.layout.addWidget(self.subjectHierarchyTree) self.subjectHierarchyTree.setMRMLScene(slicer.mrmlScene) self.subjectHierarchyTree.currentItemChanged.connect( self.onCurrentItemChanged) self.subjectHierarchyTree.currentItemModified.connect( self.onCurrentItemModified) self.subjectHierarchyCurrentVisibility = False self.subjectHierarchyTree.setColumnHidden( self.subjectHierarchyTree.model().idColumn, True) self.browserSettingsWidget = ctk.ctkCollapsibleGroupBox() self.browserSettingsWidget.title = "Browser settings" self.layout.addWidget(self.browserSettingsWidget) self.browserSettingsWidget.collapsed = True self.browserSettingsWidget.setLayout(qt.QFormLayout()) self.directoryButton = ctk.ctkDirectoryButton() self.browserSettingsWidget.layout().addRow("Local database:", self.directoryButton) self.directoryButton.directoryChanged.connect( self.onDatabaseDirectoryButtonChanged) self.onDatabaseDirectoryDetailsPopupChanged( self.detailsPopup.dicomBrowser.databaseDirectory) self.tableDensityComboBox = qt.QComboBox() self.browserSettingsWidget.layout().addRow("Table density:", self.tableDensityComboBox) self.tableDensityComboBox.currentIndexChanged.connect( self.onTableDensityChanged) self.updateTableDensityComboBox() self.horizontalCheckBox = qt.QCheckBox() self.horizontalCheckBox.checked = settingsValue( 'DICOM/horizontalTables', 0, converter=int) self.horizontalCheckBox.stateChanged.connect( self.onHorizontalStateChanged) self.browserSettingsWidget.layout().addRow("Horizontal:", self.horizontalCheckBox) self.browserPersistentCheckBox = qt.QCheckBox() self.browserPersistentCheckBox.checked = settingsValue( 'DICOM/BrowserPersistent', False, converter=toBool) self.browserPersistentCheckBox.stateChanged.connect( self.onBrowserPersistentStateChanged) self.browserSettingsWidget.layout().addRow( "Browser persistent:", self.browserPersistentCheckBox) self.additionalSettingsLayout = qt.QHBoxLayout() # # servers # # testing server - not exposed (used for development) self.localFrame = ctk.ctkCollapsibleButton(self.parent) self.localFrame.setLayout(qt.QVBoxLayout()) self.localFrame.setText("Servers") self.layout.addWidget(self.localFrame) self.localFrame.collapsed = True self.toggleServer = qt.QPushButton("Start Testing Server") self.localFrame.layout().addWidget(self.toggleServer) self.toggleServer.connect('clicked()', self.onToggleServer) self.verboseServer = qt.QCheckBox("Verbose") self.localFrame.layout().addWidget(self.verboseServer) # advanced options - not exposed to end users # developers can uncomment these lines to access testing server self.toggleServer.hide() self.verboseServer.hide() # Listener settings = qt.QSettings() self.toggleListener = qt.QPushButton() self.toggleListener.checkable = True if hasattr(slicer, 'dicomListener'): self.toggleListener.text = "Stop Listener" slicer.dicomListener.process.connect( 'stateChanged(QProcess::ProcessState)', self.onListenerStateChanged) else: self.toggleListener.text = "Start Listener" self.localFrame.layout().addWidget(self.toggleListener) self.toggleListener.connect('clicked()', self.onToggleListener) self.runListenerAtStart = qt.QCheckBox( "Start Listener when Slicer Starts") self.localFrame.layout().addWidget(self.runListenerAtStart) self.runListenerAtStart.checked = settingsValue( 'DICOM/RunListenerAtStart', False, converter=toBool) self.runListenerAtStart.connect('clicked()', self.onRunListenerAtStart) # connect to the main window's dicom button mw = slicer.util.mainWindow() if mw: try: action = slicer.util.findChildren(mw, name='LoadDICOMAction')[0] action.connect('triggered()', self.onOpenDetailsPopup) except IndexError: logging.error( 'Could not connect to the main window DICOM button') if hasattr(slicer, 'dicomListener'): slicer.dicomListener.fileToBeAddedCallback = self.onListenerToAddFile slicer.dicomListener.fileAddedCallback = self.onListenerAddedFile slicer.dicomDatabase.connect('databaseChanged()', self.onDatabaseChanged) # the recent activity frame self.activityFrame = ctk.ctkCollapsibleButton(self.parent) self.activityFrame.collapsed = True self.activityFrame.setLayout(qt.QVBoxLayout()) self.activityFrame.setText("Recent DICOM Activity") self.layout.addWidget(self.activityFrame) self.recentActivity = DICOMLib.DICOMRecentActivityWidget( self.activityFrame, detailsPopup=self.detailsPopup) self.activityFrame.layout().addWidget(self.recentActivity) self.requestUpdateRecentActivity()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # # Parameter Combobox # self.parameterSelector = slicer.qMRMLNodeComboBox() self.parameterLabel = qt.QLabel(" Parameter set: ") self.parameterSelector.nodeTypes = ["vtkMRMLScriptedModuleNode"] self.parameterSelector.removeEnabled = False self.parameterSelector.showHidden = True self.parameterSelector.setMRMLScene( slicer.mrmlScene ) self.parameterLayout = qt.QHBoxLayout() self.parameterLayout.addWidget(self.parameterLabel) self.parameterLayout.addWidget(self.parameterSelector) self.layout.addLayout(self.parameterLayout) # # Input Area # inputCollapsibleButton = ctk.ctkCollapsibleButton() inputCollapsibleButton.text = "Input" self.layout.addWidget(inputCollapsibleButton) # Layout within the dummy collapsible button inputFormLayout = qt.QFormLayout(inputCollapsibleButton) # # Input first DVH selector # self.dvh1Selector = slicer.qMRMLNodeComboBox() self.dvh1Selector.nodeTypes = ["vtkMRMLTableNode"] self.dvh1Selector.addAttribute("vtkMRMLTableNode", "DoseVolumeHistogram.DVH") self.dvh1Selector.removeEnabled = False self.dvh1Selector.setMRMLScene( slicer.mrmlScene ) inputFormLayout.addRow("DVH 1: ", self.dvh1Selector) # # Input second DVH selector # self.dvh2Selector = slicer.qMRMLNodeComboBox() self.dvh2Selector.nodeTypes = ["vtkMRMLTableNode"] self.dvh1Selector.addAttribute("vtkMRMLTableNode", "DoseVolumeHistogram.DVH") self.dvh2Selector.removeEnabled = False self.dvh2Selector.setMRMLScene( slicer.mrmlScene ) inputFormLayout.addRow("DVH 2: ", self.dvh2Selector) # # Input the dose volume # self.doseVolumeSelector = slicer.qMRMLNodeComboBox() self.doseVolumeSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.doseVolumeSelector.addAttribute("vtkMRMLScalarVolumeNode", "DicomRtImport.DoseVolume") self.doseVolumeSelector.removeEnabled = False self.doseVolumeSelector.setMRMLScene( slicer.mrmlScene ) inputFormLayout.addRow("Dose Volume: ", self.doseVolumeSelector) # # Dose volume only check box # self.showDoseVolumeOnlyCheckbox = qt.QCheckBox("Show dose volume only") self.showDoseVolumeOnlyCheckbox.setChecked(2) inputFormLayout.addWidget(self.showDoseVolumeOnlyCheckbox) # # Volume difference criterion spin box # self.volumeDifferenceSpinbox = qt.QDoubleSpinBox() self.volumeDifferenceSpinbox.setValue(1.0) self.volumeDifferenceSpinbox.setDecimals(1) self.volumeDifferenceSpinbox.setSingleStep(0.1) inputFormLayout.addRow("Volume difference criterion: ", self.volumeDifferenceSpinbox) # # Dose to agreement criterion spin box # self.doseToAgreementSpinbox = qt.QDoubleSpinBox() self.doseToAgreementSpinbox.setValue(1.0) self.doseToAgreementSpinbox.setDecimals(1) self.doseToAgreementSpinbox.setSingleStep(0.1) inputFormLayout.addRow("Dose to agreement criterion: ", self.doseToAgreementSpinbox) # # Compute button # self.computeButton = qt.QPushButton("Compute") self.computeButtonLayout = qt.QVBoxLayout() self.computeButtonLayout.addStrut(100) self.computeButtonLayout.setAlignment(2) self.computeButtonLayout.addWidget(self.computeButton) self.computeButtonFont = qt.QFont() self.computeButtonFont.setBold(True) self.computeButton.setFont(self.computeButtonFont) inputFormLayout.addRow(self.computeButtonLayout) # # Output Area # outputCollapsibleButton = ctk.ctkCollapsibleButton() outputCollapsibleButton.text = "Output" self.layout.addWidget(outputCollapsibleButton) # Layout within the dummy collapsible button outputFormLayout = qt.QFormLayout(outputCollapsibleButton) self.agreementAcceptanceOutput = qt.QLineEdit() self.agreementAcceptanceOutput.setReadOnly(True) outputFormLayout.addRow("Agreement acceptance %: ", self.agreementAcceptanceOutput) # # Visualize Area # visualizeCollapsibleButton = ctk.ctkCollapsibleButton() visualizeCollapsibleButton.text = "Visualize" sizePolicy = qt.QSizePolicy() sizePolicy.setHorizontalPolicy(qt.QSizePolicy.Preferred) sizePolicy.setVerticalPolicy(qt.QSizePolicy.Expanding) visualizeCollapsibleButton.setSizePolicy(sizePolicy) self.layout.addWidget(visualizeCollapsibleButton) # Layout within the dummy collapsible button visualizeLayout = qt.QVBoxLayout(visualizeCollapsibleButton) # # DVH Table # self.dvhTable = slicer.qMRMLTableView() self.dvhTable.setMRMLScene(slicer.mrmlScene) self.dvhTable.setSelectionMode(qt.QAbstractItemView.NoSelection) self.dvhTable.setSizePolicy(sizePolicy) visualizeLayout.addWidget(self.dvhTable) # Connections self.parameterSelector.connect('nodeAddedByUser(vtkMRMLNode*)', self.parameterNodeCreated) self.parameterSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.updateWidgetFromMRML) self.showDoseVolumeOnlyCheckbox.connect('stateChanged(int)', self.showDoseVolumesOnlyCheckboxChanged) self.dvh1Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.dvh1SelectorChanged) self.dvh2Selector.connect("currentNodeChanged(vtkMRMLNode*)", self.dvh2SelectorChanged) self.doseVolumeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.doseVolumeSelectorChanged) self.volumeDifferenceSpinbox.connect("valueChanged(double)", self.volumeDifferenceSpinboxChanged) self.doseToAgreementSpinbox.connect("valueChanged(double)", self.doseToAgreementSpinboxChanged) self.computeButton.connect('clicked(bool)', self.onComputeButton) self.updateWidgetFromMRML()
def setup(self): ScriptedLoadableModuleWidget.setup(self) # Instantiate and connect widgets ... # # Parameters Area # # self.segVolumeTotalNode = slicer.vtkMRMLModelHierarchyNode() # self.segVolumeTotalNode.SetName('segVolumeTotalNode') # self.segVolumeTotalNode.SetSingletonTag('segVolumeTotalNode') # # self.segVolumeTotalNode.HideFromEditorsOn() # slicer.mrmlScene.AddNode(self.segVolumeTotalNode) self.segVolumeTotalNode = [] self.segCombineVol = None inputCollapsibleButton = ctk.ctkCollapsibleButton() inputCollapsibleButton.text = "Input Volumes" self.layout.addWidget(inputCollapsibleButton) self.pathText = qt.QLineEdit() # self.__fixedShrinkFactor.setText("16, 16, 16") self.pathText.setToolTip('Specify output path') self.layout.addWidget(self.pathText) # Layout within the dummy collapsible button inputFormLayout = qt.QFormLayout(inputCollapsibleButton) loadSpineVolumeButton = qt.QPushButton('Load spine volume') loadSpineVolumeButton.connect('clicked()', self.loadVolume) inputFormLayout.addRow('Load spine volume', loadSpineVolumeButton) loadSegVolumeButton = qt.QPushButton('Load segmentation volume') loadSegVolumeButton.connect('clicked()', self.loadVolume) inputFormLayout.addRow('Load segmentation volume', loadSegVolumeButton) # input volume selector self.inputSelector = slicer.qMRMLNodeComboBox() self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"] self.inputSelector.selectNodeUponCreation = True self.inputSelector.addEnabled = False self.inputSelector.removeEnabled = False self.inputSelector.noneEnabled = False self.inputSelector.showHidden = False self.inputSelector.showChildNodeTypes = False self.inputSelector.setMRMLScene(slicer.mrmlScene) self.inputSelector.setToolTip("Select the CT spine volume.") inputFormLayout.addRow("Input Volume: ", self.inputSelector) # # output volume selector # self.segmentationSelector = slicer.qMRMLNodeComboBox() self.segmentationSelector.nodeTypes = ["vtkMRMLLabelMapVolumeNode"] self.segmentationSelector.selectNodeUponCreation = True self.segmentationSelector.addEnabled = True self.segmentationSelector.removeEnabled = True self.segmentationSelector.noneEnabled = True self.segmentationSelector.showHidden = False self.segmentationSelector.showChildNodeTypes = False self.segmentationSelector.setMRMLScene(slicer.mrmlScene) self.segmentationSelector.setToolTip( "Select the ground truth segmentation " "(if any exists) to compare with prediction.") inputFormLayout.addRow("Segmentation Volume: ", self.segmentationSelector) cropCollapsibleButton = ctk.ctkCollapsibleButton() cropCollapsibleButton.text = "Select Vertebrae" self.layout.addWidget(cropCollapsibleButton) # Layout within the dummy collapsible button cropFormLayout = qt.QFormLayout(cropCollapsibleButton) markerTable = slicer.qSlicerSimpleMarkupsWidget() self.markerTableSelector = markerTable.MarkupsFiducialNodeComboBox self.markerTableSelector.selectNodeUponCreation = False self.markerTableSelector.addEnabled = True self.markerTableSelector.removeEnabled = True self.markerTableSelector.noneEnabled = True self.markerTableSelector.renameEnabled = False markerTable.setMRMLScene(slicer.mrmlScene) markerTable.setCurrentNode( slicer.mrmlScene.GetNodeByID( slicer.modules.markups.logic().AddNewFiducialNode())) markerTable.show() cropFormLayout.addWidget(markerTable) font = qt.QFont() font.setBold(True) # Segment vertebrae button self.segmentationButton = qt.QPushButton('Segment Vertebrae') self.segmentationButton.setFont(font) self.segmentationButton.toolTip = 'Segment the selected vertebrae' self.segmentationButton.enabled = False # Segmentation button connections self.segmentationButton.connect('clicked(bool)', self.onSegmentButton) self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.markerTableSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) self.layout.addWidget(self.segmentationButton) # Combine Segmentations combineCollapsibleButton = ctk.ctkCollapsibleButton() combineCollapsibleButton.text = "Combine Segmentations" self.layout.addWidget(combineCollapsibleButton) # Layout within the dummy collapsible button combineFormLayout = qt.QFormLayout(combineCollapsibleButton) # Section to assign labels to segmentations and combine segmentations to a single volume self.L5SegSelector = DefaultSegSelect() self.L5SegSelector.setToolTip("Select L5 Segmentation") combineFormLayout.addRow("L5: ", self.L5SegSelector) # self.L5SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel(self.L5SegSelector.currentNode())) self.L5SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.L4SegSelector = DefaultSegSelect() self.L4SegSelector.setToolTip("Select L4 Segmentation") combineFormLayout.addRow("L4: ", self.L4SegSelector) self.L4SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.L3SegSelector = DefaultSegSelect() self.L3SegSelector.setToolTip("Select L3 Segmentation") combineFormLayout.addRow("L3: ", self.L3SegSelector) self.L3SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.L2SegSelector = DefaultSegSelect() self.L2SegSelector.setToolTip("Select L2 Segmentation") combineFormLayout.addRow("L2: ", self.L2SegSelector) self.L2SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.L1SegSelector = DefaultSegSelect() self.L1SegSelector.setToolTip("Select L1 Segmentation") combineFormLayout.addRow("L1: ", self.L1SegSelector) self.L1SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.T12SegSelector = DefaultSegSelect() self.T12SegSelector.setToolTip("Select T12 Segmentation") combineFormLayout.addRow("T12: ", self.T12SegSelector) self.T12SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.T11SegSelector = DefaultSegSelect() self.T11SegSelector.setToolTip("Select T11 Segmentation") combineFormLayout.addRow("T11: ", self.T11SegSelector) self.T11SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.T10SegSelector = DefaultSegSelect() self.T10SegSelector.setToolTip("Select T10 Segmentation") combineFormLayout.addRow("T10: ", self.T10SegSelector) self.T10SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.T9SegSelector = DefaultSegSelect() self.T9SegSelector.setToolTip("Select T9 Segmentation") combineFormLayout.addRow("T9: ", self.T9SegSelector) self.T9SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.T8SegSelector = DefaultSegSelect() self.T8SegSelector.setToolTip("Select T8 Segmentation") combineFormLayout.addRow("T8: ", self.T8SegSelector) self.T8SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.T7SegSelector = DefaultSegSelect() self.T7SegSelector.setToolTip("Select T7 Segmentation") combineFormLayout.addRow("T7: ", self.T7SegSelector) self.T7SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.T6SegSelector = DefaultSegSelect() self.T6SegSelector.setToolTip("Select T6 Segmentation") combineFormLayout.addRow("T6: ", self.T6SegSelector) self.T6SegSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.displayLabel) self.SegSelectList = [ self.L5SegSelector, self.L4SegSelector, self.L3SegSelector, self.L2SegSelector, self.L1SegSelector, self.T12SegSelector, self.T11SegSelector, self.T10SegSelector, self.T9SegSelector, self.T8SegSelector, self.T7SegSelector, self.T6SegSelector, ] # Segmentation button connections self.combineSegButton = qt.QPushButton('Combine Segmentations') self.combineSegButton.toolTip = 'Combine Segmented Vertebrae' self.combineSegButton.connect('clicked(bool)', self.onCombineSegButton) self.combineSegButton.setFont(font) combineFormLayout.addRow(self.combineSegButton) # Reset segmentations and fiducial markers self.resetSegButton = qt.QPushButton('Reset Segmentation and Markers') self.resetSegButton.toolTip = "Reset fiducial markers and individual vertebrae segmentations" self.resetSegButton.setFont(font) self.resetSegButton.connect('clicked(bool)', self.onResetSegButton) self.layout.addWidget(self.resetSegButton) # Save segmentation button self.saveButton = qt.QPushButton('Save') self.saveButton.toolTip = "Save segmentation" self.saveButton.setFont(font) self.saveButton.connect('clicked(bool)', self.onSaveButton) combineFormLayout.addRow(self.saveButton) # Add vertical spacer self.layout.addStretch(1) # Refresh Apply button state self.onSelect()
def getMinimumTextWidth(self, text): font = qt.QFont("", 0) metrics = qt.QFontMetrics(font) return metrics.width(text)