def getFile(parent, title, cb, filter='*.*', dir=None, key=None):
 assert ((not dir) or (not key))
 if (not dir):
  dirkey = (key + 'Directory')
  dir = aqt.mw.pm.profile.get(dirkey, '')
 else:
  dirkey = None
 d = QFileDialog(parent)
 d.setFileMode(QFileDialog.ExistingFile)
 if os.path.exists(dir):
  d.setDirectory(dir)
 d.setWindowTitle(title)
 d.setNameFilter(filter)
 ret = []
 def accept():
  file = str(list(d.selectedFiles())[0])
  if dirkey:
   dir = os.path.dirname(file)
   aqt.mw.pm.profile[dirkey] = dir
  if cb:
   cb(file)
  ret.append(file)
 d.accepted.connect(accept)
 d.exec_()
 return (ret and ret[0])

def getFile ( parent , title , cb , filter = '*.*' , dir = None , key = None ) : assert ( ( not dir ) or ( not key ) ) if ( not dir ) : dirkey = ( key + 'Directory' ) dir = aqt . mw . pm . profile . get ( dirkey , '' ) else : dirkey = None d = QFileDialog ( parent ) d . setFileMode ( QFileDialog . ExistingFile ) if os . path . exists ( dir ) : d . setDirectory ( dir ) d . setWindowTitle ( title ) d . setNameFilter ( filter ) ret = [ ] def accept ( ) : file = str ( list ( d . selectedFiles ( ) ) [ 0 ] ) if dirkey : dir = os . path . dirname ( file ) aqt . mw . pm . profile [ dirkey ] = dir if cb : cb ( file ) ret . append ( file ) d . accepted . connect ( accept ) d . exec_ ( ) return ( ret and ret [ 0 ] )
ask the user for a file .