Example #1
0
 def select_images_on_disk(uim, start_path=None):
     dlg = QFileDialog()
     logmsg('Select one or more images to add.')
     image_list = dlg.getOpenFileNames(caption='Select one or more images to add.',\
                                       directory=uim.hs.db_dpath)
     image_list = [str(fpath) for fpath in image_list]
     return image_list
Example #2
0
 def select_images_on_disk(uim, start_path=None):
     dlg = QFileDialog()
     logmsg('Select one or more images to add.')
     image_list = dlg.getOpenFileNames(caption='Select one or more images to add.',\
                                       directory=uim.hs.db_dpath)
     image_list = [str(fpath) for fpath in image_list]
     return image_list
Example #3
0
 def __init__(self, parent=None):
     QFileDialog.__init__(self, parent)
     self.setNameFilter(
         self.tr(
             "Geospatial vector data format (*.shp *.kml *.geojson *.svg)"))
     self.setAcceptMode(QFileDialog.AcceptOpen)
     self.setFileMode(QFileDialog.ExistingFile)
Example #4
0
 def __init__(self, parent=None):
     QFileDialog.__init__(self, parent)
     self.setNameFilter(
         self.
         tr("Geospatial raster data format (*.tfw *.tif *.jp2 *.jpx *.drg"))
     self.setAcceptMode(QFileDialog.AcceptOpen)
     self.setFileMode(QFileDialog.ExistingFile)
 def selectDirectory(self):
     directory = QFileDialog.getExistingDirectory(QFileDialog())
     if len(directory) > 0:
         directory = pathlib.Path(directory).resolve()
         if directory.exists():
             self._rddtDataExtractor.defaultPath = directory
             self.directoryBox.setText(str(directory))
             self.setUnsavedChanges(True)
Example #6
0
 def select_database(uim):
     dlg = QFileDialog()
     opt = QFileDialog.ShowDirsOnly
     if uim.hs.db_dpath is None:
         db_dpath = str(dlg.getExistingDirectory(caption='Open/New Database', options=opt))
     else:
         db_dpath = str(dlg.getExistingDirectory(\
                    caption='Open/New Database', options=opt, directory=uim.hs.db_dpath))
     return db_dpath
Example #7
0
 def select_database(uim):
     dlg = QFileDialog()
     opt = QFileDialog.ShowDirsOnly
     if uim.hs.db_dpath is None:
         db_dpath = str(
             dlg.getExistingDirectory(caption='Open/New Database',
                                      options=opt))
     else:
         db_dpath = str(dlg.getExistingDirectory(\
                    caption='Open/New Database', options=opt, directory=uim.hs.db_dpath))
     return db_dpath
Example #8
0
 def Save(self):
     d = QFileDialog(self)
     s = d.getSaveFileName()
     
     l = len(self.mt.Images)
     
     for i in xrange(l):
         self.mt.Images[i].save(s+'.'+str(i)+'.png')
         
     f = open(s,"w")
     f.write(str(l))
     f.close()
Example #9
0
    def on_browseDestButton_clicked(self, checked=None):
        """
        Called when browse button for destination is clicked.
        Opens a dialog for selecting a path.
        """
        if checked is None: return
        fileDialog = QFileDialog()

        path = str(fileDialog.getExistingDirectory(self, 'Set directory',
                                                   '/home/'))
        if path != '':
            path = path.replace(" ", "\ ")
            self.ui.lineEditDestPath.setText(path)
Example #10
0
 def Open(self):
     d = QFileDialog(self)
     s = d.getOpenFileName()
     
     self.mt.exit = True
     
     f = open(s,"r")
     l = int(f.readline())
     f.close()
     
     self.mt.Images = []
     
     for i in xrange(l):
         self.mt.Images.append(QImage(s+'.'+str(i)+'.png'))
 def saveFavorite(self):
     """
     Writes the current favorite (selected in the combobox) to a file, any 
     where in the disk that 
     can be given to another NE1 user (i.e. as an email attachment).
     """
     
     cmd = greenmsg("Save Favorite File: ")
     env.history.message(greenmsg("Save Favorite File:"))
     current_favorite = self.favoritesComboBox.currentText()
     favfilepath = getFavoritePathFromBasename(current_favorite)
     
     formats = \
                 "Favorite (*.txt);;"\
                 "All Files (*.*)"
      
     
     fn = QFileDialog.getSaveFileName(
         self, 
         "Save Favorite As", # caption
         favfilepath, #where to save
         formats, # file format options
         QString("Favorite (*.txt)") # selectedFilter
         )
     if not fn:
         env.history.message(cmd + "Cancelled")
     
     else:
         saveFavoriteFile(str(fn), favfilepath)
     return
