예제 #1
0
    def outputFiles(self, map, fileName):
        result = []

        # Extract file name without extension and path
        fileInfo = QFileInfo(fileName)
        base = fileInfo.completeBaseName() + "_"
        path = fileInfo.path()

        # Loop layers to calculate the path for the exported file
        for layer in map.layers():
            if layer.layerType() != Layer.TileLayerType:
                continue

            # Get the output file name for this layer
            layerName = layer.name()
            layerFileName = base + layerName + ".csv"
            layerFilePath = QDir(path).filePath(layerFileName)

            result.append(layerFilePath)

        # If there was only one tile layer, there's no need to change the name
        # (also keeps behavior backwards compatible)
        if len(result) == 1:
            result[0] = fileName

        return result
예제 #2
0
    def outputFiles(self, map, fileName):
        result = []

        # Extract file name without extension and path
        fileInfo = QFileInfo(fileName)
        base = fileInfo.completeBaseName() + "_"
        path = fileInfo.path()

        # Loop layers to calculate the path for the exported file
        for layer in map.layers():
            if layer.layerType() != Layer.TileLayerType:
                continue

            # Get the output file name for this layer
            layerName = layer.name()
            layerFileName = base + layerName + ".csv"
            layerFilePath = QDir(path).filePath(layerFileName)

            result.append(layerFilePath)

        # If there was only one tile layer, there's no need to change the name
        # (also keeps behavior backwards compatible)
        if len(result) == 1:
            result[0] = fileName

        return result
예제 #3
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setObjectName("myGitClone")
        root = QFileInfo.path(QFileInfo(QCoreApplication.arguments()[0]))
        print("root", root)
        self.icon = QIcon(f"{root}/favicon.ico")
        self.setWindowIcon(self.icon)
        self.setGeometry(0, 0, 800, 600)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setMinimumSize(400, 300)
        self.setDocumentMode(True)
        self.settings = QSettings('Axel Schneider', self.objectName())
        self.createStatusbar()
        self.createActions()
        self.createWidgets()
        QMetaObject.connectSlotsByName(self)
        self.readSettings()
        self.statusbar.showMessage("Ready")
        self.setWindowTitle("myGitClone")

        ### process
        ### shell settings
        self.process = QProcess(self)
        self.process.setProcessChannelMode(QProcess.MergedChannels)
        self.process.readyReadStandardError.connect(lambda: self.msg("Error"))
        self.process.started.connect(lambda: self.msg("starting shell"))
        self.process.finished.connect(lambda: self.msg("shell ended"))
예제 #4
0
 def icon(self):
     fnisPath = self.__organizer.pluginSetting(self.name(), "fnis-path")
     if os.path.exists(fnisPath):
         # We can't directly grab the icon from an executable, but this seems like the simplest alternative.
         fin = QFileInfo(fnisPath)
         model = QFileSystemModel()
         model.setRootPath(fin.path())
         return model.fileIcon(model.index(fin.filePath()))
     else:
         # Fall back to where the user might have put an icon manually.
         return QIcon("plugins/FNIS.ico")
예제 #5
0
    def saveAsDocument(self, document):
        """
        prompts the user for a new filename or path and saves the document as that
        :param document: Reference to the document
        :return: Returns if the save as succeeded or not
        """
        new_path = \
            QFileDialog.getSaveFileName(self.app, 'Save File', self.app.left_menu.model.rootPath())[
                0]

        # if the new path is an empty string do nothing
        if new_path == '':
            logging.warning("No New File Path Given")
            return False

        # check if the document is formatted
        if self.app.btn_mode_switch.isChecked():
            f_info = QFileInfo(new_path)
            if f_info.suffix() != "lef":
                new_path = os.path.join(f_info.path(), f_info.baseName()) + '.lef'
            data = document.toHtml()
        else:
            f_info = QFileInfo(new_path)
            if f_info.suffix() == "lef":
                new_path = os.path.join(f_info.path(), f_info.baseName()) + '.txt'
            data = document.toPlainText()

        # now write to the new_path
        self.writeFileData(new_path, data)

        # add the document to the dict of documents
        self.open_documents[new_path] = QFileInfo(new_path)
        self.current_document = self.open_documents[new_path]
        self.file_opened_time = os.path.getatime(self.current_document.absoluteFilePath())

        # open the document with its new text
        self.openDocument(document, new_path)

        logging.info("Saved File As - %s", new_path)
        return True
