Exemplo n.º 1
0
 def __init__(self, *var, **kw):
     original = kw['standalonesave']
     kw['standalonesave'] = False
     ExternalImagesWindow.ExternalImagesWindow.__init__(self, *var, **kw)
     standalonesave = original
     if standalonesave:
         MaskImageWidget.MaskImageWidget.buildStandaloneSaveMenu(self)
     self.backgroundIcon = qt.QIcon(qt.QPixmap(IconDict["subtract"]))
     infotext = 'Toggle background image subtraction from current image\n'
     infotext += 'No action if no background image available.'
     self.backgroundIcon = qt.QIcon(qt.QPixmap(IconDict["subtract"]))
     self.backgroundButton = self.graphWidget._addToolButton(\
                                 self.backgroundIcon,
                                 self.subtractBackground,
                                 infotext,
                                 toggle = True,
                                 state = False,
                                 position = 6)
     self.buildAndConnectImageButtonBox()
     self._toggleSelectionMode()
     self._medianParameters = {
         'use': True,
         'row_width': 1,
         'column_width': 1
     }
     self._medianParametersWidget = MedianParameters(self)
     self._medianParametersWidget.widthSpin.setValue(1)
     self.layout().addWidget(self._medianParametersWidget)
     self.connect(self._medianParametersWidget.widthSpin,
                  qt.SIGNAL('valueChanged(int)'), self.setKernelWidth)
Exemplo n.º 2
0
 def load(self):
     if PyMcaDirs.nativeFileDialogs:
         filedialog = qt.QFileDialog(self)
         filedialog.setFileMode(filedialog.ExistingFiles)
         filedialog.setWindowIcon(qt.QIcon(qt.QPixmap(Icons.IconDict["gioconda16"])))
         initdir = os.path.curdir
         if self.initDir is not None:
             if os.path.isdir(self.initDir):
                 initdir = self.initDir
         filename = filedialog.getOpenFileName(
                     self,
                     "Choose fit configuration file",
                     initdir,
                     "Fit configuration files (*.cfg)\nAll Files (*)")
         filename = qt.safe_str(filename)
         if len(filename):
             self.loadConfiguration(filename)
             self.initDir = os.path.dirname(filename)
     else:
         filedialog = qt.QFileDialog(self)
         filedialog.setFileMode(filedialog.ExistingFiles)
         filedialog.setWindowIcon(qt.QIcon(qt.QPixmap(Icons.IconDict["gioconda16"])))
         initdir = os.path.curdir
         if self.initDir is not None:
             if os.path.isdir(self.initDir):
                 initdir = self.initDir
         filename = filedialog.getOpenFileName(
                     self,
                     "Choose fit configuration file",
                     initdir,
                     "Fit configuration files (*.cfg)\nAll Files (*)")
         filename = qt.safe_str(filename)
         if len(filename):
             self.loadConfiguration(filename)
             self.initDir = os.path.dirname(filename)
Exemplo n.º 3
0
 def __init__(self,
              parent=None,
              name="Mca to Edf Conversion",
              fl=qt.Qt.WDestructiveClose,
              filelist=None,
              outputdir=None,
              actions=0):
     if qt.qVersion() < '4.0.0':
         qt.QWidget.__init__(self, parent, name, fl)
         self.setIcon(qt.QPixmap(IconDict['gioconda16']))
         self.setCaption(name)
     else:
         qt.QWidget.__init__(self, parent)
         self.setWindowTitle(name)
         self.setWindowIcon(qt.QIcon(qt.QPixmap(IconDict['gioconda16'])))
     self.mainLayout = qt.QVBoxLayout(self)
     self.mainLayout.setMargin(0)
     self.mainLayout.setSpacing(0)
     #layout.setAutoAdd(1)
     self.__build(actions)
     if filelist is None: filelist = []
     self.outputDir = None
     self.inputDir = None
     self.setFileList(filelist)
     self.setOutputDir(outputdir)
Exemplo n.º 4
0
def uic_load_pixmap_RadioField(name):
    pix = qt.QPixmap()
    m = qt.QMimeSourceFactory.defaultFactory().data(name)

    if m:
        qt.QImageDrag.decode(m, pix)

    return pix
Exemplo n.º 5
0
def uic_load_pixmap_FitActionsGUI(name):
    pix = qt.QPixmap()
    if QTVERSION < '4.0.0':
        m = qt.QMimeSourceFactory.defaultFactory().data(name)
        if m:
            qt.QImageDrag.decode(m, pix)

    return pix
Exemplo n.º 6
0
 def initIcons(self):
     self.Icons = {}
     for (name, icon) in IconDict.items():
         pixmap = qt.QPixmap(icon)
         if QTVERSION < '4.0.0':
             self.Icons[name] = qt.QIconSet(pixmap)
         else:
             self.Icons[name] = qt.QIcon(pixmap)
Exemplo n.º 7
0
 def save(self):
     if self.initDir is None:
         self.initDir = PyMcaDirs.outputDir
     if PyMcaDirs.nativeFileDialogs:
         filedialog = qt.QFileDialog(self)
         filedialog.setFileMode(filedialog.AnyFile)
         filedialog.setWindowIcon(qt.QIcon(qt.QPixmap(Icons.IconDict["gioconda16"])))
         initdir = os.path.curdir
         if self.initDir is not None:
             if os.path.isdir(self.initDir):
                 initdir = self.initDir
         filename = filedialog.getSaveFileName(
                     self,
                     "Enter output fit configuration file",
                     initdir,
                     "Fit configuration files (*.cfg)\nAll Files (*)")
         filename = qt.safe_str(filename)
         if len(filename):
             if len(filename) < 4:
                 filename = filename+".cfg"
             elif filename[-4:] != ".cfg":
                 filename = filename+".cfg"
             self.saveConfiguration(filename)
             self.initDir = os.path.dirname(filename)
     else:
         filedialog = qt.QFileDialog(self)
         filedialog.setFileMode(filedialog.AnyFile)
         filedialog.setWindowIcon(qt.QIcon(qt.QPixmap(Icons.IconDict["gioconda16"])))
         initdir = os.path.curdir
         if self.initDir is not None:
             if os.path.isdir(self.initDir):
                 initdir = self.initDir
         filename = filedialog.getSaveFileName(
                     self,
                     "Enter output fit configuration file",
                     initdir,
                     "Fit configuration files (*.cfg)\nAll Files (*)")
         filename = qt.safe_str(filename)
         if len(filename):
             if len(filename) < 4:
                 filename = filename+".cfg"
             elif filename[-4:] != ".cfg":
                 filename = filename+".cfg"
             self.saveConfiguration(filename)
             self.initDir = os.path.dirname(filename)
             PyMcaDirs.outputDir = os.path.dirname(filename)
Exemplo n.º 8
0
    def __init__(self, parent=None, n=1):
        qt.QWidget.__init__(self, parent)
        self.mainLayout = qt.QHBoxLayout(self)
        self.mainLayout.setMargin(0)
        self.mainLayout.setSpacing(0)
        self.firstButton = qt.QPushButton(self)
        self.firstButton.setIcon(qt.QIcon(qt.QPixmap(icon_first)))
        self.previousButton = qt.QPushButton(self)
        self.previousButton.setIcon(qt.QIcon(qt.QPixmap(icon_previous)))
        self.lineEdit = qt.QLineEdit(self)
        self.lineEdit.setFixedWidth(self.lineEdit.fontMetrics().width('%05d' %
                                                                      n))
        validator = qt.QIntValidator(1, n, self.lineEdit)
        self.lineEdit.setText("1")
        self._oldIndex = 0
        self.lineEdit.setValidator(validator)
        self.label = qt.QLabel(self)
        self.label.setText("of %d" % n)
        self.nextButton = qt.QPushButton(self)
        self.nextButton.setIcon(qt.QIcon(qt.QPixmap(icon_next)))
        self.lastButton = qt.QPushButton(self)
        self.lastButton.setIcon(qt.QIcon(qt.QPixmap(icon_last)))

        self.mainLayout.addWidget(qt.HorizontalSpacer(self))
        self.mainLayout.addWidget(self.firstButton)
        self.mainLayout.addWidget(self.previousButton)
        self.mainLayout.addWidget(self.lineEdit)
        self.mainLayout.addWidget(self.label)
        self.mainLayout.addWidget(self.nextButton)
        self.mainLayout.addWidget(self.lastButton)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self))

        self.connect(self.firstButton, qt.SIGNAL("clicked()"),
                     self._firstClicked)

        self.connect(self.previousButton, qt.SIGNAL("clicked()"),
                     self._previousClicked)

        self.connect(self.nextButton, qt.SIGNAL("clicked()"),
                     self._nextClicked)

        self.connect(self.lastButton, qt.SIGNAL("clicked()"),
                     self._lastClicked)

        self.connect(self.lineEdit, qt.SIGNAL("editingFinished()"),
                     self._textChangedSlot)