Example #12
0
 def read_element_rgb_table(self):
     """
     Open file browser to select a file to read from, read the data,
     update elements color in the selector dialog and also the display models
     """
     # Determine what directory to open.
     import os
     if self.w.assy.filename: 
         odir = os.path.dirname(self.w.assy.filename)
     else: 
         from utilities.prefs_constants import workingDirectory_prefs_key
         odir = env.prefs[workingDirectory_prefs_key]
     self.fileName = str( QFileDialog.getOpenFileName(
                             self,
                             "Load Element Color",
                             odir,
                             "Elements color file (*.txt);;All Files (*.*);;"
                              ))
     if self.fileName:
         colorTable = readElementColors(self.fileName)
         
         if not colorTable:
             env.history.message(redmsg("Error in element colors file: [" + self.fileName + "]. Colors not loaded."))
         else:
             env.history.message("Element colors loaded from file: [" + self.fileName + "].")
             for row in colorTable:
                  row[1] /= 255.0; row[2] /= 255.0; row[3] /= 255.0
             self.elemTable.setElemColors(colorTable)
             self._updateModelDisplay()     
             
             elemNum =  self.elementButtonGroup.checkedId()
             self.setDisplay(elemNum)
     #After loading a file, reset the flag        
     self.isElementModified = False        
Example #13
0
 def _exportImageToPNG(self, filename=None):
     if not filename:
         if not self._export_png_dialog:
             dialog = self._export_png_dialog = QFileDialog(self, "Export image to PNG", ".", "*.png")
             dialog.setDefaultSuffix("png")
             dialog.setFileMode(QFileDialog.AnyFile)
             dialog.setAcceptMode(QFileDialog.AcceptSave)
             dialog.setModal(True)
             QObject.connect(dialog, SIGNAL("filesSelected(const QStringList &)"), self._exportImageToPNG)
         return self._export_png_dialog.exec_() == QDialog.Accepted
     busy = BusyIndicator()
     if isinstance(filename, QStringList):
         filename = filename[0]
     filename = str(filename)
     # make QPixmap
     nx, ny = self.image.imageDims()
     (l0, l1), (m0, m1) = self.image.getExtents()
     pixmap = QPixmap(nx, ny)
     painter = QPainter(pixmap)
     # use QwtPlot implementation of draw canvas, since we want to avoid caching
     xmap = QwtScaleMap()
     xmap.setPaintInterval(0, nx)
     xmap.setScaleInterval(l1, l0)
     ymap = QwtScaleMap()
     ymap.setPaintInterval(ny, 0)
     ymap.setScaleInterval(m0, m1)
     self.image.draw(painter, xmap, ymap, pixmap.rect())
     painter.end()
     # save to file
     try:
         pixmap.save(filename, "PNG")
     except Exception as exc:
         self.emit(SIGNAL("showErrorMessage"), "Error writing %s: %s" % (filename, str(exc)))
         return
     self.emit(SIGNAL("showMessage"), "Exported image to file %s" % filename)
Example #14
0
    def btnCardLocation_Clicked(self):
        try:
            savePath = str(QFileDialog.getSaveFileName(self, "Save as"))
            tempPath = savePath

            if len(savePath
                   ) > 8:  #teensy requires names of less than 8 characters
                savePath = os.path.join(os.path.dirname(savePath),
                                        os.path.basename(savePath)[:8])
            __SONGS_temp_ = {
                os.path.basename(tempPath): os.path.basename(savePath)
            }
            settings[0] = savePath
            if not os.path.exists(settings[0]):
                os.makedirs(settings[0])
            shelfFile = shelve.open('GUIconfig')

            if (not '__SONGS__' in shelfFile.keys()):
                shelfFile['__SONGS__'] = {}

            __SONGS_temp_2 = shelfFile['__SONGS__']

            if not list(__SONGS_temp_.keys())[0] in list(
                    __SONGS_temp_2.keys()):
                __SONGS_temp_2.update(__SONGS_temp_)
                shelfFile['__SONGS__'] = __SONGS_temp_2
                self.ui.SelectSong.addItems(list(__SONGS_temp_.keys()))
            else:
                pass
            #   print("key exists not adding")

            shelfFile.close()
            self.ui.lineEdit.setText(os.path.basename(tempPath))
        except Exception as e:
            pass
    def saveFavorite(self):

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        formats = \
                "Favorite (*.txt);;"\
                "All Files (*.*)"

        directory = self.currentWorkingDirectory
        saveLocation = directory + "/" + current_favorite + ".txt"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As",  # caption
            favfilepath,  #where to save
            formats,  # file format options
            QString("Favorite (*.txt)")  # selectedFilter
        )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            dir, fil = os.path.split(str(fn))
            self.setCurrentWorkingDirectory(dir)
            saveFavoriteFile(str(fn), favfilepath)
        return
Example #16
0
    def import_bookmarks(self):
        filename = QFileDialog.getOpenFileName(self, _("Import Bookmarks"), '%s' % os.getcwdu(), _("Pickled Bookmarks (*.pickle)"))
        if not filename:
            return

        imported = None
        with open(filename, 'r') as fileobj:
            imported = cPickle.load(fileobj)

        if imported is not None:
            bad = False
            try:
                for bm in imported:
                    if 'title' not in bm:
                        bad = True
                        break
            except:
                pass

            if not bad:
                bookmarks = self.get_bookmarks()
                for bm in imported:
                    if bm not in bookmarks:
                        bookmarks.append(bm)
                self.set_bookmarks([bm for bm in bookmarks if bm['title'] != 'calibre_current_page_bookmark'])
