Exemplo n.º 1
0
 def loadFilename( self, filename = '' ):
     """
     Loads a new XDK file into the system.
     
     :param      filename | <str>
     
     :return     <bool> | success
     """
     if ( not (filename and isinstance(filename, basestring)) ):
         filename = QFileDialog.getOpenFileName( self,
                                                 'Open XDK File',
                                                 QDir.currentPath(),
                                                 'XDK Files (*.xdk)' )
         
         if type(filename) == tuple:
             filename = nativestring(filename[0])
         
         if not filename:
             return False
     
     if not (filename and os.path.exists(filename)):
         return False
     
     elif filename in self.loadedFilenames():
         return False
     
     self.loadFileRequested.emit(filename)
     self.setCursor(Qt.WaitCursor)
     
     return True
Exemplo n.º 2
0
    def loadFilename(self, filename=''):
        """
        Loads a new XDK file into the system.
        
        :param      filename | <str>
        
        :return     <bool> | success
        """
        if (not (filename and isinstance(filename, basestring))):
            filename = QFileDialog.getOpenFileName(self, 'Open XDK File',
                                                   QDir.currentPath(),
                                                   'XDK Files (*.xdk)')

            if type(filename) == tuple:
                filename = nativestring(filename[0])

            if not filename:
                return False

        if not (filename and os.path.exists(filename)):
            return False

        elif filename in self.loadedFilenames():
            return False

        self.loadFileRequested.emit(filename)
        self.setCursor(Qt.WaitCursor)

        return True
Exemplo n.º 3
0
    def pickAttachment(self):
        """
        Prompts the user to select an attachment to add to this edit.
        """
        filename = QFileDialog.getOpenFileName(self.window(),
                                               'Select Attachment', '',
                                               'All Files (*.*)')

        if type(filename) == tuple:
            filename = nativestring(filename[0])

        filename = nativestring(filename)
        if filename:
            self.addAttachment(os.path.basename(filename), filename)
Exemplo n.º 4
0
 def pickFilepath( self ):
     """
     Picks the image file to use for this icon path.
     """
     filepath = QFileDialog.getOpenFileName( self,
                                             'Select Image File',
                                             QDir.currentPath(),
                                             self.fileTypes())
     
     if type(filepath) == tuple:
         filepath = nativestring(filepath[0])
     
     if ( filepath ):
         self.setFilepath(filepath)
Exemplo n.º 5
0
 def pickAttachment(self):
     """
     Prompts the user to select an attachment to add to this edit.
     """
     filename = QFileDialog.getOpenFileName(self.window(),
                                            'Select Attachment',
                                            '',
                                            'All Files (*.*)')
     
     if type(filename) == tuple:
         filename = nativestring(filename[0])
     
     filename = nativestring(filename)
     if filename:
         self.addAttachment(os.path.basename(filename), filename)
Exemplo n.º 6
0
    def importProfile(self, filename=None):
        """
        Imports the profiles from the given filename.
        
        :param      filename | <str> || None
        """
        if not filename:
            filename = QFileDialog.getOpenFileName(self, 'Import Perspective',
                                                   '', 'XML Files (*.xml)')

            if type(filename) == tuple:
                filename = nativestring(filename[0])

        if not (filename and os.path.exists(filename)):
            return False

        prof = XViewProfile.load(filename)
        if prof:
            self.addProfile(prof)
Exemplo n.º 7
0
 def pickFilepath( self ):
     """
     Prompts the user to select a filepath from the system based on the \
     current filepath mode.
     """
     mode = self.filepathMode()
     
     filepath = ''
     filepaths = []
     curr_dir = nativestring(self._filepathEdit.text())
     if ( not curr_dir ):
         curr_dir = QDir.currentPath()
     
     if mode == XFilepathEdit.Mode.SaveFile:
         filepath = QFileDialog.getSaveFileName( self,
                                                 self.windowTitle(),
                                                 curr_dir,
                                                 self.filepathTypes() )
                                                 
     elif mode == XFilepathEdit.Mode.OpenFile:
         filepath = QFileDialog.getOpenFileName( self,
                                                 self.windowTitle(),
                                                 curr_dir,
                                                 self.filepathTypes() )
     
     elif mode == XFilepathEdit.Mode.OpenFiles:
         filepaths = QFileDialog.getOpenFileNames( self,
                                                   self.windowTitle(),
                                                   curr_dir,
                                                   self.filepathTypes() )
     
     else:
         filepath = QFileDialog.getExistingDirectory( self,
                                                      self.windowTitle(),
                                                      curr_dir )
     
     if filepath:
         if type(filepath) == tuple:
             filepath = filepath[0]
         self.setFilepath(nativestring(filepath))
     elif filepaths:
         self.setFilepaths(map(str, filepaths))
Exemplo n.º 8
0
 def importProfile(self, filename=None):
     """
     Imports the profiles from the given filename.
     
     :param      filename | <str> || None
     """
     if not filename:
         filename = QFileDialog.getOpenFileName( self,
                                                 'Import Perspective',
                                                 '',
                                                 'XML Files (*.xml)')
         
         if type(filename) == tuple:
             filename = nativestring(filename[0])
         
     if not (filename and os.path.exists(filename)):
         return False
     
     prof = XViewProfile.load(filename)
     if prof:
         self.addProfile(prof)