Exemplo n.º 9
0
 def getHeader(self, addlink=None):
     link = [['http://pymca.sourceforge.net', 'PyMCA home'],
             ['http://www.esrf.fr', 'ESRF home'],
             [
                 'http://www.esrf.fr/UsersAndScience/Experiments/TBS/BLISS',
                 'BLISS home'
             ]]
     if self.concentrations is not None:
         link.append(['#Concentrations', 'Concentrations'])
     if self.tableFlag:
         link.append(['#Fit_Peak_Results', 'Fit Peak Results'])
     if addlink is not None:
         for item in addlink:
             link.append(item)
     text = ""
     text += "<HTML>"
     text += "<HEAD>"
     text += "<TITLE>PyMCA : Advanced Fit Results</TITLE>"
     text += "</HEAD>"
     text += "<BODY TEXT=#000000 BGCOLOR=#FFFFFF ALINK=#ff6600 LINK=#0000cc VLINK=#0000cc marginwidth=10 marginheight=10  topmargin=10 leftmargin=10>"
     text += "<CENTER>"
     text += "<TABLE WIDTH=100%% border=0 Height=70>"
     text += "  <TR>"
     text += "    <TD><Font Size=5 Color=#0000cc>"
     text += "        <b>PyMCA : Advanced Fit Results</b></Font>"
     text += "    </td>"
     text += "    <td rowspan=2 ALIGN=RIGHT VALIGN=bottom>"
     text += "        <a HREF=" "http://www.esrf.fr/" ">"
     logofile = self.outdir + "/" + "PyMcaLogo.png"
     if not os.path.exists(logofile):
         pixmap = qt.QPixmap(PyMcaLogo.PyMcaLogo)
         pixmap.save(logofile, "PNG")
     text += "        <img SRC=%s ALT=" "ESRF home" " WIDTH=55 HEIGHT=68 BORDER=0></a>" % "PyMcaLogo.png"
     text += "    </td>"
     text += "  </tr>"
     text += "  <tr>"
     text += "     <td width=100%%  VALIGN=bottom>"
     text += "        <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%%>"
     text += "          <TR>"
     text += "            <TD WIDTH=100%% BGCOLOR=#ee22aa HEIGHT=17  ALIGN=LEFT VALIGN=middle>"
     text += "            <FONT color=#000000>&nbsp;"
     for name in link:
         text += "|&nbsp;&nbsp;<A STYLE=" "color: #FFFFFF" " HREF=" "%s" ">%s</a>&nbsp;&nbsp;" % (
             tuple(name))
     text += "            </FONT>"
     text += "            </TD>"
     text += "          </TR>"
     text += "        </TABLE>"
     text += "     </td>"
     text += "  </tr>"
     text += "  <tr>"
     text += "     <td colspan=2 height=5><spacer type=block height=10 width=0>"
     text += "     </td>"
     text += "  </tr>"
     text += "</table>"
     text += "</center>"
     return text
Exemplo n.º 10
0
 def __init__(self, parent=None, file_browser=True):
     qt.QWidget.__init__(self, parent)
     self.setWindowTitle("PyMca Simple Fit Batch GUI")
     self.setWindowIcon(qt.QIcon(qt.QPixmap(IconDict['gioconda16'])))
     self.mainLayout = qt.QGridLayout(self)
     self.mainLayout.setMargin(2)
     self.mainLayout.setSpacing(2)
     self._inputDir = None
     self._outputDir = None
     self._lastInputFileFilter = None
     self._fileList = []
     self._build(file_browser)
Exemplo n.º 11
0
    def _build(self):
        self.layout = qt.QHBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.label = None
        self.button = None
        if (self.boolTitle):
            self.label = qt.QLabel(self.textTitle, self)
            self.label.setMinimumWidth(200)
            self.layout.addWidget(self.label)
        if (self.boolIcons):
            self.save = qt.QPushButton()
            self.saveas = qt.QPushButton()
            self.load = qt.QPushButton()

            self.save.setMaximumWidth(30)
            self.saveas.setMaximumWidth(30)
            self.load.setMaximumWidth(30)
            self.save.setMaximumHeight(30)
            self.saveas.setMaximumHeight(30)
            self.load.setMaximumHeight(30)

            self.save.setFlat(True)
            self.saveas.setFlat(True)
            self.load.setFlat(True)

            if self.pathIcon1 != '':
                self.save.setIcon(qt.QIcon(qt.QPixmap(self.pathIcon1)))

            if self.pathIcon2 != '':
                self.saveas.setIcon(qt.QIcon(qt.QPixmap(self.pathIcon2)))

            if self.pathIcon3 != '':
                self.load.setIcon(qt.QIcon(qt.QPixmap(self.pathIcon3)))

            self.layout.addWidget(self.save)
            self.layout.addWidget(self.saveas)
            self.layout.addWidget(self.load)

        self.setLayout(self.layout)
Exemplo n.º 12
0
 def saveGraphImage(self, filename, original=False):
     format_ = filename[-3:].upper()
     if original:
         #This is the whole image, not the zoomed one ...
         if QTVERSION < '4.0.0':
             pixmap = qt.QPixmap(self.graph.plotImage.image)
         else:
             pixmap = qt.QPixmap.fromImage(self.graph.plotImage.image)
     else:
         pixmap = qt.QPixmap.grabWidget(self.graph.canvas())
     if pixmap.save(filename, format_):
         return
     else:
         qt.QMessageBox.critical(self, "Save Error",
                                 "%s" % sys.exc_info()[1])
         return
Exemplo n.º 13
0
def testPreview():
    """
    """
    import sys
    import os.path

    if len(sys.argv) < 2:
        print("give an image file as parameter please.")
        sys.exit(1)

    if len(sys.argv) > 2:
        print("only one parameter please.")
        sys.exit(1)

    filename = sys.argv[1]

    a = qt.QApplication(sys.argv)

    p = qt.QPrinter()
    p.setOutputFileName(os.path.splitext(filename)[0] + ".ps")
    p.setColorMode(qt.QPrinter.Color)

    w = PyMcaPrintPreview(parent=None,
                          printer=p,
                          name='Print Prev',
                          modal=0,
                          fl=0)
    w.resize(400, 500)
    if QTVERSION < '4.0.0':
        w.addPixmap(qt.QPixmap(qt.QImage(filename)))
    else:
        w.addPixmap(qt.QPixmap.fromImage(qt.QImage(filename)))
    w.addImage(qt.QImage(filename))
    if 0:
        w2 = PyMcaPrintPreview(parent=None,
                               printer=p,
                               name='2Print Prev',
                               modal=0,
                               fl=0)
        w.exec_()
        w2.resize(100, 100)
        w2.show()
        sys.exit(w2.exec_())
    if QTVERSION < '4.0.0':
        sys.exit(w.exec_loop())
    else:
        sys.exit(w.exec_())
