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


Python JFileChooser.showOpenDialog方法代码示例

本文整理汇总了Python中javax.swing.JFileChooser.showOpenDialog方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.showOpenDialog方法的具体用法?Python JFileChooser.showOpenDialog怎么用?Python JFileChooser.showOpenDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFileChooser的用法示例。


在下文中一共展示了JFileChooser.showOpenDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: chooseFile

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
def chooseFile():
    global frame, dataPath
    global systemPanel, chartPanel
    global isTemporal
    fc = JFileChooser(dataPath)
    retVal = fc.showOpenDialog(frame)
    if retVal != JFileChooser.APPROVE_OPTION:
        return
    fname = fc.getSelectedFile().getAbsolutePath()
    dataPath = os.sep.join(fname.split(os.sep)[:-1])
    if isTemporal:
        info(frame, "We need a file with information about the temporal point of each sample")
        tfc = JFileChooser(dataPath)
        tRetVal = tfc.showOpenDialog(frame)
        if retVal != JFileChooser.APPROVE_OPTION:
            return
        tname = tfc.getSelectedFile().getAbsolutePath()
    systemPanel.enableChartFun = False
    chartPanel.resetData()
    loadGenePop(fname)
    if isTemporal:
        if not loadTemporal(tname):
            return
    updateAll()
    enablePanel(empiricalPanel)
开发者ID:tiagoantao,项目名称:lositan,代码行数:27,代码来源:Main.py