예제 #6
0
    def __init__(self, mapDocument, fileName, currentScale, parent=None):
        super().__init__(parent)
        self.mUi = None
        self.mCurrentScale = currentScale
        self.mMapDocument = mapDocument
        self.mUi = Ui_ExportAsImageDialog()
        self.mUi.setupUi(self)
        self.setWindowFlags(self.windowFlags()
                            & ~Qt.WindowContextHelpButtonHint)

        saveButton = self.mUi.buttonBox.button(QDialogButtonBox.Save)
        saveButton.setText(self.tr("Export"))

        # Default to the last chosen location
        suggestion = adjustDir(self.mPath)

        # Suggest a nice name for the image
        if fileName != '':
            fileInfo = QFileInfo(fileName)
            path = fileInfo.path()
            baseName = fileInfo.completeBaseName()

            if suggestion == '':
                suggestion = adjustDir(path)

            suggestion += '/'
            suggestion += baseName
            suggestion += ".png"
        else:
            suggestion += '/'
            suggestion += "map.png"

        self.mUi.fileNameEdit.setText(suggestion)

        # Restore previously used settings
        s = preferences.Preferences.instance()
        visibleLayersOnly = s.boolValue(VISIBLE_ONLY_KEY, True)
        useCurrentScale = s.boolValue(CURRENT_SCALE_KEY, True)
        drawTileGrid = s.boolValue(DRAW_GRID_KEY, False)
        includeBackgroundColor = s.boolValue(INCLUDE_BACKGROUND_COLOR, False)

        self.mUi.visibleLayersOnly.setChecked(visibleLayersOnly)
        self.mUi.currentZoomLevel.setChecked(useCurrentScale)
        self.mUi.drawTileGrid.setChecked(drawTileGrid)
        self.mUi.includeBackgroundColor.setChecked(includeBackgroundColor)

        self.mUi.browseButton.clicked.connect(self.browse)
        self.mUi.fileNameEdit.textChanged.connect(self.updateAcceptEnabled)

        Utils.restoreGeometry(self)
예제 #7
0
   def on_btnFile_rename_clicked(self):
      self.__showBtnInfo(self.sender())
      sous=self.ui.editFile.text().strip()   #源文件
      if sous=="":
         self.ui.textEdit.appendPlainText("请先选择一个文件")
         return

      fileInfo=QFileInfo(sous)
      newFile=fileInfo.path()+"/"+fileInfo.baseName()+".XZY"  #更改文件后缀为".XYZ"
      if QFile.rename(sous,newFile):   
         self.ui.textEdit.appendPlainText("源文件:"+sous)
         self.ui.textEdit.appendPlainText("重命名为:"+newFile+"\n")
      else:
         self.ui.textEdit.appendPlainText("重命名文件失败\n")
예제 #8
0
 def on_btnFile_copy_clicked(self):
    self.__showBtnInfo(self.sender())
    sous=self.ui.editFile.text().strip()   #源文件
    if sous=="":
       self.ui.textEdit.appendPlainText("请先选择一个文件")
       return
    
    fileInfo=QFileInfo(sous)
    newFile=fileInfo.path()+"/"+fileInfo.baseName()+"--副本."+fileInfo.suffix()
    if QFile.copy(sous,newFile):  
       self.ui.textEdit.appendPlainText("源文件:"+sous)
       self.ui.textEdit.appendPlainText("复制为文件:"+newFile+"\n")
    else:
       self.ui.textEdit.appendPlainText("复制文件失败")