Exemplo n.º 14
0
    def __init__(self, *var, **kw):
        ddict = {}
        ddict['usetab'] = True
        ddict.update(kw)
        ddict['standalonesave'] = False
        MaskImageWidget.MaskImageWidget.__init__(self, *var, **ddict)
        self.slider = qt.QSlider(self)
        self.slider.setOrientation(qt.Qt.Horizontal)
        self.slider.setMinimum(0)
        self.slider.setMaximum(0)

        # The 1D graph
        self.vectorGraph = ScanWindow.ScanWindow(self)
        self.mainTab.addTab(self.vectorGraph, "VECTORS")

        self.mainLayout.addWidget(self.slider)
        self.connect(self.slider, qt.SIGNAL("valueChanged(int)"),
                     self._showImage)

        self.imageList = None
        self.imageNames = None
        self.eigenValues = None
        self.eigenVectors = None
        self.vectorNames = None
        self.vectorGraphTitles = None
        standalonesave = kw.get("standalonesave", True)
        if standalonesave:
            self.connect(self.graphWidget.saveToolButton,
                         qt.SIGNAL("clicked()"), self._saveToolButtonSignal)
            self._saveMenu = qt.QMenu()
            self._saveMenu.addAction(qt.QString("Image Data"),
                                     self.saveImageList)
            self._saveMenu.addAction(qt.QString("Standard Graphics"),
                                     self.graphWidget._saveIconSignal)
            if QTVERSION > '4.0.0':
                if MATPLOTLIB:
                    self._saveMenu.addAction(qt.QString("Matplotlib"),
                                             self._saveMatplotlibImage)
        self.multiplyIcon = qt.QIcon(qt.QPixmap(IconDict["swapsign"]))
        infotext = "Multiply image by -1"
        self.multiplyButton = self.graphWidget._addToolButton(\
                                        self.multiplyIcon,
                                        self._multiplyIconChecked,
                                        infotext,
                                        toggle=False,
                                        position=12)
Exemplo n.º 15
0
 def __init__(self, parent = None, fit=None):
     qt.QDialog.__init__(self, parent)
     self.setWindowTitle("PyMca - Simple Fit Configuration")
     self.setWindowIcon(qt.QIcon(qt.QPixmap(Icons.IconDict["gioconda16"])))
     self.mainLayout = qt.QVBoxLayout(self)
     self.mainLayout.setMargin(2)
     self.mainLayout.setSpacing(2)
     if 0:
         self.fitControlWidget = SimpleFitControlWidget.SimpleFitControlWidget(self)
         self.mainLayout.addWidget(self.fitControlWidget)
         self.connect(self.fitControlWidget,
                      qt.SIGNAL("FitControlSignal"),
                      self._fitControlSlot)
         self._stripDialog = None
     else:            
         self.tabWidget = qt.QTabWidget(self)
         self.fitControlWidget = SimpleFitControlWidget.SimpleFitControlWidget(self)
         self.connect(self.fitControlWidget,
                      qt.SIGNAL("FitControlSignal"),
                      self._fitControlSlot)
         self.tabWidget.insertTab(0, self.fitControlWidget, "FIT")
         self.fitFunctionWidgetStack = qt.QWidget(self)
         self.fitFunctionWidgetStack.mainLayout = qt.QStackedLayout(self.fitFunctionWidgetStack)
         self.fitFunctionWidgetStack.mainLayout.setMargin(0)
         self.fitFunctionWidgetStack.mainLayout.setSpacing(0)            
         self.tabWidget.insertTab(1, self.fitFunctionWidgetStack, "FUNCTION")
         self.backgroundWidgetStack = qt.QWidget(self)
         self.backgroundWidgetStack.mainLayout = qt.QStackedLayout(self.backgroundWidgetStack)
         self.backgroundWidgetStack.mainLayout.setMargin(0)
         self.backgroundWidgetStack.mainLayout.setSpacing(0)            
         self.tabWidget.insertTab(2, self.backgroundWidgetStack, "BACKGROUND")
         self.mainLayout.addWidget(self.tabWidget)
         self._stripDialog = None
     self.buildAndConnectActions()
     self.mainLayout.addWidget(qt.VerticalSpacer(self))
     self._fitFunctionWidgets = {}
     self._backgroundWidgets = {}
     self.setSimpleFitInstance(fit)
     #input output directory
     self.initDir = None
Exemplo n.º 16
0
    def __init__(self, parent=None, image=None):
        qt.QWidget.__init__(self, parent)
        self.mainLayout = qt.QGridLayout(self)
        self.mainLayout.setColumnStretch(0, 1)
        self.mainLayout.setColumnStretch(1, 0)
        self.setWindowTitle("PyMca - Matplotlib save image")
        self.setWindowIcon(qt.QIcon(qt.QPixmap(IconDict['gioconda16'])))
        self.lastOutputDir = None
        self.printPreview = PyMcaPrintPreview.PyMcaPrintPreview(modal = 0)

        #top
        self.top = TopWidget(self)
        self.mainLayout.addWidget(self.top, 0, 0)

        #image
        self.imageWidget = QPyMcaMatplotlibImage(self, image)
        self.mainLayout.addWidget(self.imageWidget, 1, 0)

        #right
        self.right = RightWidget(self)
        self.mainLayout.addWidget(self.right, 1, 1)

        #buttons
        self._buttonContainer = ButtonsWidget(self)
        self.mainLayout.addWidget(self._buttonContainer, 0, 1)

        self.connect(self._buttonContainer.updateButton,
                     qt.SIGNAL('clicked()'),
                     self.updateClicked)

        self.connect(self._buttonContainer.printButton,
                     qt.SIGNAL('clicked()'),
                     self.printClicked)

        self.connect(self._buttonContainer.saveButton, qt.SIGNAL('clicked()'),
                     self.saveClicked)
Exemplo n.º 17
0
    def __createInfoWidget(self, symbol=""):
        #Dock window like widget
        frame = qt.QWidget(self.splitter)
        layout = qt.QVBoxLayout(frame)
        layout.setMargin(0)
        layout.setSpacing(0)

        #The dock functionnality
        toolbar = qt.QWidget(frame)
        layout.addWidget(toolbar)
        layout1 = qt.QHBoxLayout(toolbar)
        layout1.setMargin(0)
        layout1.setSpacing(0)
        # --- the line
        if qt.qVersion() < '4.0.0':
            self.line1 = Line(toolbar, "line1")
        else:
            self.line1 = Line(toolbar)
        self.line1.setFrameShape(qt.QFrame.HLine)
        self.line1.setFrameShadow(qt.QFrame.Sunken)
        self.line1.setFrameShape(qt.QFrame.HLine)
        layout1.addWidget(self.line1)

        # --- the close button
        self.closelabel = PixmapLabel(toolbar)
        self.closelabel.setPixmap(qt.QPixmap(CLOSE_ICON))
        layout1.addWidget(self.closelabel)
        self.closelabel.setSizePolicy(
            qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed))

        # --- connections
        if qt.qVersion() < '4.0.0':
            self.connect(self.line1, qt.PYSIGNAL("LineDoubleClickEvent"),
                         self.infoReparent)
            self.connect(self.closelabel,
                         qt.PYSIGNAL("PixmapLabelMousePressEvent"),
                         self.infoToggle)
        else:
            self.connect(self.line1, qt.SIGNAL("LineDoubleClickEvent"),
                         self.infoReparent)
            self.connect(self.closelabel,
                         qt.SIGNAL("PixmapLabelMousePressEvent"),
                         self.infoToggle)

        # --- The text edit widget
        w = qt.QWidget(frame)
        layout.addWidget(w)
        l = qt.QVBoxLayout(w)
        l.setMargin(0)
        l.setSpacing(0)

        hbox = qt.QWidget(w)
        hbox.layout = qt.QHBoxLayout(hbox)
        hbox.layout.setMargin(0)
        hbox.layout.setSpacing(0)
        l.addWidget(hbox)
        hbox.layout.addWidget(qt.HorizontalSpacer(hbox))
        l1 = qt.QLabel(hbox)
        l1.setText('<b><nobr>Excitation Energy (keV)</nobr></b>')
        self.energy = MyQLineEdit(hbox)
        self.energy.setFixedWidth(self.energy.fontMetrics().width('#####.###'))
        self.energy.setText("")
        hbox.layout.addWidget(l1)
        hbox.layout.addWidget(self.energy)
        hbox.layout.addWidget(qt.HorizontalSpacer(hbox))
        self.connect(self.energy, qt.SIGNAL('returnPressed()'),
                     self._energySlot)
        if qt.qVersion() < '4.0.0':
            self.connect(self.energy, qt.PYSIGNAL('focusOut'),
                         self._energySlot)
        else:
            self.connect(self.energy, qt.SIGNAL('focusOut'), self._energySlot)

        self.infoText = qt.QTextEdit(w)
        self.infoText.setReadOnly(1)
        if qt.qVersion() < '4.0.0':
            self.infoText.setText(self.html.gethtml(symbol))
        else:
            self.infoText.clear()
            self.infoText.insertHtml(self.html.gethtml(symbol))
        l.addWidget(self.infoText)
        w.show()
        self.infoWidget = frame
        if qt.qVersion() < '4.0.0':
            self.infoWidget.setSizePolicy(
                qt.QSizePolicy(qt.QSizePolicy.Expanding,
                               qt.QSizePolicy.Expanding))
            self.infoWidget.setMinimumWidth(
                self.infoWidget.sizeHint().width() * 1.8)
        frame.show()