Example #17
0
    def start_download(self, request):
        if not self.gui:
            return

        url = unicode(request.url().toString())
        cf = self.get_cookies()

        filename = get_download_filename(url, cf)
        ext = os.path.splitext(filename)[1][1:].lower()
        filename = ascii_filename(filename[:60] + '.' + ext)
        if ext not in BOOK_EXTENSIONS:
            if ext == 'acsm':
                from calibre.gui2.dialogs.confirm_delete import confirm
                if not confirm(
                        '<p>' +
                        _('This ebook is a DRMed EPUB file.  '
                          'You will be prompted to save this file to your '
                          'computer. Once it is saved, open it with '
                          '<a href="http://www.adobe.com/products/digitaleditions/">'
                          'Adobe Digital Editions</a> (ADE).<p>ADE, in turn '
                          'will download the actual ebook, which will be a '
                          '.epub file. You can add this book to calibre '
                          'using "Add Books" and selecting the file from '
                          'the ADE library folder.'), 'acsm_download', self):
                    return
            home = os.path.expanduser('~')
            name = QFileDialog.getSaveFileName(
                self, _('File is not a supported ebook type. Save to disk?'),
                os.path.join(home, filename), '*.*')
            if name:
                name = unicode(name)
                self.gui.download_ebook(url, cf, name, name, False)
        else:
            self.gui.download_ebook(url, cf, filename, tags=self.tags)
    def _open_FASTA_File(self):
        """
        Open (read) the user specified FASTA sequence file and load it into
        the sequence field.

        @TODO: It only reads in the first line of the file. Also, it doesn't
               handle any special cases. (Once the special cases are clearly
               defined, that functionality will be added.

        @attention: This is not implemented yet.
        """
        #Urmi 20080714: should not this be only fasta file, for both load and save
        if self.parentWidget.assy.filename:
            odir = os.path.dirname(self.parentWidget.assy.filename)
        else:
            odir = env.prefs[workingDirectory_prefs_key]
        self.sequenceFileName = \
            str(QFileDialog.getOpenFileName(
                self,
                "Load FASTA sequence for " + self.current_protein.name,
                odir,
                "FASTA file (*.txt);;All Files (*.*);;"))
        lines = self.sequenceFileName
        try:
            lines = open(self.sequenceFileName, "rU").readlines()
        except:
            print "Exception occurred to open file: ", self.sequenceFileName
            return

        sequence = lines[0]
        sequence = QString(sequence)
        sequence = sequence.toUpper()
        self._setSequence(sequence)
        return
Example #19
0
    def import_bookmarks(self):
        filename = QFileDialog.getOpenFileName(self, _("Import Bookmarks"), '%s' % os.getcwdu(), _("Pickled Bookmarks (*.pickle)"))
        if filename == '':
            return

        imported = None
        with open(filename, 'r') as fileobj:
            imported = cPickle.load(fileobj)

        if imported != None:
            bad = False
            try:
                for bm in imported:
                    if len(bm) != 2:
                        bad = True
                        break
            except:
                pass

            if not bad:
                bookmarks = self._model.bookmarks[:]
                for bm in imported:
                    if bm not in bookmarks and bm['title'] != 'calibre_current_page_bookmark':
                        bookmarks.append(bm)
                self.set_bookmarks(bookmarks)
Example #20
0
 def rezip_epub2(self, epub, titre_dialogue="Enregistrer l'epub détatoué sous :"):
     self.setLabelText('Reconstruction de l\'epub')
     QtGui.QApplication.processEvents()
     # choix du nom de l'epub
     epub2 = QFileDialog.getSaveFileName(None, titre_dialogue, epub, 'epub(*.epub)')
     if zipfile.is_zipfile(epub):
         try:
             zepub = zipfile.ZipFile(epub2, mode="w",
                                    compression=zipfile.ZIP_DEFLATED, allowZip64=True)
             # d'abord le mimetype non compressé.
             zepub.write(os.path.join(self.dirtemp.name, "mimetype"), arcname="mimetype",
                            compress_type=zipfile.ZIP_STORED)
             # puis les autres fichiers
             exclude_files = ['.DS_Store', 'mimetype']
             for root, _dirs, files in os.walk(self.dirtemp.name):
                 for fn in files:
                     if fn in exclude_files:
                         continue
                     absfn = os.path.join(root, fn)
                     zfn = os.path.relpath(absfn, self.dirtemp.name).replace(os.sep, '/')
                     zepub.write(absfn, zfn)
             zepub.close()
         except:
             log('Impossible de rezipper cet epub.')
     return