예제 #9
0
    def open(self, t_filename=None):
        settings = QSettings(QSettings.IniFormat, QSettings.UserScope, "pySPM",
                             "pySPM")
        if t_filename is None:
            home = QDir.cleanPath(os.getenv("HOMEPATH"))
            path = settings.value("lastPath", home)
            self.filename = QFileDialog.getOpenFileName(
                None, "Choose measurement file", path, "*.ita")
        else:
            self.filename = t_filename

        check_file = QFileInfo(self.filename)
        self.setWindowTitle(check_file.fileName())
        if not check_file.exists() or not check_file.isFile():
            return

        settings.setValue("lastPath", check_file.path())
        self.ita = pySPM.ITA(self.filename)
        self.t, self.S = self.ita.getSpectrum(time=True)
        self.sf, self.k0 = self.ita.get_mass_cal()
        self.mass = pySPM.utils.time2mass(self.t, self.sf, self.k0)
        self.spec = self.ax.plot(self.mass, self.S)[0]
        SatLevel = self.ita.size['pixels']['x'] * self.ita.size['pixels'][
            'y'] * self.ita.Nscan
        self.sat_level = self.ax.axhline(SatLevel, color='r')
        if 'pySPM' in self.ita.root.goto("MassScale"):
            self.MassCal = []
            N = self.ita.root.goto("MassScale/pySPM/N").get_ulong()
            for i in range(N):
                elt = self.ita.root.goto("MassScale/pySPM/" + str(i) +
                                         "/elt").value.decode('utf8')
                mass = self.ita.root.goto("MassScale/pySPM/" + str(i) +
                                          "/mass").get_double()
                time = self.ita.root.goto("MassScale/pySPM/" + str(i) +
                                          "/time").get_double()
                self.MassCal.append(dict(elt=elt, mass=mass, time=time))
        else:
            self.MassCal = []
            for x in self.ita.root.goto("MassScale/calib"):
                if x.name == 'assign':
                    self.MassCal.append({'elt': x.get_string()})
                if x.name == 'mcp':
                    mcp = struct.unpack("<10d", x.value)
                    self.MassCal[-1]['time'] = mcp[0]
                    self.MassCal[-1]['mass'] = mcp[1]
        self.DoMassCal()
예제 #10
0
    def __init__(self, parent=None):
        super(MyWindow, self).__init__(parent)
        self.setupUi(self)
        self.originText.setFocus(True)
        #  Translator
        self.trans = QTranslator()
        # destination language
        self.dest = 'de-DE'
        self.lan = 1
        # real-time translate
        self.isRealTimeTrans = False
        self.isCopyFromTrans = False
        self.connectSlots()
        self.trans.load("de")
        self.dest = "en"

        root = QFileInfo.path(QFileInfo(QCoreApplication.arguments()[0]))
        btnIcon = root + "/google.png"
        self.hbox = QHBoxLayout()
        self.btnDE_EN = QPushButton("Deutsch > Englisch (F6)",
                                    clicked=self.toggleLanguageDE)
        self.btnDE_EN.setIcon(QIcon(btnIcon))
        self.btnEN_DE = QPushButton("Englisch > Deutsch (F7)",
                                    clicked=self.toggleLanguageEN)
        self.btnEN_DE.setIcon(QIcon(btnIcon))
        self.btn_copy = QPushButton("Übersetzung kopieren (F8)",
                                    clicked=self.copySlot)
        self.btn_copy.setIcon(QIcon.fromTheme("edit-copy"))
        empty = QWidget()
        empty.setFixedWidth(100)
        self.hbox.addWidget(self.btnDE_EN)
        self.hbox.addWidget(self.btnEN_DE)
        self.hbox.addWidget(empty)
        self.hbox.addWidget(self.btn_copy)

        self.wid = QWidget()
        self.wid.setLayout(self.hbox)
        self.statusBar.addPermanentWidget(self.wid)
        self.statusBar.setStyleSheet(
            "QStatusBar {font-size: 8pt;} QPushButton \
                                        {font-size: 9pt;} QPushButton::hover {background: #729fcf}"
        )
        self.statusBar.showMessage("Ready", 0)
        self.setWindowIcon(QIcon(btnIcon))
예제 #11
0
    def set_data(self, _file):
        ff = QFileInfo(_file)
        self.short_title(ff.fileName())
        self.ui.lsize.setText(naturalsize(ff.size(), format="%.1f "))

        if ff.isDir():
            self.ui.litems.show()
            self.ui.label_3.show()
            self.ui.litems.setText(str(len(glob(_file + "/*"))))
        else:
            self.ui.label_3.hide()
            self.ui.litems.hide()

        self.ui.lcreated.setText(ff.created().toString())
        self.ui.lmodified.setText(ff.lastModified().toString())
        self.ui.laccessed.setText(ff.lastRead().toString())
        self.ui.luser.setText(ff.owner())
        self.ui.luid.setText(str(ff.ownerId()))
        self.ui.lgroup.setText(str(ff.group()))
        self.ui.lgid.setText(str(ff.groupId()))
        self.ui.lpath.setText(ff.path())