Exemplo n.º 18
0
    def __init__(self, parent=None, name="SPSSelector", fl=0):
        qt.QWidget.__init__(self, parent, name, fl)

        self.dataSource = None

        self.data = None
        self.currentSpec = None
        self.currentArray = None
        self.selection = None
        self.openFile = self.refreshSpecList

        self.selectPixmap = qt.QPixmap(icons.selected)
        self.unselectPixamp = qt.QPixmap(icons.unselected)

        mainLayout = qt.QVBoxLayout(self)

        # --- spec name selection
        specWidget = qt.QWidget(self)
        self.specCombo = qt.QComboBox(specWidget)
        self.specCombo.setEditable(0)
        self.reload = qt.QIconSet(qt.QPixmap(icons.reload))
        refreshButton = qt.QToolButton(specWidget)
        refreshButton.setIconSet(self.reload)
        refreshButton.setSizePolicy(
            qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum))
        self.closeIcon = qt.QIconSet(qt.QPixmap(icons.fileclose))
        closeButton = qt.QToolButton(specWidget)
        closeButton.setIconSet(self.closeIcon)
        closeButton.setSizePolicy(
            qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum))
        specLayout = qt.QHBoxLayout(specWidget)
        specLayout.addWidget(self.specCombo)
        specLayout.addWidget(refreshButton)
        specLayout.addWidget(closeButton)

        self.connect(refreshButton, qt.SIGNAL("clicked()"),
                     self.refreshSpecList)
        self.connect(closeButton, qt.SIGNAL("clicked()"),
                     self.closeCurrentSpec)
        self.connect(self.specCombo, qt.SIGNAL("activated(const QString &)"),
                     self.refreshArrayList)

        # --- splitter
        self.splitter = qt.QSplitter(self)
        self.splitter.setOrientation(qt.QSplitter.Vertical)

        # --- shm array list
        self.arrayList = qt.QListView(self.splitter, "ShmArrayList")
        self.arrayList.addColumn("")
        self.arrayList.addColumn("Array Name")
        self.arrayList.addColumn("Rows")
        self.arrayList.addColumn("Cols")
        self.arrayList.setSorting(-1)
        self.arrayList.header().setClickEnabled(0, -1)
        self.arrayList.setAllColumnsShowFocus(1)
        self.arrayList.setSelectionMode(qt.QListView.Single)

        self.connect(self.arrayList, qt.SIGNAL("selectionChanged()"),
                     self.__arraySelection)

        # --- array parameter
        self.paramIndex = {}
        self.paramWidget = qt.QWidgetStack(self.splitter)
        for type in self.WidgetArrays.keys():
            widclass = self.WidgetArrays[type]
            wid = widclass(self.paramWidget)
            self.paramWidget.addWidget(wid)
            self.paramIndex[type] = self.paramWidget.id(wid)

        # --- command buttons
        butWidget = qt.QWidget(self)
        butWidget.setSizePolicy(
            qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum))
        addButton = qt.QPushButton("Add", butWidget)
        removeButton = qt.QPushButton("Remove", butWidget)
        replaceButton = qt.QPushButton("Replace", butWidget)

        butLayout = qt.QHBoxLayout(butWidget)
        butLayout.addWidget(removeButton)
        butLayout.addWidget(replaceButton)
        butLayout.addWidget(addButton)
        butLayout.setMargin(5)

        self.connect(addButton, qt.SIGNAL("clicked()"), self.__addClicked)
        self.connect(replaceButton, qt.SIGNAL("clicked()"),
                     self.__replaceClicked)
        self.connect(removeButton, qt.SIGNAL("clicked()"),
                     self.__removeClicked)

        # --- main layout
        mainLayout.setMargin(5)
        mainLayout.setSpacing(5)
        mainLayout.addWidget(specWidget)
        mainLayout.addWidget(self.splitter)
        mainLayout.addWidget(butWidget)
Exemplo n.º 19
0
 def _pluginClicked(self):
     actionList = []
     menu = qt.QMenu(self)
     text = qt.QString("Reload")
     menu.addAction(text)
     actionList.append(text)
     menu.addSeparator()
     callableKeys = ["Dummy"]
     for m in self.pluginList:
         if m == "PyMcaPlugins.Plugin1DBase":
             continue
         module = sys.modules[m]
         if hasattr(module, 'MENU_TEXT'):
             text = qt.QString(module.MENU_TEXT)
         else:
             text = os.path.basename(module.__file__)
             if text.endswith('.pyc'):
                 text = text[:-4]
             elif text.endswith('.py'):
                 text = text[:-3]
             text = qt.QString(text)
         methods = self.pluginInstanceDict[m].getMethods(plottype="SCAN")
         if not len(methods):
             continue
         menu.addAction(text)
         actionList.append(text)
         callableKeys.append(m)
     a = menu.exec_(qt.QCursor.pos())
     if a is None:
         return None
     idx = actionList.index(a.text())
     if idx == 0:
         n = self.getPlugins()
         if n < 1:
             msg = qt.QMessageBox(self)
             msg.setIcon(qt.QMessageBox.Information)
             msg.setText("Problem loading plugins")
             msg.exec_()
         return
     key = callableKeys[idx]
     methods = self.pluginInstanceDict[key].getMethods(plottype="SCAN")
     if len(methods) == 1:
         idx = 0
     else:
         actionList = []
         methods.sort()
         menu = qt.QMenu(self)
         for method in methods:
             text = qt.QString(method)
             pixmap = self.pluginInstanceDict[key].getMethodPixmap(method)
             tip = qt.QString(
                 self.pluginInstanceDict[key].getMethodToolTip(method))
             if pixmap is not None:
                 action = qt.QAction(qt.QIcon(qt.QPixmap(pixmap)), text,
                                     self)
             else:
                 action = qt.QAction(text, self)
             if tip is not None:
                 action.setToolTip(tip)
             menu.addAction(action)
             actionList.append((text, pixmap, tip, action))
         qt.QObject.connect(menu, qt.SIGNAL("hovered(QAction *)"),
                            self._actionHovered)
         a = menu.exec_(qt.QCursor.pos())
         if a is None:
             return None
         idx = -1
         for action in actionList:
             if a.text() == action[0]:
                 idx = actionList.index(action)
     try:
         self.pluginInstanceDict[key].applyMethod(methods[idx])
     except:
         msg = qt.QMessageBox(self)
         msg.setIcon(qt.QMessageBox.Critical)
         if QTVERSION < '4.0.0':
             msg.setText("%s" % sys.exc_info()[1])
         else:
             msg.setWindowTitle("Plugin error")
             msg.setText("An error has occured while executing the plugin:")
             msg.setInformativeText(str(sys.exc_info()[1]))
             msg.setDetailedText(traceback.format_exc())
         msg.exec_()
