我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用PySide.QtGui.QFileDialog()。
def zmianaSciezkiF(self): ''' change output file path ''' fileName = QtGui.QFileDialog().getExistingDirectory(None, 'Output directory', QtCore.QDir.homePath(), QtGui.QFileDialog.ShowDirsOnly) if fileName: self.pathToFile.setText(fileName) ##*********************************************************************** ##* CONSOLE ##***********************************************************************
def brdIn(): board=qg.QFileDialog().getOpenFileName() [0] try: radice=et.parse(board).getroot() el=[] pos=[] for ramo in radice.iter('element'): el.append(ramo) for e in el: x=float(e.attrib['x']) y=float(e.attrib['y']) if ('rot' in e.attrib) and (e.attrib['rot'].lstrip('R').isdigit()): rot=float(e.attrib['rot'].lstrip('R')) else: rot=0.0 pos.append([e.attrib['name'],[x,y,rot]]) dpos=dict(pos) for k in dpos.keys(): App.Console.PrintMessage(str(k)+'\t'+str(dpos[k])+'\n') return dpos except: App.Console.PrintMessage('no such file\n')
def save_as(self, document): """ Launch a Qt file browser to select a file, then save the supplied document to that path. :param document: The document to save. """ from sgtk.platform.qt import QtGui try: doc_path = document.fullName.fsName except RuntimeError: doc_path = None # photoshop doesn't appear to have a "save as" dialog accessible via # python. so open our own Qt file dialog. file_dialog = QtGui.QFileDialog( parent=self._get_dialog_parent(), caption="Save As", directory=doc_path, filter="Photoshop Documents (*.psd)" ) file_dialog.setLabelText(QtGui.QFileDialog.Accept, "Save") file_dialog.setLabelText(QtGui.QFileDialog.Reject, "Cancel") file_dialog.setOption(QtGui.QFileDialog.DontResolveSymlinks) file_dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog) if not file_dialog.exec_(): return path = file_dialog.selectedFiles()[0] if path: self.save_to_path(document, path)
def zmianaSciezkiF(self): fileName = QtGui.QFileDialog().getSaveFileName(None, 'Save as', QtCore.QDir.homePath(), supSoftware[self.exportType.programName]['format']) if fileName[0]: fileName = fileName[0] program = str(self.listaFormatow.currentItem().data(QtCore.Qt.UserRole)) if not fileName.endswith('.{0}'.format(supSoftware[program]['format'].split('.')[1])): fileName += '.{0}'.format(supSoftware[program]['format'].split('.')[1]) self.pathToFile.setText(fileName) #*********************************************************************** #* CONSOLE #***********************************************************************
def zmianaSciezkiF(self): ''' change output file path ''' fileName = QtGui.QFileDialog().getExistingDirectory(None, 'Output directory', QtCore.QDir.homePath(), QtGui.QFileDialog.ShowDirsOnly) if fileName: self.pathToFile.setText(fileName)
def changePathF(self): path = QtGui.QFileDialog().getSaveFileName(self, u"Save as", os.path.expanduser("~"), "*.xml") fileName = path[0] if not fileName == "": if not fileName.endswith('xml'): fileName = fileName + '.xml' self.filePath.setText(fileName) self.changePathFInfo()
def zmianaSciezkiF(self): ''' change output file path ''' fileName = QtGui.QFileDialog().getExistingDirectory(None, 'Output directory', QtCore.QDir.homePath(), QtGui.QFileDialog.ShowDirsOnly) if fileName: self.pathToFile.setText(fileName) #*********************************************************************** #* CONSOLE #***********************************************************************
def chooseFile(self): dial = QtGui.QFileDialog().getOpenFileName(self, u"Choose file", "~", "*.fcstd") if dial: self.fileName.setText(dial[0])
def changePathF(self): path = QtGui.QFileDialog().getSaveFileName(self, u"Save as", os.path.expanduser("~"), "*.inc") fileName = path[0] if not fileName == "": if not fileName.lower().endswith('inc'): fileName = fileName + '.inc' self.filePath.setText(fileName) self.changePathFInfo()
def openFileDialog( self, name, openDialog ): if bool(openDialog): pathDialog = QtGui.QFileDialog() pathDialog.setFileMode( QtGui.QFileDialog.AnyFile ) newFile = str( pathDialog.getOpenFileName(self.MainWindow, name, "")[0] ) else: # Get directory from the lineedit object print( "TODO" ) if name == u'OrientGain_GainRef': self.ui_OrienGainRefDialog.leGainRefPath.setText( newFile ) elif name == u'OrientGain_TargetStack': self.ui_OrienGainRefDialog.leInputPath.setText( newFile ) elif name == 'qsubHeader': self.cfgCluster[u'qsubHeader'] = newFile # Would prefer to generate a signal here. self.leQsubHeaderFile.setText( newFile ) elif name == u'gautoTemplates': self.cfgGauto[u'T'] = newFile self.leGautoTemplates.setText( newFile ) elif name == u'gainRef': # self.zorroDefault.files['gainRef'] = newFile print( "openFileDialog: Setting gainRef to %s" % newFile ) self.skulk.paths['gainRef'] = newFile self.ui_FileLocDialog.leGainRefPath.setText( newFile )
def openFileBrowser(self): fileBrowser = QtGui.QFileDialog(self) fileBrowser.setNameFilter("Json (*.json)") if fileBrowser.exec_(): filesPath = fileBrowser.selectedFiles() if len(filesPath) > 0: self.openFile(filesPath[0])
def chooseFoamDir(self): d = QtGui.QFileDialog().getExistingDirectory(None, 'Choose OpenFOAM directory', self.foam_dir) if d and os.access(d, os.W_OK): self.foam_dir = d self.form.le_foam_dir.setText(self.foam_dir)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) # self.dir = os.getcwd() self.fDialog = QtGui.QFileDialog(self) self.fname ='' self.cImg = None self.ui.tabWidget.setEnabled(False) self.isModelLoaded = False self.net = None self.load()
def getFromFile(): '''Input polar coord. from .csv: returns a list of (x,y,0). The file must be ";" separated: column A = radius, column B = angle''' from PySide import QtGui fileIn=open(QtGui.QFileDialog().getOpenFileName()[0],'r') lines=fileIn.readlines() fileIn.close() xyCoord=[] for line in lines: polarCoord=line.split(';') xyCoord.append(polar2xy(float(polarCoord[0]),float(polarCoord[1])*math.pi/180)) return xyCoord
def openPathDialog( self, pathname, openDialog ): # Comments on how to handle updates from a lineedit Qt object # http://stackoverflow.com/questions/12182133/pyqt4-combine-textchanged-and-editingfinished-for-qlineedit if bool(openDialog): pathDialog = QtGui.QFileDialog() pathDialog.setFileMode( QtGui.QFileDialog.Directory ) pathDialog.setOption( QtGui.QFileDialog.ShowDirsOnly, True ) newPath = str(pathDialog.getExistingDirectory(self.MainWindow,pathname, "")) print( "New path for "+ pathname + " : " + newPath ) else: # Get directory from the lineedit object print( "TODO" ) #self.FileLocDialog.raise_() self.FileLocDialog.activateWindow() if pathname == u'input_dir': self.skulk.paths[pathname] = newPath self.ui_FileLocDialog.leInputPath.setText( self.skulk.paths.get_real(pathname) ) elif pathname == u'output_dir': self.skulk.paths[pathname] = newPath self.ui_FileLocDialog.leOutputPath.setText( self.skulk.paths.get_real(pathname) ) elif pathname == u'raw_subdir': self.skulk.paths[pathname] = newPath self.ui_FileLocDialog.leRawPath.setText( self.skulk.paths.get_real(pathname) ) elif pathname == u'sum_subdir': self.skulk.paths[pathname] = newPath self.ui_FileLocDialog.leSumPath.setText( self.skulk.paths.get_real(pathname) ) elif pathname == u'align_subdir': self.skulk.paths[pathname] = newPath self.ui_FileLocDialog.leAlignPath.setText( self.skulk.paths.get_real(pathname) ) elif pathname == u'fig_subdir': self.skulk.paths[pathname] = newPath self.ui_FileLocDialog.leFiguresPath.setText( self.skulk.paths.get_real(pathname) ) elif pathname == u'cachePath': print( "TODO: Automator.openPathDialog; manage cachePath" ) pass