Example #21
0
    def import_bookmarks(self):
        filename = QFileDialog.getOpenFileName(
            self, _("Import Bookmarks"), '%s' % os.getcwdu(),
            _("Pickled Bookmarks (*.pickle)"))
        if not filename:
            return

        imported = None
        with open(filename, 'r') as fileobj:
            imported = cPickle.load(fileobj)

        if imported is not None:
            bad = False
            try:
                for bm in imported:
                    if len(bm) != 2:
                        bad = True
                        break
            except:
                pass

            if not bad:
                bookmarks = self.get_bookmarks()
                for bm in imported:
                    if bm not in bookmarks and bm[
                            'title'] != 'calibre_current_page_bookmark':
                        bookmarks.append(bm)
                self.set_bookmarks(bookmarks)
Example #22
0
    def start_download(self, request):
        if not self.gui:
            return

        url = unicode(request.url().toString())
        cf = self.get_cookies()

        filename = get_download_filename(url, cf)
        ext = os.path.splitext(filename)[1][1:].lower()
        filename = ascii_filename(filename[:60] + '.' + ext)
        if ext not in BOOK_EXTENSIONS:
            if ext == 'acsm':
                from calibre.gui2.dialogs.confirm_delete import confirm
                if not confirm('<p>' + _('This ebook is a DRMed EPUB file.  '
                          'You will be prompted to save this file to your '
                          'computer. Once it is saved, open it with '
                          '<a href="http://www.adobe.com/products/digitaleditions/">'
                          'Adobe Digital Editions</a> (ADE).<p>ADE, in turn '
                          'will download the actual ebook, which will be a '
                          '.epub file. You can add this book to calibre '
                          'using "Add Books" and selecting the file from '
                          'the ADE library folder.'),
                          'acsm_download', self):
                    return
            home = os.path.expanduser('~')
            name = QFileDialog.getSaveFileName(self,
                _('File is not a supported ebook type. Save to disk?'),
                os.path.join(home, filename),
                '*.*')
            if name:
                name = unicode(name)
                self.gui.download_ebook(url, cf, name, name, False)
        else:
            self.gui.download_ebook(url, cf, filename, tags=self.tags)
Example #23
0
 def openStrandSequenceFile(self):
     """
     Open (read) the user specified Strand sequence file and enter the 
     sequence in the Strand sequence Text edit. Note that it ONLY reads the 
     FIRST line of the file.
     @TODO: It only reads in the first line of the file. Also, it doesn't
            handle any special cases. (Once the special cases are clearly 
            defined, that functionality will be added. 
     """
     
     if self.parentWidget.assy.filename: 
         odir = os.path.dirname(self.parentWidget.assy.filename)
     else: 
         odir = env.prefs[workingDirectory_prefs_key]
     self.sequenceFileName = \
         str(QFileDialog.getOpenFileName( 
             self,
             "Load Strand Sequence",
             odir,
             "Strand Sequnce file (*.txt);;All Files (*.*);;"))  
     lines = self.sequenceFileName
     try:
         lines = open(self.sequenceFileName, "rU").readlines()         
     except:
         print "Exception occurred to open file: ", self.sequenceFileName
         return 
     
     sequence = lines[0]
     sequence = QString(sequence) 
     sequence = sequence.toUpper()
     self._updateSequenceAndItsComplement(sequence)
     return
    def saveFavorite(self):
        """
        Writes the current favorite (selected in the combobox) to a file, any 
        where in the disk that 
        can be given to another NE1 user (i.e. as an email attachment).
        """

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        formats = \
                    "Favorite (*.txt);;"\
                    "All Files (*.*)"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As",  # caption
            favfilepath,  #where to save
            formats,  # file format options
            QString("Favorite (*.txt)")  # selectedFilter
        )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            saveFavoriteFile(str(fn), favfilepath)
        return
Example #25
0
    def loadTestruns(self):
        thedir = str(".")
        filenames = QFileDialog.getOpenFileNames(
            self,
            caption=("%s - Load testruns" % QApplication.applicationName()),
            directory=thedir,
            filter=str("Testrun files (*.trn)"))
        if filenames:
            loadedtrs = 0
            notloadedtrs = 0
            for filename in filenames:
                try:
                    print(filename)
                    tr = TestRun.loadFromFile(str(filename))
                    try:
                        self.addTestrun(tr)
                    except Exception as e:
                        print(e)

                    loadedtrs += 1
                except Exception:
                    notloadedtrs += 1

            message = "Loaded %d/%d test runs" % (loadedtrs,
                                                  loadedtrs + notloadedtrs)
            self.updateStatus(message)

        pass
Example #26
0
    def openStrandSequenceFile(self):
        """
        Open (read) the user specified Strand sequence file and enter the
        sequence in the Strand sequence Text edit. Note that it ONLY reads the
        FIRST line of the file.
        @TODO: It only reads in the first line of the file. Also, it doesn't
               handle any special cases. (Once the special cases are clearly
               defined, that functionality will be added.
        """

        if self.parentWidget.assy.filename:
            odir = os.path.dirname(self.parentWidget.assy.filename)
        else:
            odir = env.prefs[workingDirectory_prefs_key]
        self.sequenceFileName = \
            str(QFileDialog.getOpenFileName(
                self,
                "Load Strand Sequence",
                odir,
                "Strand Sequnce file (*.txt);;All Files (*.*);;"))
        lines = self.sequenceFileName
        try:
            lines = open(self.sequenceFileName, "rU").readlines()
        except:
            print "Exception occurred to open file: ", self.sequenceFileName
            return

        sequence = lines[0]
        sequence = QString(sequence)
        sequence = sequence.toUpper()
        self._updateSequenceAndItsComplement(sequence)
        return