Exemplo n.º 20
0
    def _initIcons(self):
        if QTVERSION < '4.0.0':
            self.normalIcon = qt.QIconSet(qt.QPixmap(IconDict["normal"]))
            self.zoomIcon = qt.QIconSet(qt.QPixmap(IconDict["zoom"]))
            self.roiIcon = qt.QIconSet(qt.QPixmap(IconDict["roi"]))
            self.peakIcon = qt.QIconSet(qt.QPixmap(IconDict["peak"]))

            self.zoomResetIcon = qt.QIconSet(qt.QPixmap(IconDict["zoomreset"]))
            self.roiResetIcon = qt.QIconSet(qt.QPixmap(IconDict["roireset"]))
            self.peakResetIcon = qt.QIconSet(qt.QPixmap(IconDict["peakreset"]))
            self.refreshIcon = qt.QIconSet(qt.QPixmap(IconDict["reload"]))

            self.logxIcon = qt.QIconSet(qt.QPixmap(IconDict["logx"]))
            self.logyIcon = qt.QIconSet(qt.QPixmap(IconDict["logy"]))
            self.xAutoIcon = qt.QIconSet(qt.QPixmap(IconDict["xauto"]))
            self.yAutoIcon = qt.QIconSet(qt.QPixmap(IconDict["yauto"]))
            self.togglePointsIcon = qt.QIconSet(
                qt.QPixmap(IconDict["togglepoints"]))
            self.fitIcon = qt.QIconSet(qt.QPixmap(IconDict["fit"]))
            self.searchIcon = qt.QIconSet(qt.QPixmap(IconDict["peaksearch"]))

            self.averageIcon = qt.QIconSet(qt.QPixmap(IconDict["average16"]))
            self.deriveIcon = qt.QIconSet(qt.QPixmap(IconDict["derive"]))
            self.smoothIcon = qt.QIconSet(qt.QPixmap(IconDict["smooth"]))
            self.swapSignIcon = qt.QIconSet(qt.QPixmap(IconDict["swapsign"]))
            self.yMinToZeroIcon = qt.QIconSet(
                qt.QPixmap(IconDict["ymintozero"]))
            self.subtractIcon = qt.QIconSet(qt.QPixmap(IconDict["subtract"]))
            self.printIcon = qt.QIconSet(qt.QPixmap(IconDict["fileprint"]))
            self.saveIcon = qt.QIconSet(qt.QPixmap(IconDict["filesave"]))
        else:
            self.normalIcon = qt.QIcon(qt.QPixmap(IconDict["normal"]))
            self.zoomIcon = qt.QIcon(qt.QPixmap(IconDict["zoom"]))
            self.roiIcon = qt.QIcon(qt.QPixmap(IconDict["roi"]))
            self.peakIcon = qt.QIcon(qt.QPixmap(IconDict["peak"]))

            self.zoomResetIcon = qt.QIcon(qt.QPixmap(IconDict["zoomreset"]))
            self.roiResetIcon = qt.QIcon(qt.QPixmap(IconDict["roireset"]))
            self.peakResetIcon = qt.QIcon(qt.QPixmap(IconDict["peakreset"]))
            self.refreshIcon = qt.QIcon(qt.QPixmap(IconDict["reload"]))

            self.logxIcon = qt.QIcon(qt.QPixmap(IconDict["logx"]))
            self.logyIcon = qt.QIcon(qt.QPixmap(IconDict["logy"]))
            self.xAutoIcon = qt.QIcon(qt.QPixmap(IconDict["xauto"]))
            self.yAutoIcon = qt.QIcon(qt.QPixmap(IconDict["yauto"]))
            self.togglePointsIcon = qt.QIcon(
                qt.QPixmap(IconDict["togglepoints"]))

            self.fitIcon = qt.QIcon(qt.QPixmap(IconDict["fit"]))
            self.searchIcon = qt.QIcon(qt.QPixmap(IconDict["peaksearch"]))

            self.averageIcon = qt.QIcon(qt.QPixmap(IconDict["average16"]))
            self.deriveIcon = qt.QIcon(qt.QPixmap(IconDict["derive"]))
            self.smoothIcon = qt.QIcon(qt.QPixmap(IconDict["smooth"]))
            self.swapSignIcon = qt.QIcon(qt.QPixmap(IconDict["swapsign"]))
            self.yMinToZeroIcon = qt.QIcon(qt.QPixmap(IconDict["ymintozero"]))
            self.subtractIcon = qt.QIcon(qt.QPixmap(IconDict["subtract"]))

            self.printIcon = qt.QIcon(qt.QPixmap(IconDict["fileprint"]))
            self.saveIcon = qt.QIcon(qt.QPixmap(IconDict["filesave"]))

            self.pluginIcon = qt.QIcon(qt.QPixmap(IconDict["plugin"]))
Exemplo n.º 21
0
 def _fitControlSlot(self, ddict):
     if DEBUG:
         print("FitControlSignal", ddict)
     event = ddict['event']
     if event == "stripSetupCalled":
         if self._stripDialog is None:
             self._stripDialog = StripBackgroundWidget.StripBackgroundDialog()
             self._stripDialog.setWindowIcon(qt.QIcon(\
                                 qt.QPixmap(Icons.IconDict["gioconda16"])))
         pars = self.__getConfiguration("FIT")
         if self.simpleFitInstance is None:
             return
         xmin = pars['xmin']
         xmax = pars['xmax']
         idx = (self.simpleFitInstance._x0 >= xmin) & (self.simpleFitInstance._x0 <= xmax)
         x = self.simpleFitInstance._x0[idx] * 1
         y = self.simpleFitInstance._y0[idx] * 1
         self._stripDialog.setParameters(pars)
         self._stripDialog.setData(x, y)
         ret = self._stripDialog.exec_()
         if not ret:
             return
         pars = self._stripDialog.getParameters()
         self.fitControlWidget.setConfiguration(pars)
         
     if event == "fitFunctionChanged":
         functionName = ddict['fit_function']
         if functionName in [None, "None", "NONE"]:
             functionName = "None"
             instance = self._fitFunctionWidgets.get(functionName, None)
             if instance is None:
                 instance = qt.QWidget(self.fitFunctionWidgetStack)
                 self.fitFunctionWidgetStack.mainLayout.addWidget(instance)
                 self._fitFunctionWidgets[functionName] = instance
             self.fitFunctionWidgetStack.mainLayout.setCurrentWidget(instance)
             return
         fun = self.simpleFitInstance._fitConfiguration['functions'][functionName]
         instance = self._fitFunctionWidgets.get(functionName, None)
         if instance is None:
             widget = fun.get('widget', None)
             if widget is None:
                 instance = self._buildDefaultWidget(functionName, background=False)
             else:
                 instance = widget(self.fitFunctionWidgetStack)
                 self.fitFunctionWidgetStack.mainLayout.addWidget(instance)
             self._fitFunctionWidgets[functionName] = instance
         if hasattr(instance, 'configure'):
             configureMethod = fun['configure']
             if configureMethod is not None:
                 #make sure it is up-to-date
                 fun['configuration'].update(configureMethod())
                 instance.configure(fun)
         self.fitFunctionWidgetStack.mainLayout.setCurrentWidget(instance)
         
     if event == "backgroundFunctionChanged":
         functionName = ddict['background_function']
         if functionName in [None, "None", "NONE"]:
             functionName = "None"
             instance = self._backgroundWidgets.get(functionName, None)
             if instance is None:
                 instance = qt.QWidget(self.backgroundWidgetStack)
                 self.backgroundWidgetStack.mainLayout.addWidget(instance)
                 self._backgroundWidgets[functionName] = instance
             self.backgroundWidgetStack.mainLayout.setCurrentWidget(instance)
             return
         fun = self.simpleFitInstance._fitConfiguration['functions'][functionName]
         instance = self._backgroundWidgets.get(functionName, None)
         if instance is None:
             widget = fun.get('widget', None)
             if widget is None:
                 instance = self._buildDefaultWidget(functionName, background=True)
             else:
                 instance = widget(self.backgroundWidgetStack)
                 self.backgroundWidgetStack.mainLayout.addWidget(instance)
             self._backgroundWidgets[functionName] = instance
         if hasattr(instance, 'configure'):
             configureMethod = fun['configure']
             if configureMethod is not None:
                 #make sure it is up-to-date
                 fun['configuration'].update(configureMethod())
                 instance.configure(fun)
         self.backgroundWidgetStack.mainLayout.setCurrentWidget(instance)
