Exemplo n.º 1
0
def test():
    from PyMca5.PyMcaGui.pymca import QDataSource
    a = qt.QApplication(sys.argv)
    w = QSpecFileWidget()
    if len(sys.argv) > 1:
        d = QDataSource.QDataSource(sys.argv[1])
    else:
        if os.path.exists('03novs060sum.mca'):
            d = QDataSource.QDataSource('03novs060sum.mca')
        else:
            print("Usage:")
            print("      python QSpecFileWidget.py filename")
            a.quit()
            sys.exit(0)
    w.setData(d)
    w.show()

    def mySlot(selection):
        print(selection)
        try:
            # this is only for "addSelection"
            print(
                d.getDataObject(selection[0]['Key'],
                                selection[0]['selection']))
        except:
            pass
        return

    w.sigAddSelection.connect(mySlot)
    w.sigRemoveSelection.connect(mySlot)
    w.sigReplaceSelection.connect(mySlot)
    a.lastWindowClosed.connect(a.quit)

    a.exec()
Exemplo n.º 2
0
 def _sourceSelectorSlot(self, ddict):
     if DEBUG:
         print("_sourceSelectorSlot(self, ddict)")
         print("ddict = ", ddict)
     if ddict["event"] == "NewSourceSelected":
         source = QDataSource.QDataSource(ddict["sourcelist"])
         self.sourceList.append(source)
         sourceType = source.sourceType
         self.selectorWidget[sourceType].setDataSource(source)
     elif ddict["event"] == "SourceSelected":
         found = 0
         for source in self.sourceList:
             if source.sourceName == ddict["sourcelist"]:
                 found = 1
                 break
         if not found:
             if DEBUG:
                 print("WARNING: source not found")
             return
         sourceType = source.sourceType
         self.selectorWidget[sourceType].setDataSource(source)
     elif ddict["event"] == "SourceClosed":
         found = 0
         for source in self.sourceList:
             if source.sourceName == ddict["sourcelist"]:
                 found = 1
                 break
         if not found:
             if DEBUG:
                 print("WARNING: source not found")
             return
         sourceType = source.sourceType
         del self.sourceList[self.sourceList.index(source)]
         for source in self.sourceList:
             if sourceType == source.sourceType:
                 self.selectorWidget[sourceType].setDataSource(source)
                 return
         #there is no other selection of that type
         if len(self.sourceList):
             source = self.sourceList[0]
             sourceType = source.sourceType
             self.selectorWidget[sourceType].setDataSource(source)
         else:
             self.selectorWidget[sourceType].setDataSource(None)
Exemplo n.º 3
0
 def setFileList(self, filelist, append=False):
     if filelist is None:
         filelist = []
     if not append:
         self._fileList = []
     self._listView.clear()
     text = ""
     for ffile in self._fileList:
         text += ffile + "\n"
     for ffile in filelist:
         if ffile not in self._fileList:
             self._fileList.append(ffile)
             text += ffile + "\n"
     self._listView.insertPlainText(text)
     sourceType = QDataSource.getSourceType(self._fileList[0])
     dataSourceClass  = QDataSource.source_types[sourceType]
     dataSourceWidget = QDataSource.source_widgets[sourceType]
     self._dataSource = dataSourceClass(self._fileList[0])
     self._dataWidget = dataSourceWidget()
     self._dataWidget.setDataSource(self._dataSource)
     self._dataWidget.sigAddSelection.connect(self.printSelection)
     self._dataWidget.show()
Exemplo n.º 4
0
 def setFileList(self, filelist, append=False):
     if filelist is None:
         filelist = []
     if not append:
         self._fileList = []
     self._listView.clear()
     text = ""
     for ffile in self._fileList:
         text += ffile + "\n"
     for ffile in filelist:
         if ffile not in self._fileList:
             self._fileList.append(ffile)
             text += ffile + "\n"
     self._listView.insertPlainText(text)
     sourceType = QDataSource.getSourceType(self._fileList[0])
     dataSourceClass = QDataSource.source_types[sourceType]
     dataSourceWidget = QDataSource.source_widgets[sourceType]
     self._dataSource = dataSourceClass(self._fileList[0])
     self._dataWidget = dataSourceWidget()
     self._dataWidget.setDataSource(self._dataSource)
     self._dataWidget.sigAddSelection.connect(self.printSelection)
     self._dataWidget.show()
Exemplo n.º 5
0
 def mySlot(ddict):
     print(ddict)
     if ddict["event"] == "NewSourceSelected":
         d = QDataSource.QDataSource(ddict["sourcelist"][0])
         w.specfileWidget.setDataSource(d)
         w.sigSourceSelectorSignal.connect(mySlot)