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)
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)
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)
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)
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)
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)
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)
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)
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)
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
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)
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)
def __init__(self, parent): ''' Constructor ''' qt.QToolBar.__init__(self, parent) self.setIconSize(qt.QSize(25, 25)) self.zoomAutoAction = qt.QAction(qt.QIcon('Icones/autozoom.png'), '&Zoom', self) self.zoomAutoAction.setStatusTip('Fit window') self.zoomAutoAction.setCheckable(False) self.zoomAutoAction.setChecked(False) self.zoomActive = False qt.QObject.connect(self.zoomAutoAction, qt.SIGNAL("triggered()"), self.zoomAutoPushed) self.zone1Action = qt.QAction(qt.QIcon('Icones/zone.png'), '&ZoneSelection', self) self.zone1Action.setStatusTip('Select Zone') self.zone1Action.setCheckable(True) self.zone1Action.setChecked(False) qt.QObject.connect(self.zone1Action, qt.SIGNAL("triggered()"), self.zone1Selected) self.pointerAction = qt.QAction(qt.QIcon('Icones/cursor.png'), '&PointerSelection', self) self.pointerAction.setStatusTip('Select Pointer') self.pointerAction.setCheckable(True) self.pointerAction.setChecked(True) qt.QObject.connect(self.pointerAction, qt.SIGNAL("triggered()"), self.pointerSelected) self.drawingAction = qt.QAction(qt.QIcon('Icones/circle18.png'), '&DrawingSelection', self) self.drawingAction.setStatusTip('Select Drawing') self.drawingAction.setCheckable(True) self.drawingAction.setChecked(False) qt.QObject.connect(self.drawingAction, qt.SIGNAL("triggered()"), self.drawingSelected) self.polygonAction = qt.QAction(qt.QIcon('Icones/polygon.png'), '&PolygonSelection', self) self.polygonAction.setStatusTip('Select Polygone') self.polygonAction.setCheckable(True) self.polygonAction.setChecked(False) qt.QObject.connect(self.polygonAction, qt.SIGNAL("triggered()"), self.polygonSelected) self.pointRemoveAction = qt.QAction(qt.QIcon('Icones/remove.png'), '&DeletePoint', self) self.pointRemoveAction.setStatusTip('remove Point') self.pointRemoveAction.setCheckable(False) self.pointRemoveAction.setChecked(False) self.radius = LabelEditAndButton(True, "", True, str(100), False) self.doubleSlider = DoubleSlider(self) self.setMinAndMaxToolBar(0, 0) self.doubleSlider.setMaximumWidth(800) self.colorChoice = qt.QComboBox() self.colormapList = [] colorMapDefault = "GrayLevel", range(256), range(256), range(256) self.colormapList.append(colorMapDefault) self.colorChoice.addItems([self.colormapList[0][0]]) self.addColorMap('Jet', './jet_color.txt') self.addAction(self.zoomAutoAction) self.addSeparator() self.addAction(self.pointerAction) self.addAction(self.zone1Action) self.addAction(self.drawingAction) self.ActionRadius = self.addWidget(self.radius) self.ActionRadius.setVisible(False) self.addAction(self.polygonAction) self.addAction(self.pointRemoveAction) self.addWidget(self.doubleSlider) self.addWidget(self.colorChoice)
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')
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)
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_()
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)
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()
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_)])
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"]))