Example #27
0
 def saveFavorite(self):
     """
     Save favorite file in a user chosen location
     """
     cmd = greenmsg("Save Favorite File: ")
     env.history.message(greenmsg("Save Favorite File:"))
     current_favorite = self.favoritesComboBox.currentText()
     favfilepath = getFavoritePathFromBasename(current_favorite)
     formats = \
             "Favorite (*.txt);;"\
             "All Files (*.*)"
     directory = self.currentWorkingDirectory
     saveLocation = directory + "/" + current_favorite + ".txt"
     fn = QFileDialog.getSaveFileName(
         self,
         "Save Favorite As", # caption
         favfilepath, #where to save
         formats, # file format options
         QString("Favorite (*.txt)") # selectedFilter
         )
     if not fn:
         env.history.message(cmd + "Cancelled")
     else:
         dir, fil = os.path.split(str(fn))
         self.setCurrentWorkingDirectory(dir)
         saveFavoriteFile(str(fn), favfilepath)
     return
Example #28
0
    def saveToFile(self):
        fdiag = QFileDialog()
        
        selectedFilter = QString()
        
        if foundPandas:
            filt = self.tr("Excel Open XML Document (*.xlsx);;Portable Network Graphics (*.png)")
        else:
            filt = self.tr("Portable Network Graphics (*.png)")

        fileName = fdiag.getSaveFileName(self, self.tr("Save Data As"),
                                        datetime.now().strftime('%Y-%m-%d-T%H%M%S-') + self.modeAscii,
                                        filt, selectedFilter)
        
        if len(fileName) == 0:
            return
        
        if 'png' in  selectedFilter:
            if fileName[-4:] == '.png':
                fileName = fileName[0:-4]
            
            px =  QPixmap.grabWidget(self.graphGrp)
            px.save(fileName + '.png', "PNG")
            return
        
        if fileName[-5:] == '.xlsx':
                fileName = fileName[0:-5]
        
        data = self.excelData.getData()
        if len(data) == 0:
            mb = QMessageBox()
            mb.setIcon(QMessageBox.Warning)
            mb.setWindowTitle(self.tr('Warning'))
            mb.setText(self.tr('No data exists. No output file has been produced.'))
            mb.exec_()
            return
        
        
        if data.ndim == 1: #Bad workaround if only one line exists
            add = []
            for idx in range(0,len(data)):
                add.append(0)
            data = np.vstack((data, np.array(add)))

        df = pandas.DataFrame(data, columns=['Frequency', self.modeTuple[0], self.modeTuple[1]])
        df.to_excel(str(fileName) + '.xlsx', index=False)
Example #29
0
 def loadObs(self):
     self.CalcProvisionals.setEnabled(True)
     fileName = QFileDialog.getOpenFileName(
         self, "Open Points File", "", "All Files (*);;Text Files (*.txt)",
         "")
     if fileName:
         #             self.lineEditPoints.setText(fileName)
         self.treeObs.clear()
         self.readObsFile(fileName)
Example #30
0
 def LoadAction(self):
     if not self.MainProgramm.DataSaved :
         msgbox = QMessageBox(QMessageBox.Question, "Frage", "Soll die vorherige Messung ueberschrieben werden ?", QMessageBox.No| QMessageBox.Yes)
         if not msgbox.exec_() == QMessageBox.Yes:
             return
     filename = QFileDialog.getOpenFileName(self,"Messung laden")
     if not filename == '':
         self.MainProgramm.LoadFile(filename)
     return
Example #31
0
    def export_bookmarks(self):
        filename = QFileDialog.getSaveFileName(self, _("Export Bookmarks"),
                '%s%suntitled.pickle' % (os.getcwdu(), os.sep),
                _("Saved Bookmarks (*.pickle)"))
        if not filename:
            return

        with open(filename, 'w') as fileobj:
            cPickle.dump(self.get_bookmarks(), fileobj)
    def export_bookmarks(self):
        filename = QFileDialog.getSaveFileName(self, _("Export Bookmarks"),
                '%s%suntitled.pickle' % (os.getcwdu(), os.sep),
                _("Saved Bookmarks (*.pickle)"))
        if filename == '':
            return

        with open(filename, 'w') as fileobj:
            cPickle.dump(self._model.bookmarks, fileobj)
Example #33
0
 def loadControl(self):
     self.CfileName = QFileDialog.getOpenFileName(
         self, "Open Points File", "", "All Files (*);;Text Files (*.txt)",
         "")
     if self.CfileName:
         #             self.lineEditPoints.setText(fileName)
         self.treeControl.clear()
         self.readControlFile(self.CfileName)
     self.updateControl.setVisible(True)
    def showOpenFileWin(self):
        fileDir = QFileDialog.getOpenFileName()
        myFile = open(fileDir, "r")

        with myFile:
            global fileContent
            fileContent = myFile.read()

        self.showNodesWin()
        self.addNode()