Exemplo n.º 22
0
    def _buildToolBar(self,
                      selection=False,
                      colormap=False,
                      imageicons=False,
                      standalonesave=True,
                      standalonezoom=True,
                      profileselection=False):
        if QTVERSION < '4.0.0':
            if qt.qVersion() < '3.0':
                self.colormapIcon = qt.QIconSet(
                    qt.QPixmap(IconDict["colormap16"]))
            else:
                self.colormapIcon = qt.QIconSet(
                    qt.QPixmap(IconDict["colormap"]))
            self.selectionIcon = qt.QIconSet(qt.QPixmap(IconDict["normal"]))
            self.zoomResetIcon = qt.QIconSet(qt.QPixmap(IconDict["zoomreset"]))
            self.printIcon = qt.QIconSet(qt.QPixmap(IconDict["fileprint"]))
            self.saveIcon = qt.QIconSet(qt.QPixmap(IconDict["filesave"]))
            self.xAutoIcon = qt.QIconSet(qt.QPixmap(IconDict["xauto"]))
            self.yAutoIcon = qt.QIconSet(qt.QPixmap(IconDict["yauto"]))
            self.imageIcon = qt.QIconSet(qt.QPixmap(IconDict["image"]))
            self.eraseSelectionIcon = qt.QIconSet(
                qt.QPixmap(IconDict["eraseselect"]))
            self.rectSelectionIcon = qt.QIconSet(
                qt.QPixmap(IconDict["boxselect"]))
            self.brushSelectionIcon = qt.QIconSet(
                qt.QPixmap(IconDict["brushselect"]))
            self.brushIcon = qt.QIconSet(qt.QPixmap(IconDict["brush"]))
            self.hFlipIcon = qt.QIconSet(
                qt.QPixmap(IconDict["gioconda16mirror"]))
        else:
            self.colormapIcon = qt.QIcon(qt.QPixmap(IconDict["colormap"]))
            self.selectionIcon = qt.QIcon(qt.QPixmap(IconDict["normal"]))
            self.zoomResetIcon = qt.QIcon(qt.QPixmap(IconDict["zoomreset"]))
            self.printIcon = qt.QIcon(qt.QPixmap(IconDict["fileprint"]))
            self.saveIcon = qt.QIcon(qt.QPixmap(IconDict["filesave"]))
            self.xAutoIcon = qt.QIcon(qt.QPixmap(IconDict["xauto"]))
            self.yAutoIcon = qt.QIcon(qt.QPixmap(IconDict["yauto"]))
            self.hFlipIcon = qt.QIcon(qt.QPixmap(IconDict["gioconda16mirror"]))
            self.imageIcon = qt.QIcon(qt.QPixmap(IconDict["image"]))
            self.eraseSelectionIcon = qt.QIcon(
                qt.QPixmap(IconDict["eraseselect"]))
            self.rectSelectionIcon = qt.QIcon(qt.QPixmap(
                IconDict["boxselect"]))
            self.brushSelectionIcon = qt.QIcon(
                qt.QPixmap(IconDict["brushselect"]))
            self.brushIcon = qt.QIcon(qt.QPixmap(IconDict["brush"]))
            self.additionalIcon = qt.QIcon(
                qt.QPixmap(IconDict["additionalselect"]))
            self.hLineIcon = qt.QIcon(qt.QPixmap(IconDict["horizontal"]))
            self.vLineIcon = qt.QIcon(qt.QPixmap(IconDict["vertical"]))
            self.lineIcon = qt.QIcon(qt.QPixmap(IconDict["diagonal"]))

        self.toolBar = qt.QWidget(self)
        self.toolBarLayout = qt.QHBoxLayout(self.toolBar)
        self.toolBarLayout.setMargin(0)
        self.toolBarLayout.setSpacing(0)
        self.mainLayout.addWidget(self.toolBar)
        #Autoscale
        if standalonezoom:
            tb = self._addToolButton(self.zoomResetIcon, self._zoomReset,
                                     'Auto-Scale the Graph')
        else:
            tb = self._addToolButton(self.zoomResetIcon, None,
                                     'Auto-Scale the Graph')
        self.zoomResetToolButton = tb
        #y Autoscale
        tb = self._addToolButton(self.yAutoIcon,
                                 self._yAutoScaleToggle,
                                 'Toggle Autoscale Y Axis (On/Off)',
                                 toggle=True,
                                 state=True)
        if qt.qVersion() < '4.0.0':
            tb.setState(qt.QButton.On)
        else:
            tb.setDown(True)
        self.yAutoScaleToolButton = tb
        tb.setDown(True)

        #x Autoscale
        tb = self._addToolButton(self.xAutoIcon,
                                 self._xAutoScaleToggle,
                                 'Toggle Autoscale X Axis (On/Off)',
                                 toggle=True,
                                 state=True)
        self.xAutoScaleToolButton = tb
        tb.setDown(True)

        #colormap
        if colormap:
            tb = self._addToolButton(self.colormapIcon, None,
                                     'Change Colormap')
            self.colormapToolButton = tb

        #flip
        tb = self._addToolButton(self.hFlipIcon, None, 'Flip Horizontal')
        self.hFlipToolButton = tb

        #save
        if standalonesave:
            tb = self._addToolButton(self.saveIcon, self._saveIconSignal,
                                     'Save Graph')
        else:
            tb = self._addToolButton(self.saveIcon, None, 'Save')
        self.saveToolButton = tb

        #Selection
        if selection:
            tb = self._addToolButton(self.selectionIcon,
                                     None,
                                     'Toggle Selection Mode',
                                     toggle=True,
                                     state=False)
            if qt.qVersion() < '4.0.0':
                tb.setState(qt.QButton.Off)
            else:
                tb.setDown(False)
            self.selectionToolButton = tb
        #image selection icons
        if imageicons:
            tb = self._addToolButton(self.imageIcon, None, 'Reset')
            self.imageToolButton = tb

            tb = self._addToolButton(self.eraseSelectionIcon, None,
                                     'Erase Selection')
            self.eraseSelectionToolButton = tb

            tb = self._addToolButton(self.rectSelectionIcon, None,
                                     'Rectangular Selection')
            self.rectSelectionToolButton = tb

            tb = self._addToolButton(self.brushSelectionIcon, None,
                                     'Brush Selection')
            self.brushSelectionToolButton = tb

            tb = self._addToolButton(self.brushIcon, None, 'Select Brush')
            self.brushToolButton = tb
            if QTVERSION > '4.0.0':
                tb = self._addToolButton(self.additionalIcon, None,
                                         'Additional Selections Menu')
                self.additionalSelectionToolButton = tb
        else:
            self.imageToolButton = None

        #picker selection
        self._pickerSelectionButtons = []
        if profileselection:
            self._profileSelection = True
            self._polygonSelection = False
            self._pickerSelectionButtons = []
            if self._profileSelection:
                tb = self._addToolButton(self.hLineIcon,
                                         self._hLineProfileClicked,
                                         'Horizontal Profile Selection',
                                         toggle=True,
                                         state=False)
                self.hLineProfileButton = tb
                self._pickerSelectionButtons.append(tb)

                tb = self._addToolButton(self.vLineIcon,
                                         self._vLineProfileClicked,
                                         'Vertical Profile Selection',
                                         toggle=True,
                                         state=False)
                self.vLineProfileButton = tb
                self._pickerSelectionButtons.append(tb)

                tb = self._addToolButton(self.lineIcon,
                                         self._lineProfileClicked,
                                         'Line Profile Selection',
                                         toggle=True,
                                         state=False)
                self.lineProfileButton = tb
                self._pickerSelectionButtons.append(tb)

                self._pickerSelectionWidthLabel = qt.QLabel(self.toolBar)
                self._pickerSelectionWidthLabel.setText("W:")
                self.toolBar.layout().addWidget(
                    self._pickerSelectionWidthLabel)
                self._pickerSelectionWidthValue = qt.QSpinBox(self.toolBar)
                self._pickerSelectionWidthValue.setMinimum(1)
                self._pickerSelectionWidthValue.setMaximum(1000)
                self.toolBar.layout().addWidget(
                    self._pickerSelectionWidthValue)
                #tb = self._addToolButton(None,
                #                     self._lineProfileClicked,
                #                     'Line Profile Selection',
                #                     toggle=True,
                #                     state=False)
                #tb.setText = "W:"
                #self.lineWidthProfileButton = tb
                #self._pickerSelectionButtons.append(tb)
            if self._polygonSelection:
                print("Polygon selection not implemented yet")
        #hide profile selection buttons
        if imageicons:
            for button in self._pickerSelectionButtons:
                button.hide()

        self.infoWidget = qt.QWidget(self.toolBar)
        self.infoWidget.mainLayout = qt.QHBoxLayout(self.infoWidget)
        self.infoWidget.mainLayout.setMargin(0)
        self.infoWidget.mainLayout.setSpacing(0)
        self.infoWidget.label = qt.QLabel(self.infoWidget)
        self.infoWidget.label.setText("X = ???? Y = ???? Z = ????")
        self.infoWidget.mainLayout.addWidget(self.infoWidget.label)
        self.toolBarLayout.addWidget(self.infoWidget)
        self.infoWidget.hide()

        self.toolBarLayout.addWidget(qt.HorizontalSpacer(self.toolBar))

        # ---print
        tb = self._addToolButton(self.printIcon, self.printGraph,
                                 'Prints the Graph')
