当前位置: 首页>>代码示例>>Python>>正文


Python JFileChooser.setCurrentDirectory方法代码示例

本文整理汇总了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
开发者ID:BWHCNI,项目名称:workflow,代码行数:31,代码来源:OMUtilities.py

示例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()
开发者ID:fran-jo,项目名称:SimuGUI,代码行数:17,代码来源:meegui_jy.py

示例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
开发者ID:nachouve,项目名称:uve_gvsig_scripts,代码行数:18,代码来源:batchLegend.py

示例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
开发者ID:BWHCNI,项目名称:workflow,代码行数:22,代码来源:Grab_MetaData.py

示例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
开发者ID:pdfernhout,项目名称:openvirgle,代码行数:24,代码来源:browser.py


注:本文中的javax.swing.JFileChooser.setCurrentDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。