Esempio n. 1
0
 def loadFile(self, fullFilename):
     self._f = None
     err = self.openFile(fullFilename)
     if err == 1:
         print(
             "Cannot open file. SWMR mode not supported by your h5py version. Please change file mode in the file menue and try again."
         )
         return
     self.fullFilename = fullFilename
     self.filename = QtCore.QFileInfo(fullFilename).fileName()
     self.fullName = self.name = "/"
     self.tagsItem = None
     self.modelItem = None
     self.pattersonItem = None
     self.dataItems = {}
     self.groupItems = {}
     self.tagsItems = {}
     self.modelItems = {}
     self.pattersonItems = {}
     self.children = {}
     H5Group = self._f[self.fullName]
     for k in H5Group.keys():
         item = H5Group[k]
         if isinstance(item, h5py.Dataset):
             self.children[k] = DataItem(self, self, "/" + k)
         elif isinstance(item, h5py.Group):
             self.children[k] = GroupItem(self, self, "/" + k)
     self.collectItems(self.children)
     self.stackSize = None
Esempio n. 2
0
    def getRet(self):
        if self.exec_():
            ret = dict()
            if not self.text_name.text():
                error('Name required')
                return False
            if not re.match(r'[a-z_]\w*$', self.text_name.text(), re.I):
                error('No valid variable name')
                return False
            if self.filename[0]:
                ret['icon'] = QtCore.QFileInfo(self.filename[0]).baseName()
            else:
                ret['icon'] = None
                error('No icon selected', warn=True)

            ret['name'] = self.text_name.text()

            newProperties = dict()
            for key in list(self.values.keys()):
                newProperties[key] = self.values[key].text()
            ret['properties'] = newProperties

            return ret
        else:
            return False
Esempio n. 3
0
 def __init__(self, filename='untitled', runflag=False):
     threading.Thread.__init__(self)
     if filename != 'untitled':
         self.fname = QtCore.QFileInfo(filename)
         self.mypath = str(self.fname.absolutePath())
         self.fname = str(self.fname.baseName())
     else:
         self.fname = 'untitled'
         self.mypath = os.getcwd()
     self.runflag = runflag
Esempio n. 4
0
 def setContents(self, fileName):
     fi = QtCore.QFileInfo(fileName)
     self.srcUrl = QtCore.QUrl.fromLocalFile(fi.absoluteFilePath())
     file = QtCore.QFile(fileName)
     if file.open(QtCore.QIODevice.ReadOnly):
         data = file.readAll().data().decode()
         if fileName.endswith(".html"):
             self.setHtml(data)
         else:
             self.setPlainText(data)
Esempio n. 5
0
    def getRet(self):
        if self.exec_():
            ret = dict()
            if not self.text_name.text():
                error('Name required')
                return False
            if not re.match(r'[a-z_]\w*$', self.text_name.text(), re.I):
                error(self.text_name.text() + ' is not valid variable name')
                return False
            if not self.filename[0]:
                error('no icon set', warn=True)
                ret['icon'] = None
            else:
                ret['icon'] = QtCore.QFileInfo(self.filename[0]).baseName()

            ret['name'] = self.text_name.text()
            ret['input'] = []
            ret['output'] = []

            for inp in self.inputInstances:
                name = inp[0].text()
                x = int(inp[1].text())
                y = int(inp[2].text())
                if inp[3].isChecked():
                    ret['input'].append((name, x, y, True))
                else:
                    ret['input'].append((name, x, y))

            for outp in self.outputInstances:
                name = outp[0].text()
                x = int(outp[1].text())
                y = int(outp[2].text())
                if outp[3].isChecked():
                    ret['output'].append((name, x, y, True))
                else:
                    ret['output'].append((name, x, y))

            ret['inout'] = []

            newProperties = dict()
            for key in list(self.values.keys()):
                newProperties[key] = eval(self.values[key].text())
            ret['properties'] = newProperties

            parameters = dict()
            for key in list(self.valuesPar.keys()):
                parameters[key] = eval(self.valuesPar[key].text())
            ret['parameters'] = parameters

            return ret
        else:
            return False
Esempio n. 6
0
 def accept(self, *args):
     indexes = self.listView.selectionModel().selectedRows()
     if indexes:
         index = indexes[0]
         if self.fileModel.isDir(index):
             self.enterDirectory(index)
             return
         fname = str(index.data())
     else:
         fname = self.fileNameEdit.text().strip()
         if not fname:
             return
         info = QtCore.QFileInfo(fname)
         if info.isDir():
             self.setPath(info.absoluteFilePath())
             return
     self.openFile.emit(os.path.join(self.getPath(), fname))
Esempio n. 7
0
def SpyceSession(filename='untitled', runflag=False):
    if filename != 'untitled':
        fname = QtCore.QFileInfo(filename)
        mypath = str(fname.absolutePath())
        fname = str(fname.baseName())
    else:
        fname = 'untitled'
        mypath = os.getcwd()

    app = QtWidgets.QApplication(sys.argv)

    library = LibraryWindow()
    library.setGeometry(20, 100, 400, 768)
    library.show()

    main = EditorWindow(library, fname, mypath, runflag)
    main.setGeometry(500, 100, 1024, 768)
    main.show()

    ret = app.exec_()
    app.deleteLater()
Esempio n. 8
0
 def image(self, value):
     self._image = value
     self.svgIcon.renderer().load(value)
     elementName = QtCore.QFileInfo(value).baseName()
     self.svgIcon.setElementId(elementName)