Exemplo n.º 23
0
    def __init__(self,
                 parent,
                 legends,
                 motorValues,
                 plotWindow=None,
                 actions=[],
                 nSelectors=2):
        """
        legends            List contains Plotnames
        motorValues     List contains names and values of the motors
        """
        CloseEventNotifyingWidget.CloseEventNotifyingWidget.__init__(
            self, parent)
        self.setWindowTitle("Sort Plots Window")

        self.legendList = legends
        self.motorsList = motorValues
        self.motorNamesList = [''] + self.getAllMotorNames()
        self.motorNamesList.sort()
        self.numCurves = len(legends)
        self.actionList = actions
        self.cBoxList = []
        self.ScanWindowA = None
        self.ScanWindowB = None
        self.closeWidget = CloseEventNotifyingWidget.CloseEventNotifyingWidget(
        )
        self.plotWindow = plotWindow if plotWindow else None

        buttonPerfom = qt.QPushButton("Perform action", self)
        buttonProcessA = qt.QPushButton("Process as A", self)
        buttonProcessB = qt.QPushButton("Process as B", self)
        updatePixmap = qt.QPixmap(IconDict["reload"])
        buttonUpdate = qt.QPushButton(qt.QIcon(updatePixmap), '', self)

        cBoxLabel = qt.QLabel(qt.QString('Select motor:'), self)
        for i in range(nSelectors):
            cBox = qt.QComboBox(self)
            cBox.addItems(self.motorNamesList)
            cBox.activated['QString'].connect(self.updateTree)
            self.cBoxList += [cBox]
        self.actionCBox = qt.QComboBox(self)

        self.list = SortPlotsTreeWidget(self)
        labels = ['Legend'] + nSelectors * ['']
        ncols = len(labels)
        self.list.setColumnCount(ncols)
        self.list.setHeaderLabels(labels)
        self.list.setSortingEnabled(True)
        self.list.setSelectionMode(qt.QAbstractItemView.ExtendedSelection)

        mainLayout = qt.QGridLayout(self)
        cBoxLayout = qt.QHBoxLayout(None)
        buttonLayout = qt.QHBoxLayout(None)
        mainLayout.setContentsMargins(1, 1, 1, 1)
        mainLayout.setSpacing(2)
        mainLayout.addLayout(cBoxLayout, 0, 0)
        mainLayout.addLayout(buttonLayout, 2, 0)
        self.setLayout(mainLayout)

        cBoxLayout.addWidget(cBoxLabel)
        for cBox in self.cBoxList:
            cBoxLayout.addWidget(cBox)
        cBoxLayout.addWidget(qt.HorizontalSpacer(self))
        cBoxLayout.addWidget(buttonUpdate)
        mainLayout.addWidget(self.list, 1, 0)
        buttonLayout.addWidget(buttonProcessA)
        buttonLayout.addWidget(buttonProcessB)
        buttonLayout.addWidget(qt.HorizontalSpacer(self))
        buttonLayout.addWidget(self.actionCBox)
        buttonLayout.addWidget(buttonPerfom)
        self.resize(500, 300)

        buttonPerfom.clicked.connect(self.performAction)
        buttonProcessA.clicked.connect(self.processAsA)
        buttonProcessB.clicked.connect(self.processAsB)
        buttonUpdate.clicked.connect(self.updatePlots)

        self.updateTree()
        self.updateActionList([('Invert selection', self.list.invertSelection),
                               ('Process as A', self.processAsA),
                               ('Process as B', self.processAsB),
                               ('Remove curve(s)', self.removeCurve_)])
Exemplo n.º 24
0
    def __init__(self, parent=None, filetypelist=None):
        qt.QWidget.__init__(self, parent)
        self.mainLayout= qt.QVBoxLayout(self)
        self.mainLayout.setMargin(0)
        self.mainLayout.setSpacing(0)
        if filetypelist is None:
            self.fileTypeList = ["Spec Files (*mca)",
                                "Spec Files (*dat)",
                                "Spec Files (*spec)",
                                "SPE Files (*SPE)",
                                "EDF Files (*edf)",
                                "EDF Files (*ccd)",
                                "CSV Files (*csv)",
                                "All Files (*)"]
        else:
            self.fileTypeList = filetypelist
        self.lastFileFilter = self.fileTypeList[0]

        # --- file combo/open/close
        self.lastInputDir = PyMcaDirs.inputDir
        self.fileWidget= qt.QWidget(self)
        fileWidgetLayout= qt.QHBoxLayout(self.fileWidget)
        fileWidgetLayout.setMargin(0)
        fileWidgetLayout.setSpacing(0)
        self.fileCombo  = qt.QComboBox(self.fileWidget)
        self.fileCombo.setEditable(0)
        self.mapCombo= {}
        openButton= qt.QToolButton(self.fileWidget)
        if QTVERSION < '4.0.0':
            self.openIcon= qt.QIconSet(qt.QPixmap(icons.fileopen))
            self.closeIcon= qt.QIconSet(qt.QPixmap(icons.fileclose))
            self.specIcon= qt.QIconSet(qt.QPixmap(icons.spec))
            self.reloadIcon = qt.QIconSet(qt.QPixmap(icons.reload))
            openButton.setIconSet(self.openIcon)
            openButton.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum))
            closeButton= qt.QToolButton(self.fileWidget)
            closeButton.setIconSet(self.closeIcon)
            specButton= qt.QToolButton(self.fileWidget)
            specButton.setIconSet(self.specIcon)
            refreshButton= qt.QToolButton(self.fileWidget)
            refreshButton.setIconSet(self.reloadIcon)
        else:
            self.openIcon   = qt.QIcon(qt.QPixmap(icons.fileopen))
            self.closeIcon  = qt.QIcon(qt.QPixmap(icons.fileclose))
            self.reloadIcon = qt.QIcon(qt.QPixmap(icons.reload))
            self.specIcon   = qt.QIcon(qt.QPixmap(icons.spec))

            openButton.setIcon(self.openIcon)
            openButton.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum))
            openButton.setToolTip("Open new file data source")

            closeButton= qt.QToolButton(self.fileWidget)
            closeButton.setIcon(self.closeIcon)
            closeButton.setToolTip("Close current data source")

            refreshButton= qt.QToolButton(self.fileWidget)
            refreshButton.setIcon(self.reloadIcon)
            refreshButton.setToolTip("Refresh data source")

            specButton= qt.QToolButton(self.fileWidget)
            specButton.setIcon(self.specIcon)
            specButton.setToolTip("Open new shared memory source")

        closeButton.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum))
        specButton.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum))
        refreshButton.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Minimum))

        self.connect(openButton, qt.SIGNAL("clicked()"), self._openFileSlot)
        self.connect(closeButton, qt.SIGNAL("clicked()"), self.closeFile)
        self.connect(refreshButton, qt.SIGNAL("clicked()"),
                         self._reload)
            
        self.connect(specButton, qt.SIGNAL("clicked()"), self.openSpec)
        self.connect(self.fileCombo, qt.SIGNAL("activated(const QString &)"),
                                                     self._fileSelection)

        fileWidgetLayout.addWidget(self.fileCombo)
        fileWidgetLayout.addWidget(openButton)            
        fileWidgetLayout.addWidget(closeButton)
        fileWidgetLayout.addWidget(specButton)
        if sys.platform == "win32":specButton.hide()
        fileWidgetLayout.addWidget(refreshButton)
        self.specButton = specButton
        self.mainLayout.addWidget(self.fileWidget)
