def __init__(self, parent=None):
            qt.QWidget.__init__(self)
            self.objectName = "qSlicerAppMainWindow"
            self.setLayout(qt.QVBoxLayout())
            self.mainFrame = qt.QFrame()
            self.mainFrame.setLayout(qt.QHBoxLayout())

            self._statusBar = qt.QStatusBar()
            self._statusBar.setMaximumHeight(35)

            self.layout().addWidget(self.mainFrame)
            self.layout().addWidget(self._statusBar)
Example #2
0
    def __init__(self, parent = None, printer = None, name = "PrintPreview", \
                 modal = 0, fl = 0):
        """
        Constructor method:

        """
        qt.QDialog.__init__(self, parent, name, modal, fl)

        self.printer    = None

        # main layout 
        layout = qt.QVBoxLayout(self, 0, -1, "PrintPreview global layout")

        toolBar = qt.QWidget(self)

        # Margin
        marginLabel = qt.QLabel("Margins:", toolBar)    
        self.marginSpin = qt.QSpinBox(0, 50, 10, toolBar)
        self.connect(self.marginSpin, qt.SIGNAL("valueChanged(int)"),    \
                     self.__marginChanged)

        # Scale / Zoom
        scaleLabel = qt.QLabel("Zoom:", toolBar)
        scaleCombo = qt.QComboBox(toolBar)
        self.scaleValues = [20, 40, 60, 80, 100, 150, 200]

        for scale in self.scaleValues:
            scaleCombo.insertItem("%3d %%"%scale)
            
        self.scaleCombo = scaleCombo
        self.connect(self.scaleCombo, qt.SIGNAL("activated(int)"),        \
                     self.__scaleChanged)


        # --- command buttons
        buttonSize = 65
        
        hideBut   = qt.QPushButton("Hide", toolBar)
        hideBut.setFixedWidth(buttonSize-10)
        self.connect(hideBut, qt.SIGNAL("clicked()"), self.hide)

        cancelBut = qt.QPushButton("Clear All", toolBar)
        cancelBut.setFixedWidth(buttonSize+10)
        self.connect(cancelBut, qt.SIGNAL("clicked()"), self.__clearAll)

        removeBut = qt.QPushButton("Remove", toolBar)
        removeBut.setFixedWidth(buttonSize)
        self.connect(removeBut, qt.SIGNAL("clicked()"), self.__remove)

        setupBut  = qt.QPushButton("Setup", toolBar)
        setupBut.setFixedWidth(buttonSize-5)
        self.connect(setupBut, qt.SIGNAL("clicked()"), self.__setup)

        printBut  = qt.QPushButton("Print", toolBar)
        printBut.setFixedWidth(buttonSize-5)
        self.connect(printBut, qt.SIGNAL("clicked()"), self.__print)
        
        # a layout for the toolbar
        toolsLayout = qt.QHBoxLayout(toolBar, 0, -1, "Tools Layout")

        # now we put widgets in the toolLayout
        toolsLayout.addWidget(hideBut)
        toolsLayout.addWidget(printBut)
        toolsLayout.addWidget(cancelBut)
        toolsLayout.addWidget(removeBut)
        toolsLayout.addWidget(setupBut)
        toolsLayout.addStretch()
        toolsLayout.addWidget(marginLabel)
        toolsLayout.addWidget(self.marginSpin)    
        toolsLayout.addStretch()
        toolsLayout.addWidget(scaleLabel)
        toolsLayout.addWidget(scaleCombo)
        toolsLayout.addStretch()

        # canvas to display items to print
        self.canvas     = qtcanvas.QCanvas(self)
        self.canvasView = PrintCanvasView(self.canvas, self)

        # status bar
        statusBar = qt.QStatusBar(self)

        self.targetLabel = qt.QLabel( "???", statusBar, "targetLabel")
        statusBar.addWidget(self.targetLabel)

        # finally, building main widget.
        layout.addWidget(toolBar)
        layout.addWidget(self.canvasView)
        layout.addWidget(statusBar)
        
        # use user printer or a default QPrinter
        if printer == None:
            printer = qt.QPrinter()
            
        self.setPrinter(printer)
Example #3
0
    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)

        #
        # input volume selector
        #
        with It(slicer.qMRMLNodeComboBox()) as w:
            self.inputSelector = w
            w.nodeTypes = ["vtkMRMLFiberBundleNode"]
            w.selectNodeUponCreation = True
            w.addEnabled = False
            w.removeEnabled = False
            w.noneEnabled = False
            w.showHidden = False
            w.showChildNodeTypes = False
            w.setMRMLScene(slicer.mrmlScene)
            w.setToolTip("Pick the fiber bundle to export.")
            parametersFormLayout.addRow("Input FiberBundleNode: ",
                                        self.inputSelector)

        #
        # tube radius controller
        #
        with It(ctk.ctkSliderWidget()) as w:
            self.radiusSelector = w
            w.minimum = 0.1
            w.maximum = 20.0
            w.singleStep = 0.1
            w.setToolTip("Select radius for output tubes")
            parametersFormLayout.addRow("Tube radius: ", self.radiusSelector)

        with It(ctk.ctkSliderWidget()) as w:
            self.numSidesSelector = w
            w.value = 6
            w.decimals = 0
            w.minimum = 3
            w.maximum = 20
            w.singleStep = 1
            w.pageStep = 1
            w.setToolTip(
                "Select number of sides for output tube: higher number will look nicer, but will take more memory and time to export."
            )
            parametersFormLayout.addRow("Number of sides: ",
                                        self.numSidesSelector)

        #
        # use native scalar range
        #
        with It(qt.QCheckBox()) as w:
            self.nativeRangeCheckbox = w
            w.checked = True
            w.setToolTip(
                "Checked: set the scalar range of the exported color table to match the scalar range of the selected node. Otherwise, the range will be set to [0,1]."
            )
            parametersFormLayout.addRow("Restrict scalar range", w)

        #
        # output file selector, export button, and status frame
        #
        with It(ctk.ctkPathLineEdit()) as w:
            self.outputFileSelector = w
            # make a file-only, save dialog
            w.filters = ctk.ctkPathLineEdit.Files | ctk.ctkPathLineEdit.Writable
            w.connect('currentPathChanged(const QString&)', self.reset)
            parametersFormLayout.addRow("Output File: ",
                                        self.outputFileSelector)

        with It(qt.QPushButton("Export")) as w:
            self.exportButton = w
            w.toolTip = "Run Export"
            w.styleSheet = "background: lightgray"
            w.connect('clicked(bool)', self.onExport)
            parametersFormLayout.addRow("", w)

        with It(qt.QStatusBar()) as w:
            self.statusLabel = w
            w.setToolTip("CLI status")
            w.styleSheet = "background: lightgray"
            parametersFormLayout.addRow("Status: ", w)

        # Add vertical spacer
        self.layout.addStretch(1)
 def statusBar(self):
     self._statusBar = getattr(self, "_statusBar", None)
     if not self._statusBar:
         self._statusBar = qt.QStatusBar()
     return self._statusBar