本文整理汇总了Python中javax.swing.JFileChooser.setCurrentDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.setCurrentDirectory方法的具体用法?Python JFileChooser.setCurrentDirectory怎么用?Python JFileChooser.setCurrentDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.setCurrentDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MultiFileDialog
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setCurrentDirectory [as 别名]
def MultiFileDialog(title):
#hide/show debug prints
verbose = 0
# Choose image file(s) to open
fc = JFileChooser()
fc.setMultiSelectionEnabled(True)
fc.setDialogTitle(title)
sdir = OpenDialog.getDefaultDirectory()
if sdir!=None:
fdir = File(sdir)
if fdir!=None:
fc.setCurrentDirectory(fdir)
returnVal = fc.showOpenDialog(IJ.getInstance())
if returnVal!=JFileChooser.APPROVE_OPTION:
return
files = fc.getSelectedFiles()
paths = []
for i in range(len(files)):
paths.append(os.path.join(files[i].getParent(), files[i].getName()))
if verbose > 0:
for i in range(len(files)):
path = os.path.join(files[i].getParent(), files[i].getName())
print "Path: " + path
return paths
示例2: onOpenFile
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setCurrentDirectory [as 别名]
def onOpenFile(self, event):
''' remember to change the path'''
chooseFile = JFileChooser()
chooseFile.setCurrentDirectory(File('C:\Users\fragom\PhD_CIM\Modelica\Models'))
filtro = FileNameExtensionFilter("mo files", ["mo"])
chooseFile.addChoosableFileFilter(filtro)
ret = chooseFile.showDialog(self, "Choose file")
if ret == JFileChooser.APPROVE_OPTION:
self.faile= chooseFile.getSelectedFile()
if event.getActionCommand() == "Load Model":
self.cbMoFile.addItem(self.faile.getPath())
self.cbMoFile.selectedItem= self.faile.getPath()
if event.getActionCommand() == "Load Library":
self.cbMoLib.addItem(self.faile.getPath())
self.cbMoLib.selectedItem= self.faile.getPath()
示例3: openGVL
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setCurrentDirectory [as 别名]
def openGVL():
from javax.swing import JFileChooser
GUIUtil=PluginServices.getPluginServices("com.iver.cit.gvsig.cad").getClassLoader().loadClass("com.iver.cit.gvsig.gui.GUIUtil")
chooser = JFileChooser()
chooser.setFileFilter(GUIUtil().createFileFilter("GVL Legend File",["gvl"]))
from java.util.prefs import Preferences
lastPath = Preferences.userRoot().node("gvsig.foldering").get("DataFolder", "null")
chooser.setCurrentDirectory(File(lastPath))
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY)
returnVal = chooser.showOpenDialog(None)
if returnVal == chooser.APPROVE_OPTION:
gvlPath = chooser.getSelectedFile().getPath()
elif returnVal == chooser.CANCEL_OPTION:
JOptionPane.showMessageDialog(None, "You have to open a .gvl file. Retry!","Batch Legend",JOptionPane.WARNING_MESSAGE)
gvlPath = ""
return gvlPath
示例4: FolderDialog
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setCurrentDirectory [as 别名]
def FolderDialog(title, folder):
fc = JFileChooser()
fc.setMultiSelectionEnabled(False)
fc.setDialogTitle(title)
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setAcceptAllFileFilterUsed(False);
if folder ==None:
sdir = OpenDialog.getDefaultDirectory()
else:
sdir = folder
if sdir!=None:
fdir = File(sdir)
if fdir!=None:
fc.setCurrentDirectory(fdir)
returnVal = fc.showOpenDialog(IJ.getInstance())
if returnVal!=JFileChooser.APPROVE_OPTION:
return
folder = fc.getSelectedFile();
path = os.path.join(folder.getParent(), folder.getName())
return path
示例5: go
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setCurrentDirectory [as 别名]
def go(self, fileTypes=None, default=None, directoryAllowed=False):
fileChooser = JFileChooser()
if self.title:
fileChooser.setDialogTitle(self.title)
if default:
fileChooser.setSelectedFile(java.io.File(default))
fileChooser.setCurrentDirectory(java.io.File("."))
if fileTypes:
for extension, description in fileTypes:
fileChooser.addChoosableFileFilter(FileFilterForExtension(extension, description))
if self.loadOrSave == "load":
result = fileChooser.showOpenDialog(self.parent)
else:
result = fileChooser.showSaveDialog(self.parent)
if (result == JFileChooser.APPROVE_OPTION):
fileResult = None
fileAndMaybeDir = fileChooser.getSelectedFile().getAbsoluteFile()
if directoryAllowed or not fileAndMaybeDir.isDirectory():
fileResult = str(fileAndMaybeDir)
return fileResult
else:
return None