Exemplo n.º 25
0
    def __init__(self,
                 parent=None,
                 energy=None,
                 threshold=None,
                 useviewer=None,
                 name="Peak Identifier",
                 fl=0):
        if QTVERSION < '4.0.0':
            qt.QWidget.__init__(self, parent, name, fl)
            self.setCaption(name)
            self.setIcon(qt.QPixmap(IconDict['gioconda16']))
        else:
            if fl == 0:
                qt.QWidget.__init__(self, parent)
            else:
                qt.QWidget.__init__(self, parent, fl)
            self.setWindowTitle(name)
            self.setWindowIcon(qt.QIcon(qt.QPixmap(IconDict['gioconda16'])))

        if energy is None: energy = 5.9
        if threshold is None: threshold = 0.030
        if useviewer is None: useviewer = 0
        self.__useviewer = useviewer

        layout = qt.QVBoxLayout(self)
        #heading
        self.__energyHBox = qt.QWidget(self)
        hbox = self.__energyHBox
        hbox.layout = qt.QHBoxLayout(hbox)
        hbox.layout.setMargin(0)
        hbox.layout.setSpacing(0)
        layout.addWidget(hbox)
        hbox.layout.addWidget(qt.HorizontalSpacer(hbox))

        l1 = qt.QLabel(hbox)
        l1.setText('<b><nobr>Energy (keV)</nobr></b>')
        hbox.layout.addWidget(l1)
        self.energy = MyQLineEdit(hbox)
        self.energy.setText("%.3f" % energy)
        if QTVERSION < '4.0.0':
            qt.QToolTip.add(self.energy, 'Press enter to validate your energy')
        else:
            self.energy._validator = qt.QDoubleValidator(self.energy)
            self.energy.setValidator(self.energy._validator)
            self.energy.setToolTip('Press enter to validate your energy')
        hbox.layout.addWidget(self.energy)
        hbox.layout.addWidget(qt.HorizontalSpacer(hbox))
        if QTVERSION < '4.0.0':
            self.connect(self.energy, qt.SIGNAL('returnPressed()'),
                         self._energySlot)
        else:
            self.connect(self.energy, qt.SIGNAL('editingFinished()'),
                         self._energySlot)
        #parameters
        self.__hbox2 = qt.QWidget(self)
        hbox2 = self.__hbox2

        layout.addWidget(hbox2)
        hbox2.layout = qt.QHBoxLayout(hbox2)
        hbox2.layout.setMargin(0)
        hbox2.layout.setSpacing(0)
        font = hbox2.font()
        font.setBold(1)
        hbox2.setFont(font)

        l2 = qt.QLabel(hbox2)
        l2.setText('Energy Threshold (eV)')
        self.threshold = qt.QSpinBox(hbox2)
        if QTVERSION < '4.0.0':
            self.threshold.setMinValue(0)
            self.threshold.setMaxValue(1000)
        else:
            self.threshold.setMinimum(0)
            self.threshold.setMaximum(1000)
        self.threshold.setValue(int(threshold * 1000))
        self.k = qt.QCheckBox(hbox2)
        self.k.setText('K')
        self.k.setChecked(1)
        self.l1 = qt.QCheckBox(hbox2)
        self.l1.setText('L1')
        self.l1.setChecked(1)
        self.l2 = qt.QCheckBox(hbox2)
        self.l2.setText('L2')
        self.l2.setChecked(1)
        self.l3 = qt.QCheckBox(hbox2)
        self.l3.setText('L3')
        self.l3.setChecked(1)
        self.m = qt.QCheckBox(hbox2)
        self.m.setText('M')
        self.m.setChecked(1)
        self.connect(self.threshold, qt.SIGNAL('valueChanged(int)'),
                     self.myslot)
        self.connect(self.k, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.l1, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.l2, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.l3, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.m, qt.SIGNAL('clicked()'), self.myslot)

        hbox2.layout.addWidget(l2)
        hbox2.layout.addWidget(self.threshold)
        hbox2.layout.addWidget(self.k)
        hbox2.layout.addWidget(self.l1)
        hbox2.layout.addWidget(self.l2)
        hbox2.layout.addWidget(self.l3)
        hbox2.layout.addWidget(self.m)

        if self.__useviewer:
            if QTVERSION < '4.0.0':
                self.__browsertext = qt.QTextView(self)
            else:
                self.__browsertext = qt.QTextEdit(self)
        layout.addWidget(self.__browsertext)
        self.setEnergy()
Exemplo n.º 26
0
    def __init__(self, *var, **kw):
        ddict = {}
        ddict['usetab'] = False
        ddict.update(kw)
        ddict['standalonesave'] = False
        if 'dynamic' in kw:
            del ddict['dynamic']
        if 'crop' in kw:
            del ddict['crop']
        if 'depthselection' in kw:
            del ddict['depthselection']
        self._depthSelection = kw.get('depthselection', False)
        MaskImageWidget.MaskImageWidget.__init__(self, *var, **ddict)
        self.slider = qt.QSlider(self)
        self.slider.setOrientation(qt.Qt.Horizontal)
        self.slider.setMinimum(0)
        self.slider.setMaximum(0)

        self.mainLayout.addWidget(self.slider)
        self.connect(self.slider, qt.SIGNAL("valueChanged(int)"),
                     self._showImage)

        self.imageList = None
        self._imageDict = None
        self.imageNames = None
        self._stack = None
        standalonesave = kw.get("standalonesave", True)
        if standalonesave:
            self.connect(self.graphWidget.saveToolButton,
                         qt.SIGNAL("clicked()"), self._saveToolButtonSignal)
            self._saveMenu = qt.QMenu()
            self._saveMenu.addAction(QString("Image Data"), self.saveImageList)
            self._saveMenu.addAction(QString("Standard Graphics"),
                                     self.graphWidget._saveIconSignal)
            if QTVERSION > '4.0.0':
                if MATPLOTLIB:
                    self._saveMenu.addAction(QString("Matplotlib"),
                                             self._saveMatplotlibImage)

        dynamic = kw.get("dynamic", False)
        self._dynamic = dynamic

        crop = kw.get("crop", True)
        if crop:
            self.cropIcon = qt.QIcon(qt.QPixmap(IconDict["crop"]))
            infotext = "Crop image to the currently zoomed window"
            cropPosition = 6
            #if 'imageicons' in kw:
            #    if not kw['imageicons']:
            #        cropPosition = 6
            self.cropButton = self.graphWidget._addToolButton(\
                                            self.cropIcon,
                                            self._cropIconChecked,
                                            infotext,
                                            toggle = False,
                                            position = cropPosition)

            infotext = "Flip image and data, not the scale."
            self.graphWidget.hFlipToolButton.setToolTip('Flip image')
            self._flipMenu = qt.QMenu()
            self._flipMenu.addAction(QString("Flip Image and Vertical Scale"),
                                     self.__hFlipIconSignal)
            self._flipMenu.addAction(QString("Flip Image Left-Right"),
                                     self._flipLeftRight)
            self._flipMenu.addAction(QString("Flip Image Up-Down"),
                                     self._flipUpDown)
        else:
            self.connect(self.graphWidget.hFlipToolButton,
                         qt.SIGNAL("clicked()"), self.__hFlipIconSignal)