Example #35
0
    def loadObs(self):
        self.CalcProvisionals.setEnabled(True)
        fileName = QFileDialog.getOpenFileName(self,
                "Open Points File",
                "",
                "All Files (*);;Text Files (*.txt)", "")
        if fileName:
#             self.lineEditPoints.setText(fileName)
            self.treeObs.clear()
            self.readObsFile(fileName)
Example #36
0
    def loadControl(self):
        self.CfileName = QFileDialog.getOpenFileName(self,
                "Open Points File",
                "",
                "All Files (*);;Text Files (*.txt)", "")
        if self.CfileName:
#             self.lineEditPoints.setText(fileName)
            self.treeControl.clear()
            self.readControlFile(self.CfileName)
        self.updateControl.setVisible(True)
Example #37
0
 def _openFileCallback(self):
     if not self._open_file_dialog:
         filters = ";;".join(
             ["%s (%s)" % (name, " ".join(patterns)) for name, patterns, func in self._load_file_types])
         dialog = self._open_file_dialog = QFileDialog(self, "Open sky model", ".", filters)
         dialog.setFileMode(QFileDialog.ExistingFile)
         dialog.setModal(True)
         QObject.connect(dialog, SIGNAL("filesSelected(const QStringList &)"), self.openFile)
     self._open_file_dialog.exec_()
     return
Example #38
0
 def _chooseFile(self):
     if self._file_dialog is None:
         dialog = self._file_dialog = QFileDialog(self, self._dialog_label, ".", self._file_types)
         if self._default_suffix:
             dialog.setDefaultSuffix(self._default_suffix)
         dialog.setFileMode(self._file_mode)
         dialog.setModal(True)
         if self._dir is not None:
             dialog.setDirectory(self._dir)
         QObject.connect(dialog, SIGNAL("filesSelected(const QStringList &)"), self.setFilename)
     return self._file_dialog.exec_()
Example #39
0
 def _select_other_dialog(self):
     path = str(QFileDialog.getExistingDirectory(self, "Select purrlog", self.dirname))
     if not path:
         return
     if not Purr.Purrer.is_purrlog(path):
         QMessageBox.warning(self, "Invalid purrlog",
                             "The path you have selected, <tt>%s</tt>, does not refer to a valid purrlog." % Kittens.utils.collapseuser(
                                 path))
         return
     self.load_path = path
     self.wother.setText(Kittens.utils.collapseuser(path))
     self.checkCompleteness()
Example #40
0
 def LoadAction(self):
     if not self.MainProgramm.DataSaved:
         msgbox = QMessageBox(
             QMessageBox.Question, "Frage",
             "Soll die vorherige Messung ueberschrieben werden ?",
             QMessageBox.No | QMessageBox.Yes)
         if not msgbox.exec_() == QMessageBox.Yes:
             return
     filename = QFileDialog.getOpenFileName(self, "Messung laden")
     if not filename == '':
         self.MainProgramm.LoadFile(filename)
     return
Example #41
0
    def on_browseButton_clicked(self, checked=None):
        """
        Called when browse button for selecting the edf file is clicked.
        Opens a dialog for selecting a file.
        """
        if checked is None: return
        fileDialog = QFileDialog()

        self.fName = str(fileDialog.getOpenFileName(self, 
                                            'Select a file to convert',
                                            '/home/'))
        if self.fName != '':
            self.fName = self.fName.replace(" ", "\ ")
            self.ui.lineEditEdfName.setText(self.fName)
            splitted = str.split(self.fName, '/')
            destPath = '/'.join(splitted[:-1])
            #destPath = destPath.replace(" ", "\ ")
            self.ui.lineEditDestPath.setText(destPath)
            fifName = splitted[-1][:-4] + '.fif'
            #fifName = fifName.replace(" ", "\ ")
            self.ui.lineEditFifName.setText(fifName)
Example #42
0
    def _openFileDialog(self):
        """
        Opens the QFileDialog for accepting user input
        for the input image file path (self._filePath)
        """

        self._filePath = (str(
            QFileDialog.getOpenFileName(
                self, "Open Image Path", "",
                "Image file (*.jpg);;All Files (*.*);;")))
        self._filePath = os.path.normpath(self._filePath)
        self._dialog.inputLineEdit.setText(self._filePath)
Example #43
0
    def saveParserAs(self):
        filename = str(
            QFileDialog.getSaveFileName(self,
                                        caption="%s - Save a parser" %
                                        QApplication.applicationName(),
                                        directory=str("."),
                                        filter=str("XML files (*.xml)")))
        if not filename:
            return

        misc.saveAsXML(self.parser, filename)
        self.filename = filename
        self.updateStatus("Saved parser to file %s" % filename)
