From: Daniel L. <dan...@ma...> - 2005-12-24 18:23:13
|
> Message: 1 > Date: Fri, 23 Dec 2005 13:38:34 +0100 > From: Mathias Tirtasana <mat...@un...> > To: JYTHON <jyt...@li...> > Subject: [Jython-users] JFileChooser > > Is it possible to wait for the result of a JFileChooser? > Mathias Here is a snippet I use in an application I wrote: def chooseAction(self, event): chooser = JFileChooser() chooser.setCurrentDirectory(io.File(os.getcwd())) returnVal = chooser.showDialog(None, "Select configuration file") if (returnVal == JFileChooser.APPROVE_OPTION): selection = chooser.getSelectedFile() selectedPath = selection.getAbsolutePath() # parse file into components (selectedDir, selectedFile) = os.path.split(selectedPath) (selectedRoot, selectedExt) = os.path.splitext(selectedFile) #print "Path = ", selectedPath, ", File = ", selectedFile, " Dir = ", selectedDir, ", Root = ", selectedRoot, " Ext = ", selectedExt Daniel Lord |