예제 #12
0
파일: spectra.py 프로젝트: scholi/pySPM
 def open(self, t_filename=None):
     settings = QSettings(QSettings.IniFormat, QSettings.UserScope, "pySPM", "pySPM")
     if t_filename is None:
         home = QDir.cleanPath(os.getenv("HOMEPATH"))
         path = settings.value("lastPath", home)
         self.filename = QFileDialog.getOpenFileName(None, "Choose measurement file", path, "*.ita")
     else:
         self.filename = t_filename
     
     check_file = QFileInfo(self.filename)
     self.setWindowTitle(check_file.fileName())
     if not check_file.exists() or  not check_file.isFile():
         return
     
     settings.setValue("lastPath", check_file.path())
     self.ita = pySPM.ITA(self.filename)
     self.t, self.S = self.ita.getSpectrum(time=True)
     self.sf, self.k0 = self.ita.get_mass_cal()
     self.mass = pySPM.utils.time2mass(self.t, self.sf, self.k0)
     self.spec = self.ax.plot(self.mass, self.S)[0]
     SatLevel = self.ita.size['pixels']['x']*self.ita.size['pixels']['y']*self.ita.Nscan
     self.sat_level = self.ax.axhline(SatLevel, color='r')
     if 'pySPM' in self.ita.root.goto("MassScale"):
         self.MassCal = []
         N = self.ita.root.goto("MassScale/pySPM/N").get_ulong()
         for i in range(N):
             elt = self.ita.root.goto("MassScale/pySPM/"+str(i)+"/elt").value.decode('utf8')
             mass = self.ita.root.goto("MassScale/pySPM/"+str(i)+"/mass").get_double()
             time = self.ita.root.goto("MassScale/pySPM/"+str(i)+"/time").get_double()
             self.MassCal.append(dict(elt=elt, mass=mass, time=time))
     else:
         self.MassCal = []
         for x in self.ita.root.goto("MassScale/calib"):
             if x.name == 'assign':
                 self.MassCal.append({'elt':x.get_string()})
             if x.name == 'mcp':
                 mcp = struct.unpack("<10d", x.value)
                 self.MassCal[-1]['time'] = mcp[0]
                 self.MassCal[-1]['mass']  =  mcp[1]
     self.DoMassCal()                    
예제 #13
0
    def on_btnDir_rename_clicked(self):
        self.__showBtnInfo(self.sender())

        sous = self.ui.editFile.text()
        if sous == "":
            self.ui.textEdit.appendPlainText("请先选择一个文件")
            return

        parDir = self.ui.editDir.text().strip()
        if parDir == "":
            self.ui.textEdit.appendPlainText("请先选择一个目录")
            return

        dirObj = QDir(parDir)

        fileInfo = QFileInfo(sous)
        newFile = fileInfo.path() + "/" + fileInfo.baseName() + ".XYZ"

        if dirObj.rename(sous, newFile):
            self.ui.textEdit.appendPlainText("源文件:" + sous)
            self.ui.textEdit.appendPlainText("重命名为:" + newFile + "\n")
        else:
            self.ui.textEdit.appendPlainText("重命名文件失败\n")
예제 #14
0
    def updateDetails(self, path):
        """
        Updates the elements in the right menu based on arguments
        :param path: path of the file
        :return: nothing
        """
        info = QFileInfo(path)

        bullet = html.unescape("&#8226;")

        value: str = bullet + " File not saved!"
        # Get the file info and update all the respective fields
        if info is not None and path is not None:
            value = ""
            i_s = "<i>"
            i_e = "</i>"
            br = "<br>"

            size = info.size()
            units = ['Bytes', 'KB', 'MB', 'GB']
            unit = 0
            while len(str(round(size, 0))) > 3:
                size /= 1000
                unit += 1

            value += bullet + " Name: " + i_s + info.fileName() + i_e + br
            value += bullet + " Path: " + i_s + info.path() + i_e + br
            value += bullet + " Size: " + i_s + str(size) + " " + units[unit] + i_e + br
            value += bullet + " Owner: " + i_s + (str(info.owner())) + i_e + br
            value += bullet + " Viewed: " + i_s + \
                     (info.lastRead().toString(self.format_time)) + i_e + br
            value += bullet + " Modified: " + i_s + \
                     (info.lastModified().toString(self.format_time)) + i_e

        self.col_metadata_contents.setText(value)
        # Update the summary from file
        self.updateSummary()
예제 #15
0
def getLockfileName(path):
    fi = QFileInfo(path)
    return fi.path() + QDir.separator() + ".#" + fi.fileName()
예제 #16
0
 def on_btnInfo_path_clicked(self):
     self.__showBtnInfo(self.sender())
     fileInfo = QFileInfo(self.ui.editFile.text())
     text = fileInfo.path()
     self.ui.textEdit.appendPlainText(text + "\n")
예제 #17
0
 def setFilename(self, filename):
     info = QFileInfo(filename)
     self.filename = info.fileName()
     self.source_path = info.path()