def main(): app = qt.QApplication(sys.argv) winpalette = qt.QPalette(qt.QColor(230, 240, 249), qt.QColor(238, 234, 238)) app.setPalette(winpalette) if len(sys.argv) > 1: ene = float(sys.argv[1]) else: ene = 5.9 mw = qt.QWidget() l = qt.QVBoxLayout(mw) l.setSpacing(0) if 0: w = PeakIdentifier(mw, energy=ene) browsertext = qt.QTextView(mw) def myslot(dict): browsertext.setText(dict['text']) mw.connect(w, qt.PYSIGNAL('PeakIdentifierSignal'), myslot) else: w = PeakIdentifier(mw, energy=ene, useviewer=1) #######w.myslot() l.addWidget(w) if QTVERSION < '4.0.0': app.setMainWidget(mw) mw.show() app.exec_loop() else: mw.setWindowTitle("Peak Identifier") mw.show() app.exec_()
def main(): import sys import getopt app=qt.QApplication(sys.argv) winpalette = qt.QPalette(qt.QColor(230,240,249),qt.QColor(238,234,238)) app.setPalette(winpalette) options='' longoptions=[] opts, args = getopt.getopt( sys.argv[1:], options, longoptions) for opt,arg in opts: pass filelist=args qt.QObject.connect(app,qt.SIGNAL("lastWindowClosed()"),app, qt.SLOT("quit()")) w=EdfFileSimpleViewer() if QTVERSION < '4.0.0' : app.setMainWidget(w) w.show() if len(filelist):w.setFileList(filelist) app.exec_loop() else: if len(filelist):w.setFileList(filelist) w.show() app.exec_()
def setPaletteBackgroundColor(self, color): if QTVERSION < '4.0.0': qt.QLineEdit.setPaletteBackgroundColor(self, color) else: palette = qt.QPalette() role = self.backgroundRole() palette.setColor(role, color) self.setPalette(palette)
def main(): app = qt.QApplication([]) winpalette = qt.QPalette(qt.QColor(230, 240, 249), qt.QColor(238, 234, 238)) app.setPalette(winpalette) w = ElementsInfo() if qt.qVersion() < '4.0.0': app.setMainWidget(w) w.show() app.exec_loop() else: w.show() app.exec_()
def main(args): app = qt.QApplication(args) #if sys.platform == 'win32': if 1: winpalette = qt.QPalette(qt.QColor(230, 240, 249), qt.QColor(238, 234, 238)) app.setPalette(winpalette) options = '' longoptions = ['spec=', 'shm='] try: opts, args = getopt.getopt(sys.argv[1:], options, longoptions) except getopt.error: print(sys.exc_info()[1]) sys.exit(1) # --- waiting widget if QTVERSION < '4.0.0': wa = qt.QMessageBox("PyMca", "PyMca v. 1.5 loading ...", qt.QMessageBox.NoIcon, qt.QMessageBox.NoButton, qt.QMessageBox.NoButton, qt.QMessageBox.NoButton, None, None) wa.show() kw = {} for opt, arg in opts: if opt in ('--spec'): kw['spec'] = arg elif opt in ('--shm'): kw['shm'] = arg #demo = McaWindow.McaWidget(**kw) demo = PyMca() qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()")) if QTVERSION < '4.0.0': app.setMainWidget(demo) demo.show() # --- close waiting widget wa.close() app.exec_loop() else: demo.show() app.exec_()
def main(): import getopt options = 'f' longoptions = ['outdir=', 'listfile=', 'mcastep='] filelist = None outdir = None listfile = None mcastep = 1 opts, args = getopt.getopt(sys.argv[1:], options, longoptions) for opt, arg in opts: if opt in ('--outdir'): outdir = arg elif opt in ('--listfile'): listfile = arg elif opt in ('--mcastep'): mcastep = int(arg) if listfile is None: filelist = [] for item in args: filelist.append(item) else: fd = open(listfile) filelist = fd.readlines() fd.close() for i in range(len(filelist)): filelist[i] = filelist[i].replace('\n', '') app = qt.QApplication(sys.argv) winpalette = qt.QPalette(qt.QColor(230, 240, 249), qt.QColor(238, 234, 238)) app.setPalette(winpalette) if len(filelist) == 0: qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()")) w = Mca2EdfGUI(actions=1) if QTVERSION < '4.0.0': app.setMainWidget(w) w.show() app.exec_loop() else: w.show() sys.exit(app.exec_()) else: qt.QObject.connect(app, qt.SIGNAL("lastWindowClosed()"), app, qt.SLOT("quit()")) text = "Batch from %s to %s" % (os.path.basename( filelist[0]), os.path.basename(filelist[-1])) window = Mca2EdfWindow(name=text, actions=1) b = Mca2EdfBatch(window, filelist, outdir, mcastep) def cleanup(): b.pleasePause = 0 b.pleaseBreak = 1 b.wait() qt.qApp.processEvents() def pause(): if b.pleasePause: b.pleasePause = 0 window.pauseButton.setText("Pause") else: b.pleasePause = 1 window.pauseButton.setText("Continue") qt.QObject.connect(window.pauseButton, qt.SIGNAL("clicked()"), pause) qt.QObject.connect(window.abortButton, qt.SIGNAL("clicked()"), window.close) qt.QObject.connect(app, qt.SIGNAL("aboutToQuit()"), cleanup) window.show() b.start() if QTVERSION < '4.0.0': app.setMainWidget(window) app.exec_loop() else: sys.exit(app.exec_())
def __init__(self, parent=None, name="FitPeakSelect", peakdict={}, fl=0, energyTable=None): qt.QWidget.__init__(self, parent) if QTVERSION < '4.0.0': self.setSizePolicy( qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)) layout = qt.QVBoxLayout(self) layout.setMargin(0) layout.setSpacing(10) hbox = qt.QWidget(self) hboxLayout = qt.QHBoxLayout(hbox) hboxLayout.setMargin(0) hboxLayout.setSpacing(20) hboxLayout.addWidget(qt.HorizontalSpacer(hbox)) l1 = MyQLabel(hbox, bold=True, color=qt.QColor(0, 0, 0)) hboxLayout.addWidget(l1) self.energyValue = None if energyTable is not None: text = '<b><nobr>Excitation Energy (keV)</nobr></b>' l1.setFixedWidth(l1.fontMetrics().width("##" + text + "####")) l1.setText(text) self.energyTable = energyTable add = 0 self.energy = MyQLabel(hbox) hboxLayout.addWidget(self.energy) self.energy.setFixedWidth( self.energy.fontMetrics().width('########.###')) self.energy.setAlignment(qt.Qt.AlignLeft) #self.energy.setForegroundColor(qt.Qt.red) else: l1.setText('<b><nobr>Excitation Energy (keV)</nobr></b>') self.energyTable = EnergyTable.EnergyTable(self) add = 1 self.energy = qt.QLineEdit(hbox) hboxLayout.addWidget(self.energy) self.energy.setFixedWidth( self.energy.fontMetrics().width('########.###')) self.energyButton = qt.QPushButton(hbox) hboxLayout.addWidget(self.energyButton) self.energyButton.setText("Update") self.connect(self.energyButton, qt.SIGNAL('clicked()'), self._energyClicked) hboxLayout.addWidget(qt.HorizontalSpacer(hbox)) layout.addSpacing(20) layout.addWidget(hbox) self.table = QPeriodicTable(self) line = qt.QFrame(self) line.setFrameShape(qt.QFrame.HLine) line.setFrameShadow(qt.QFrame.Sunken) self.peaks = PeakButtonList(self) self.peaks.setDisabled(['K', 'Ka', 'Kb', 'L', 'L1', 'L2', 'L3', 'M']) if QTVERSION < '4.0.0': self.connect(self.energyTable, qt.PYSIGNAL("EnergyTableSignal"), self._energyTableAction) self.connect(self.table, qt.PYSIGNAL("elementClicked"), self.elementClicked) self.connect(self.peaks, qt.PYSIGNAL("selectionChanged"), self.peakSelectionChanged) else: self.connect(self.energyTable, qt.SIGNAL("EnergyTableSignal"), self._energyTableAction) self.connect(self.table, qt.SIGNAL("elementClicked"), self.elementClicked) self.connect(self.peaks, qt.SIGNAL("selectionChanged"), self.peakSelectionChanged) #Reset All self.resetAllButton = qt.QPushButton(self.peaks) palette = qt.QPalette(self.resetAllButton.palette()) role = self.resetAllButton.foregroundRole() palette.setColor(role, qt.Qt.red) self.resetAllButton.setPalette(palette) self.resetAllButton.setText("Reset All") self.peaks.layout().addWidget(self.resetAllButton) self.connect(self.resetAllButton, qt.SIGNAL("clicked()"), self.__resetAll) layout.addWidget(self.table) layout.addWidget(line) layout.addWidget(self.peaks) if add: layout.addWidget(self.energyTable) layout.addStretch(1) self.current = None self.setSelection(peakdict)