Example #44
0
 def _showAddDirectoryDialog(self):
     dd = str(QFileDialog.getExistingDirectory(self, "PURR: Add a directory to monitor")).strip()
     if dd:
         # adds a watched directory. Default initial setting of 'watching' is POUNCE if all
         # directories are in POUNCE state, or WATCHED otherwise.
         watching = max(Purr.WATCHED,
                        min([state for path, state in self.purrer.watchedDirectories()] or [Purr.WATCHED]))
         self.purrer.addWatchedDirectory(dd, watching)
         self.purrpipes[dd] = Purr.Pipe.open(dd)
         self.wdirlist.add(dd, watching)
         # update dialogs since dir list has changed
         dirs = [path for path, state in self.purrer.watchedDirectories()]
         self.new_entry_dialog.setDefaultDirs(*dirs)
         self.view_entry_dialog.setDefaultDirs(*dirs)
Example #45
0
    def _outputLocationPath(self):
        """
        Opens QFileDialog so that user can specify the output
        directory location. The result is stored in self._dirPath.
        """

        self._dirPath = (str(
            QFileDialog.getExistingDirectory(
                self, "Open Directory", "",
                QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)))

        self._dirPath = os.path.normpath(self._dirPath)

        self._dialog.outputLineEdit.setText(self._dirPath)
Example #46
0
 def resize(self):
     # on a choisi de remplacer la couv, redimesionnement et sauvegarde de la nouvelle image
     newcouv = QFileDialog.getOpenFileName(None, "Sélectionnez la nouvelle couverture :",
                                           QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation),
                                           "Images (*.png *.gif *.jpg *.jpeg *.bmp)")
     if not newcouv:
         return self.suppr_comm()
     log('\t remplacement de la couverture')
     newimg = Image.open(newcouv)
     im = Image.open(self.monepub.imagedecouv)
     oldwidth, oldheight = im.size
     newimg = newimg.resize((oldwidth, oldheight))
     newimg.save(self.monepub.imagedecouv)
     self.ccouv.close()
     return tatoo.suppr_tatoo(self.monepub)
Example #47
0
    def browseDirectories(self):
       """Slot method for the browse button of library page. """
       # Determine what directory to open.
       if self.w.assy.filename:
           odir = os.path.dirname(self.w.assy.filename)
       else:
           from utilities.prefs_constants import workingDirectory_prefs_key
           odir = env.prefs[workingDirectory_prefs_key]

       fdir = QFileDialog.getExistingDirectory(self, "Choose library directory", odir)
       libDir = str(fdir)
       if libDir and os.path.isdir(libDir):
           env.prefs[self.libPathKey] = libDir
           self.dirView.setRootPath(libDir)
           #Refresh GL-thumbView display
           self.newModel = None
           self.elemGLPane.updateModel(self.newModel)
Example #48
0
    def loadParser(self):
        thedir = str(".")
        filename = str(
            QFileDialog.getOpenFileName(self,
                                        caption="%s - Load a parser" %
                                        QApplication.applicationName(),
                                        directory=thedir,
                                        filter=str("XML files (*.xml)")))
        if filename:
            try:
                parser = ReaderManager.fromXMLFile(filename)
                message = "Loaded parser from %s" % filename
                self.setParser(parser)
            except Exception:
                message = "Error: Could not load parser from file %s" % filename

            self.updateStatus(message)
Example #49
0
    def stepSaveAs(self, phase=0):
        if phase == 0:
            self.setWindowTitle(QString(u'Сохранение файла'))
            self.progressBar.setValue(90)
            self.emitStep(self.stepSaveAs, 1)
            return

        saveCat = QFileDialog.getExistingDirectory(
            None, u"Сохранить в каталог", u"./logs", QFileDialog.ShowDirsOnly
            | QFileDialog.DontResolveSymlinks)
        print("save to " + saveCat)
        QtCore.QFile.remove(saveCat + '/' + getFile)
        if False == QtCore.QFile.copy(getFile, saveCat + '/' + getFile):
            print("error")
        QtCore.QFile.remove(getFile)

        app.closeAllWindows()
Example #50
0
    def saveStrandSequence(self):
        """
        Save the strand sequence entered in the Strand text edit in the 
        specified file. 
        """
        if not self.sequenceFileName:  
            sdir = env.prefs[workingDirectory_prefs_key]
        else:
            sdir = self.sequenceFileName
           
        fileName = QFileDialog.getSaveFileName(
                     self,              
                     "Save Strand Sequence As ...",
                     sdir,
                    "Strand Sequence File (*.txt)"
                     )
        
        if fileName:
            fileName = str(fileName)
            if fileName[-4] != '.':
                fileName += '.txt'
               
            if os.path.exists(fileName):
                
                # ...and if the "Save As" file exists...
                # ... confirm overwrite of the existing file.
                
                ret = QMessageBox.warning( 
                    self, 
                    "Save Strand Sequence...", 
                    "The file \"" + fileName + "\" already exists.\n"\
                    "Do you want to overwrite the existing file or cancel?",
                    "&Overwrite", "&Cancel", "",
                    0, # Enter == button 0
                    1 ) # Escape == button 1

                if ret == 1:
                    # The user cancelled
                    return 
                    
            # write the current set of element colors into a file    
            self._writeStrandSequenceFile(
                fileName,
                str(self.sequenceTextEdit.toPlainText()))
        return