示例2: MultiFileDialog

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [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

示例3: FileManager

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
class FileManager(object):
    
    def __init__(self, pywin):
        self.fc = JFileChooser()
        self.fc.fileFilter = FileNameExtensionFilter("Python Files", ["py"])
        self.pywin = pywin
        self.load_path = None
        self.script_path = None

    @property
    def script_area(self):
        return self.pywin.script_pane.script_area
    
    def show_open_dialog(self, title):
        self.fc.dialogTitle = title
        res = self.fc.showOpenDialog(self.pywin.frame)
        if res == JFileChooser.APPROVE_OPTION:
            return self.fc.selectedFile
    
    def show_save_dialog(self, title):
        self.fc.dialogTitle = title
        res = self.fc.showSaveDialog(self.pywin.frame)
        if res == JFileChooser.APPROVE_OPTION:
            return self.fc.selectedFile
    
    def save_script(self):
        if self.script_path is None:
            return
        with codecs.open(self.script_path, "wb", "utf-8") as stream:
            stream.write(self.script_area.input)
    
    def open_script(self):
        f = self.show_open_dialog("Select script file to open")
        if f is None:
            return
        self.script_path = f.absolutePath
        with codecs.open(self.script_path, "rb", "utf-8") as stream:
            self.script_area.input = stream.read()
    
    def save_script_as(self):
        f = self.show_save_dialog("Select file to write script to")
        if f is None:
            return
        self.script_path = f.absolutePath
        self.save_script()
    
    def load_script(self):
        f = self.show_open_dialog("Select script file to load")
        if f is None:
            return
        self.load_path = f.absolutePath
        self.reload_script()
    
    def reload_script(self):
        print "*** Loading", self.load_path, "***"
        try:
            self.pywin.execfile(self.load_path)
        except Exception, e:
            self.pywin.outputpane.addtext(str(e) + '\n', 'error')
开发者ID:aeriksson,项目名称:geogebra,代码行数:61,代码来源:gui.py

示例4: loadPopNames

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
def loadPopNames():
    global frame, empiricalPanel
    fc = JFileChooser(dataPath)
    retVal = fc.showOpenDialog(frame)
    if retVal == JFileChooser.APPROVE_OPTION:
        file = fc.getSelectedFile()
        loadFilePopNames(file)
        updateAll()
        enablePanel(empiricalPanel)
开发者ID:tiagoantao,项目名称:lositan,代码行数:11,代码来源:Main.py

示例5: getFile

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
 def getFile(self,button):
     dlg = JFileChooser()
     result = dlg.showOpenDialog(None)
     if result == JFileChooser.APPROVE_OPTION:
         f = dlg.getSelectedFile()
         path = f.getPath()
         self.FileText.setText(path)
         try:
             self.getIPList(path)
         except:
             exit(0)
开发者ID:0x24bin,项目名称:BurpSuite,代码行数:13,代码来源:Burp_MultiProxy.py

示例6: GnitPickFileChooser

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
class GnitPickFileChooser(ActionListener):
  def __init__(self,frm):
    self.frame = frm

  def actionPerformed(self,e):
      self.chooser = JFileChooser()
      self.option = self.chooser.showOpenDialog(self.frame)
      
      if (self.option == JFileChooser.APPROVE_OPTION):
          self.frame.statusbar.setText("You chose " + self.chooser.getSelectedFile().getName())
      else:
          self.frame.statusbar.setText("You cancelled.")
开发者ID:mcamiano,项目名称:gnitpick,代码行数:14,代码来源:GnitPickFileChooser.py

示例7: get_image_file

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
	def get_image_file(self) :
		file_dialog = JFileChooser()
		#image files
		image_filter = FileNameExtensionFilter("Image Files", 
			["jpg","bmp","png","gif"])
		print image_filter.getExtensions()
		file_dialog.setFileFilter(image_filter)
		x = file_dialog.showOpenDialog(None)
		if x == JFileChooser.APPROVE_OPTION :
			return file_dialog.getSelectedFile()
		else :
			return None
开发者ID:bkap,项目名称:MICT,代码行数:14,代码来源:imagetool.py

示例8: _configFileDialogue

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
 def _configFileDialogue(self):
     from javax.swing import JFileChooser
     from javax.swing.filechooser import FileNameExtensionFilter
     fileDialogue = JFileChooser(self.dssFilePath)
     filter = FileNameExtensionFilter("Configuration file (*.yml; *.yaml)",
                                      ["yaml", "yml"])
     fileDialogue.setFileFilter(filter)
     ret = fileDialogue.showOpenDialog(self.mainWindow)
     if ret == JFileChooser.APPROVE_OPTION:
         return fileDialogue.getSelectedFile().getAbsolutePath()
     else:
         raise CancelledError("Config file selection was cancelled.")
开发者ID:EnviroCentre,项目名称:monitoring-module,代码行数:14,代码来源:__init__.py

示例9: set_from_file

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
    def set_from_file(self, event):
        fileChooser = JFileChooser()
        if self.filename is not None:
            fileChooser.setSelectedFile(java.io.File(self.filename))

        if fileChooser.showOpenDialog(self) == JFileChooser.APPROVE_OPTION:
            self.filename = fileChooser.selectedFile.absolutePath

            #TODO: this doesn't for for nested FunctionInputs
            input = self.view.network.getNode(self.name)

            from nef.functions import Interpolator
            interp = Interpolator(self.filename)
            interp.load_into_function(input)
开发者ID:Elhamahm,项目名称:nengo_1.4,代码行数:16,代码来源:function.py

示例10: check_directory

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
def check_directory(path):

	if (os.path.lexists(path)):
		contents=os.listdir(path)
		
		if (contents.count("install-birch")==0):
			print_console("The selected directory "+path+" does NOT contain a BIRCH installation!")
			message="The selected path does NOT contain a BIRCH installation.\nPlease select the base directory of the installation that you wish to update,\nOr click \"no\" to cancel update."
			reload = JOptionPane.showConfirmDialog(None,message, "Input",JOptionPane.YES_NO_OPTION);
		
			if (reload==JOptionPane.NO_OPTION):
				print_console("User aborted install.")
				commonlib.shutdown()
			
			fc = JFileChooser();
			fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
			fc.showOpenDialog(None);
			path = fc.getSelectedFile().getPath();
			
			check_directory(path)
			
		else:
			ARGS.install_dir=path
			print_console("The selected directory "+path+" contains a BIRCH installation, it will be updated")
开发者ID:dalehamel,项目名称:getbirch,代码行数:26,代码来源:__init__.py

示例11: browse

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
 def browse(self, event=None):
     '''
     Open new dialog for the user to select a path as default working dir.
     '''
     default_path = self.wd_field.getText()
     if not os.path.isdir(default_path):
         default_path = os.getcwd()
     fileChooser = JFileChooser(default_path)
     fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
     # Fixed showDialog bug using showOpenDialog instead. The former was
     # duplicating the last folder name in the path due to a Java bug in
     # OSX in the implementation of JFileChooser!
     status = fileChooser.showOpenDialog(self)
     if status == JFileChooser.APPROVE_OPTION:
         self.wd_field.setText(fileChooser.getSelectedFile().toString())
开发者ID:oracc,项目名称:nammu,代码行数:17,代码来源:EditSettingsView.py

示例12: openGVL

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [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

示例13: __init__

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
 def __init__(self, configFileName=None, dssFilePath=None):
     """
     A tool is defined by providing a `yaml` configuration file 
     ``configFileName`` and a HEC-DSS database ``dssFilePath`` to operate on.
     If ``dssFilePath`` is not set, the active DSS-file in the HEC-DSSVue
     window will be used. If ``configFileName`` is not set, a file selection
     dialogue is displayed prompting for a configuration file.
     
     The attribute :attr:`.config` will be set containing the parsed yaml 
     config file.
     """
     
     if dssFilePath:
         self.dssFilePath = dssFilePath
         self.mainWindow = None
     else:
         from hec.dssgui import ListSelection
         self.mainWindow = ListSelection.getMainWindow()
         self.dssFilePath = self.mainWindow.getDSSFilename()
         if not configFileName:
             from javax.swing import JFileChooser
             from javax.swing.filechooser import FileNameExtensionFilter
             fileDialogue = JFileChooser(self.dssFilePath)
             filter = FileNameExtensionFilter("Configuration file (*.yml; *.yaml)", 
                                              ["yaml", "yml"])
             fileDialogue.setFileFilter(filter)
             ret = fileDialogue.showOpenDialog(self.mainWindow)
             if ret == JFileChooser.APPROVE_OPTION:
                 self.configFilePath = (fileDialogue.getSelectedFile().
                                        getAbsolutePath())
             else:
                 raise CancelledError("Config file selection was cancelled.") 
     
     if configFileName:
         self.configFilePath = path.join(path.dirname(self.dssFilePath), 
                                         configFileName)
     elif dssFilePath:
         raise ValueError("`configFileName` argument must be provided if `dssFilePath` is specified.")
     
     #: Message to be displayed in HEC-DSSVue after running the tool. This 
     #: attribute is typically set in the :meth:`main`.
     self.message = ""
     
     if self._toolIsValid():
         with codecs.open(self.configFilePath, encoding='utf-8') as configFile:
             self.config = yaml.load(configFile.read())
         self._configIsValid()
开发者ID:jprine,项目名称:monitoring-module,代码行数:49,代码来源:__init__.py

示例14: generate_board

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
    def generate_board(self, event):

        chooser = JFileChooser()
        status = chooser.showOpenDialog(self.frame)
        if status != JFileChooser.APPROVE_OPTION:
            return

        imageFile = chooser.getSelectedFile()

        self.puzzle = SimplePyzzle(float(int(self.combo_box.getSelectedItem())))
        self.draw_board()
        self.load_images(imageFile, self.puzzle.level())
        self.canvas.set_puzzle(self.puzzle)
        width = self.images_dict[0].getWidth()
        height = self.images_dict[0].getHeight()
        size = Dimension(width * self.puzzle.level(), height * self.puzzle.level())
        self.frame.setPreferredSize(size)
        self.frame.setSize(size)
开发者ID:pythonoob,项目名称:SimplePyzzle,代码行数:20,代码来源:Gui.py

示例15: saveas

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import showOpenDialog [as 别名]
    def saveas(self, e):
        c = None
        if "lastdir" in self.settings.keys():
            c = JFileChooser(self.settings["lastdir"])
        else:
            c = JFileChooser()

        r = c.showOpenDialog(self.frame)

        if r == JFileChooser.APPROVE_OPTION:
            f = c.getSelectedFile()
            self.f = f
            s = f.getAbsolutePath()

            self.settings["lastdir"] = f.getParent()
            self.settings.save()

            o = FileOutputStream(s)
            self.text.setoutput(o)
开发者ID:silvioangels,项目名称:cb2java-1,代码行数:21,代码来源:window.py


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