Example #51
0
    def stepSelect(self, phase = 0):
        if phase == 0:
            self.setWindowTitle(QString(u'Выбрать архив'))
            self.progressBar.setValue(30)
            self.emitStep(self.stepSelect, 1)
            return
        
#         print("archive")
        self.archiveName = QFileDialog.getOpenFileName(None, u"Выберите архив",
                                                    u"cps/updates",
                                                    'CNC.upd.tar.gz')
        if(self.archiveName == ""):
            print("archiveName is null, exit")
            app.closeAllWindows()
            
        print("open " + self.archiveName)
#         time.sleep(5)
        self.emitStep(self.stepUpload)
Example #52
0
 def stepSaveAs(self, phase = 0):
     if phase == 0:
         self.setWindowTitle(QString(u'Сохранение файла'))
         self.progressBar.setValue(90)
         self.emitStep(self.stepSaveAs, 1)
         return
     
     saveCat = QFileDialog.getExistingDirectory(None, u"Сохранить в каталог",
                                                 u"./logs",
                                                 QFileDialog.ShowDirsOnly
                                               | QFileDialog.DontResolveSymlinks);
     print("save to " + saveCat)
     QtCore.QFile.remove( saveCat+'/' + getFile)
     if False == QtCore.QFile.copy(getFile, saveCat+'/' + getFile):
         print("error");
     QtCore.QFile.remove( getFile)
        
     app.closeAllWindows()
Example #53
0
    def openFileChooserDialog(self):
        """
        Prompts the user to choose a file from disk and inserts the full path
        into the lineEdit widget.
        """

        _dir = getDefaultWorkingDirectory()

        if self.directory:
            if os.path.isdir(self.directory):
                _dir = self.directory

        fname = QFileDialog.getOpenFileName(self, self.caption, _dir, self.filter)

        if fname:
            self.setText(fname)
            self.lineEdit.emit(SIGNAL("editingFinished()"))

        return
Example #54
0
    def get_sync_app_fs(self):
        '''
        Get path to selected sync_app
        '''
        self._log_location()
        sync_app = unicode(QFileDialog.getOpenFileName(
            self.gui,
            "Select sync app",
            os.path.expanduser("~"),
            "*.app").toUtf8())
        if sync_app:
            # Populate the filespec edit control
            self._log(sync_app)
            self.sync_app_path_le.setText(sync_app)

            # Populate the putative app name
            app_name = os.path.basename(sync_app)
            root_name = app_name.split('.')[0]
            self.app_name_le.setText(root_name)
Example #55
0
    def write_element_rgb_table(self):
        """
        Save the current set of element preferences into an external file --
        currently only r,g,b color of each element will be saved.
        """
        if not self.fileName:
            from utilities.prefs_constants import workingDirectory_prefs_key   
            sdir = env.prefs[workingDirectory_prefs_key]
        else:
            sdir = self.fileName
           
        fn = QFileDialog.getSaveFileName(
                     self,              
                     "Save Element Colors As ...",
                     sdir,
                    "Element Color File (*.txt)"
                     )
        
        if fn:
            fn = str(fn)
            if fn[-4] != '.':
                fn += '.txt'
            
            import os    
            if os.path.exists(fn): # ...and if the "Save As" file exists...
                # ... confirm overwrite of the existing file.
                ret = QMessageBox.warning( self, "Save Element Colors...",
                    "The file \"" + fn + "\" already exists.\n"
                      "Do you want to overwrite the existing file or cancel?",
                    "&Overwrite", "&Cancel", "",
                    0,      # Enter == button 0
                    1 )     # Escape == button 1

                if ret == 1: # The user cancelled
                    return 
                    
            # write the current set of element colors into a file    
            saveElementColors(fn, self.elemTable.getAllElements())
            env.history.message("Element colors saved in file: [" + fn + "]")
            #After saving a file, reset the flag        
            self.isFileSaved = True        
    def saveFavorite(self):
        """
        Writes the current favorite (selected in the combobox) to a file, any
        where in the disk that
        can be given to another NE1 user (i.e. as an email attachment).
        """

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        #Check to see if favfilepath exists first
        if not os.path.exists(favfilepath):
            msg = "%s does not exist" % favfilepath
            env.history.message(cmd + msg)
            return
        formats = \
                    "Favorite (*.txt);;"\
                    "All Files (*.*)"

        directory = self.currentWorkingDirectory
        saveLocation = directory + "/" + current_favorite + ".txt"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As", # caption
            saveLocation, #where to save
            formats, # file format options
            QString("Favorite (*.txt)") # selectedFilter
            )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            #remember this directory

            dir, fil = os.path.split(str(fn))
            self.setCurrentWorkingDirectory(dir)
            saveFavoriteFile(str(fn), favfilepath)
        return