Extended EricDirFileDialog and EricFileDialog to offer a pathlib.Path based interface. eric7

Sun, 17 Jul 2022 12:21:39 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 17 Jul 2022 12:21:39 +0200
branch
eric7
changeset 9239
3c605ab5a8c7
parent 9238
a7cbf3d61498
child 9240
183220dc5492

Extended EricDirFileDialog and EricFileDialog to offer a pathlib.Path based interface.

src/eric7/APIs/Python3/eric7.api file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.EricWidgets.EricDirFileDialog.html file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.EricWidgets.EricFileDialog.html file | annotate | diff | comparison | revisions
src/eric7/EricWidgets/EricDirFileDialog.py file | annotate | diff | comparison | revisions
src/eric7/EricWidgets/EricFileDialog.py file | annotate | diff | comparison | revisions
--- a/src/eric7/APIs/Python3/eric7.api	Sat Jul 16 18:14:30 2022 +0200
+++ b/src/eric7/APIs/Python3/eric7.api	Sun Jul 17 12:21:39 2022 +0200
@@ -1247,6 +1247,7 @@
 eric7.EricWidgets.EricDirFileDialog.EricDirFileDialog.accept?4()
 eric7.EricWidgets.EricDirFileDialog.EricDirFileDialog.exec?4()
 eric7.EricWidgets.EricDirFileDialog.EricDirFileDialog.getOpenFileAndDirNames?4(caption="", directory="", filterStr="", options=None)
+eric7.EricWidgets.EricDirFileDialog.EricDirFileDialog.getOpenFileAndDirPaths?4(caption="", directory="", filterStr="", options=None)
 eric7.EricWidgets.EricDirFileDialog.EricDirFileDialog.on_directoryEntered?4(directory)
 eric7.EricWidgets.EricDirFileDialog.EricDirFileDialog.on_selectionChanged?4(selected, deselected)
 eric7.EricWidgets.EricDirFileDialog.EricDirFileDialog?1(parent=None, caption="", directory="", filterStr="")
@@ -1273,13 +1274,21 @@
 eric7.EricWidgets.EricFileDialog.ReadOnly?7
 eric7.EricWidgets.EricFileDialog.ShowDirsOnly?7
 eric7.EricWidgets.EricFileDialog.getExistingDirectory?4(parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly)
+eric7.EricWidgets.EricFileDialog.getExistingDirectoryPath?4(parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly)
+eric7.EricWidgets.EricFileDialog.getOpenFilPathsAndFilter?4(parent=None, caption="", directory="", filterStr="", initialFilter="", options=None)
 eric7.EricWidgets.EricFileDialog.getOpenFileAndDirNames?4(parent=None, caption="", directory="", filterStr="", options=None)
+eric7.EricWidgets.EricFileDialog.getOpenFileAndDirPaths?4(parent=None, caption="", directory="", filterStr="", options=None)
 eric7.EricWidgets.EricFileDialog.getOpenFileName?4(parent=None, caption="", directory="", filterStr="", options=None)
 eric7.EricWidgets.EricFileDialog.getOpenFileNameAndFilter?4(parent=None, caption="", directory="", filterStr="", initialFilter="", options=None)
 eric7.EricWidgets.EricFileDialog.getOpenFileNames?4(parent=None, caption="", directory="", filterStr="", options=None)
 eric7.EricWidgets.EricFileDialog.getOpenFileNamesAndFilter?4(parent=None, caption="", directory="", filterStr="", initialFilter="", options=None)
+eric7.EricWidgets.EricFileDialog.getOpenFilePath?4(parent=None, caption="", directory="", filterStr="", options=None)
+eric7.EricWidgets.EricFileDialog.getOpenFilePathAndFilter?4(parent=None, caption="", directory="", filterStr="", initialFilter="", options=None)
+eric7.EricWidgets.EricFileDialog.getOpenFilePaths?4(parent=None, caption="", directory="", filterStr="", options=None)
 eric7.EricWidgets.EricFileDialog.getSaveFileName?4(parent=None, caption="", directory="", filterStr="", options=None)
 eric7.EricWidgets.EricFileDialog.getSaveFileNameAndFilter?4(parent=None, caption="", directory="", filterStr="", initialFilter="", options=None)
+eric7.EricWidgets.EricFileDialog.getSaveFilePath?4(parent=None, caption="", directory="", filterStr="", options=None)
+eric7.EricWidgets.EricFileDialog.getSaveFilePathAndFilter?4(parent=None, caption="", directory="", filterStr="", initialFilter="", options=None)
 eric7.EricWidgets.EricFileSaveConfirmDialog.EricFileSaveConfirmDialog.selectedAction?4()
 eric7.EricWidgets.EricFileSaveConfirmDialog.EricFileSaveConfirmDialog?1(filename, title, message="", picker=True, parent=None)
 eric7.EricWidgets.EricFileSaveConfirmDialog.confirmOverwrite?4(filename, title, message="", picker=True, parent=None)
Binary file src/eric7/Documentation/Help/source.qch has changed
--- a/src/eric7/Documentation/Help/source.qhp	Sat Jul 16 18:14:30 2022 +0200
+++ b/src/eric7/Documentation/Help/source.qhp	Sun Jul 17 12:21:39 2022 +0200
@@ -4945,6 +4945,7 @@
       <keyword name="EricDirFileDialog.accept" id="EricDirFileDialog.accept" ref="eric7.EricWidgets.EricDirFileDialog.html#EricDirFileDialog.accept" />
       <keyword name="EricDirFileDialog.exec" id="EricDirFileDialog.exec" ref="eric7.EricWidgets.EricDirFileDialog.html#EricDirFileDialog.exec" />
       <keyword name="EricDirFileDialog.getOpenFileAndDirNames" id="EricDirFileDialog.getOpenFileAndDirNames" ref="eric7.EricWidgets.EricDirFileDialog.html#EricDirFileDialog.getOpenFileAndDirNames" />
+      <keyword name="EricDirFileDialog.getOpenFileAndDirPaths" id="EricDirFileDialog.getOpenFileAndDirPaths" ref="eric7.EricWidgets.EricDirFileDialog.html#EricDirFileDialog.getOpenFileAndDirPaths" />
       <keyword name="EricDirFileDialog.on_directoryEntered" id="EricDirFileDialog.on_directoryEntered" ref="eric7.EricWidgets.EricDirFileDialog.html#EricDirFileDialog.on_directoryEntered" />
       <keyword name="EricDirFileDialog.on_selectionChanged" id="EricDirFileDialog.on_selectionChanged" ref="eric7.EricWidgets.EricDirFileDialog.html#EricDirFileDialog.on_selectionChanged" />
       <keyword name="EricDnDTabBar" id="EricDnDTabBar" ref="eric7.EricWidgets.EricTabWidget.html#EricDnDTabBar" />
@@ -18721,6 +18722,7 @@
       <keyword name="getExecutablePath" id="getExecutablePath" ref="eric7.Utilities.__init__.html#getExecutablePath" />
       <keyword name="getExecutablePaths" id="getExecutablePaths" ref="eric7.Utilities.__init__.html#getExecutablePaths" />
       <keyword name="getExistingDirectory" id="getExistingDirectory" ref="eric7.EricWidgets.EricFileDialog.html#getExistingDirectory" />
+      <keyword name="getExistingDirectoryPath" id="getExistingDirectoryPath" ref="eric7.EricWidgets.EricFileDialog.html#getExistingDirectoryPath" />
       <keyword name="getExporter" id="getExporter" ref="eric7.QScintilla.Exporters.__init__.html#getExporter" />
       <keyword name="getFeedLinks" id="getFeedLinks" ref="eric7.WebBrowser.Tools.Scripts.html#getFeedLinks" />
       <keyword name="getFileNameFromUrl" id="getFileNameFromUrl" ref="eric7.WebBrowser.Tools.WebBrowserTools.html#getFileNameFromUrl" />
@@ -18762,12 +18764,17 @@
       <keyword name="getMicroPython" id="getMicroPython" ref="eric7.Preferences.__init__.html#getMicroPython" />
       <keyword name="getModuleQualnameFromPath" id="getModuleQualnameFromPath" ref="eric7.Plugins.CheckerPlugins.CodeStyleChecker.Security.SecurityUtils.html#getModuleQualnameFromPath" />
       <keyword name="getMultiProject" id="getMultiProject" ref="eric7.Preferences.__init__.html#getMultiProject" />
+      <keyword name="getOpenFilPathsAndFilter" id="getOpenFilPathsAndFilter" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFilPathsAndFilter" />
       <keyword name="getOpenFileAndDirNames" id="getOpenFileAndDirNames" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFileAndDirNames" />
+      <keyword name="getOpenFileAndDirPaths" id="getOpenFileAndDirPaths" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFileAndDirPaths" />
       <keyword name="getOpenFileFiltersList" id="getOpenFileFiltersList" ref="eric7.QScintilla.Lexers.__init__.html#getOpenFileFiltersList" />
       <keyword name="getOpenFileName" id="getOpenFileName" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFileName" />
       <keyword name="getOpenFileNameAndFilter" id="getOpenFileNameAndFilter" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFileNameAndFilter" />
       <keyword name="getOpenFileNames" id="getOpenFileNames" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFileNames" />
       <keyword name="getOpenFileNamesAndFilter" id="getOpenFileNamesAndFilter" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFileNamesAndFilter" />
+      <keyword name="getOpenFilePath" id="getOpenFilePath" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFilePath" />
+      <keyword name="getOpenFilePathAndFilter" id="getOpenFilePathAndFilter" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFilePathAndFilter" />
+      <keyword name="getOpenFilePaths" id="getOpenFilePaths" ref="eric7.EricWidgets.EricFileDialog.html#getOpenFilePaths" />
       <keyword name="getOpenSearchLinks" id="getOpenSearchLinks" ref="eric7.WebBrowser.Tools.Scripts.html#getOpenSearchLinks" />
       <keyword name="getPath" id="getPath" ref="eric7.EricWidgets.EricPathPickerDialog.html#getPath" />
       <keyword name="getPercentReplacement" id="getPercentReplacement" ref="eric7.Utilities.__init__.html#getPercentReplacement" />
@@ -18802,6 +18809,8 @@
       <keyword name="getSaveFileFiltersList" id="getSaveFileFiltersList" ref="eric7.QScintilla.Lexers.__init__.html#getSaveFileFiltersList" />
       <keyword name="getSaveFileName" id="getSaveFileName" ref="eric7.EricWidgets.EricFileDialog.html#getSaveFileName" />
       <keyword name="getSaveFileNameAndFilter" id="getSaveFileNameAndFilter" ref="eric7.EricWidgets.EricFileDialog.html#getSaveFileNameAndFilter" />
+      <keyword name="getSaveFilePath" id="getSaveFilePath" ref="eric7.EricWidgets.EricFileDialog.html#getSaveFilePath" />
+      <keyword name="getSaveFilePathAndFilter" id="getSaveFilePathAndFilter" ref="eric7.EricWidgets.EricFileDialog.html#getSaveFilePathAndFilter" />
       <keyword name="getServersPath" id="getServersPath" ref="eric7.Plugins.VcsPlugins.vcsPySvn.SvnUtilities.html#getServersPath" />
       <keyword name="getServersPath" id="getServersPath" ref="eric7.Plugins.VcsPlugins.vcsSubversion.SvnUtilities.html#getServersPath" />
       <keyword name="getSettings" id="getSettings" ref="eric7.Preferences.__init__.html#getSettings" />
--- a/src/eric7/Documentation/Source/eric7.EricWidgets.EricDirFileDialog.html	Sat Jul 16 18:14:30 2022 +0200
+++ b/src/eric7/Documentation/Source/eric7.EricWidgets.EricDirFileDialog.html	Sun Jul 17 12:21:39 2022 +0200
@@ -86,6 +86,10 @@
 <td><a href="#EricDirFileDialog.getOpenFileAndDirNames">getOpenFileAndDirNames</a></td>
 <td>Static method to get the names of files and directories for opening it.</td>
 </tr>
+<tr>
+<td><a href="#EricDirFileDialog.getOpenFileAndDirPaths">getOpenFileAndDirPaths</a></td>
+<td>Static method to get the paths of files and directories for opening it.</td>
+</tr>
 </table>
 
 <a NAME="EricDirFileDialog.__init__" ID="EricDirFileDialog.__init__"></a>
@@ -215,6 +219,48 @@
 list of str
 </dd>
 </dl>
+<a NAME="EricDirFileDialog.getOpenFileAndDirPaths" ID="EricDirFileDialog.getOpenFileAndDirPaths"></a>
+<h4>EricDirFileDialog.getOpenFileAndDirPaths (static)</h4>
+<b>getOpenFileAndDirPaths</b>(<i>caption="", directory="", filterStr="", options=None</i>)
+
+<p>
+        Static method to get the paths of files and directories for opening it.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+paths of the selected files and folders
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+list of pathlib.Path
+</dd>
+</dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 </body></html>
\ No newline at end of file
--- a/src/eric7/Documentation/Source/eric7.EricWidgets.EricFileDialog.html	Sat Jul 16 18:14:30 2022 +0200
+++ b/src/eric7/Documentation/Source/eric7.EricWidgets.EricFileDialog.html	Sun Jul 17 12:21:39 2022 +0200
@@ -34,10 +34,22 @@
 <td>Module function to get the name of a directory.</td>
 </tr>
 <tr>
+<td><a href="#getExistingDirectoryPath">getExistingDirectoryPath</a></td>
+<td>Module function to get the path of a directory.</td>
+</tr>
+<tr>
+<td><a href="#getOpenFilPathsAndFilter">getOpenFilPathsAndFilter</a></td>
+<td>Module function to get a list of paths of files for opening and the selected file name filter.</td>
+</tr>
+<tr>
 <td><a href="#getOpenFileAndDirNames">getOpenFileAndDirNames</a></td>
 <td>Module function to get the names of files and directories for opening.</td>
 </tr>
 <tr>
+<td><a href="#getOpenFileAndDirPaths">getOpenFileAndDirPaths</a></td>
+<td>Module function to get the paths of files and directories for opening.</td>
+</tr>
+<tr>
 <td><a href="#getOpenFileName">getOpenFileName</a></td>
 <td>Module function to get the name of a file for opening it.</td>
 </tr>
@@ -54,12 +66,32 @@
 <td>Module function to get a list of names of files for opening and the selected file name filter.</td>
 </tr>
 <tr>
+<td><a href="#getOpenFilePath">getOpenFilePath</a></td>
+<td>Module function to get the path of a file for opening it.</td>
+</tr>
+<tr>
+<td><a href="#getOpenFilePathAndFilter">getOpenFilePathAndFilter</a></td>
+<td>Module function to get the path of a file for opening it and the selected file name filter.</td>
+</tr>
+<tr>
+<td><a href="#getOpenFilePaths">getOpenFilePaths</a></td>
+<td>Module function to get a list of paths of files for opening.</td>
+</tr>
+<tr>
 <td><a href="#getSaveFileName">getSaveFileName</a></td>
-<td>Module function to get the name of a file for saving it.</td>
+<td>Module function to get the name of a file for saving.</td>
 </tr>
 <tr>
 <td><a href="#getSaveFileNameAndFilter">getSaveFileNameAndFilter</a></td>
-<td>Module function to get the name of a file for saving it and the selected file name filter.</td>
+<td>Module function to get the name of a file for saving and the selected file name filter.</td>
+</tr>
+<tr>
+<td><a href="#getSaveFilePath">getSaveFilePath</a></td>
+<td>Module function to get the path of a file for saving.</td>
+</tr>
+<tr>
+<td><a href="#getSaveFilePathAndFilter">getSaveFilePathAndFilter</a></td>
+<td>Module function to get the path of a file for saving and the selected file name filter.</td>
 </tr>
 </table>
 <hr />
@@ -139,6 +171,97 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
+<a NAME="getExistingDirectoryPath" ID="getExistingDirectoryPath"></a>
+<h2>getExistingDirectoryPath</h2>
+<b>getExistingDirectoryPath</b>(<i>parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly</i>)
+
+<p>
+    Module function to get the path of a directory.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+path of selected directory
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+pathlib.Path
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
+<a NAME="getOpenFilPathsAndFilter" ID="getOpenFilPathsAndFilter"></a>
+<h2>getOpenFilPathsAndFilter</h2>
+<b>getOpenFilPathsAndFilter</b>(<i>parent=None, caption="", directory="", filterStr="", initialFilter="", options=None</i>)
+
+<p>
+    Module function to get a list of paths of files for opening and the
+    selected file name filter.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>initialFilter</i> (str)</dt>
+<dd>
+initial filter for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+list of file paths to be opened and selected filter
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+tuple of (list of pathlib.Path, str)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
 <a NAME="getOpenFileAndDirNames" ID="getOpenFileAndDirNames"></a>
 <h2>getOpenFileAndDirNames</h2>
 <b>getOpenFileAndDirNames</b>(<i>parent=None, caption="", directory="", filterStr="", options=None</i>)
@@ -184,6 +307,51 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
+<a NAME="getOpenFileAndDirPaths" ID="getOpenFileAndDirPaths"></a>
+<h2>getOpenFileAndDirPaths</h2>
+<b>getOpenFileAndDirPaths</b>(<i>parent=None, caption="", directory="", filterStr="", options=None</i>)
+
+<p>
+    Module function to get the paths of files and directories for opening.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+paths of the selected files and folders
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+list of pathlib.Path
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
 <a NAME="getOpenFileName" ID="getOpenFileName"></a>
 <h2>getOpenFileName</h2>
 <b>getOpenFileName</b>(<i>parent=None, caption="", directory="", filterStr="", options=None</i>)
@@ -374,12 +542,152 @@
 <div align="right"><a href="#top">Up</a></div>
 <hr />
 <hr />
+<a NAME="getOpenFilePath" ID="getOpenFilePath"></a>
+<h2>getOpenFilePath</h2>
+<b>getOpenFilePath</b>(<i>parent=None, caption="", directory="", filterStr="", options=None</i>)
+
+<p>
+    Module function to get the path of a file for opening it.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+path of file to be opened
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+pathlib.Path
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
+<a NAME="getOpenFilePathAndFilter" ID="getOpenFilePathAndFilter"></a>
+<h2>getOpenFilePathAndFilter</h2>
+<b>getOpenFilePathAndFilter</b>(<i>parent=None, caption="", directory="", filterStr="", initialFilter="", options=None</i>)
+
+<p>
+    Module function to get the path of a file for opening it and the selected
+    file name filter.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>initialFilter</i> (str)</dt>
+<dd>
+initial filter for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+path of file to be opened and selected filter
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+tuple of (pathlib.Path, str)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
+<a NAME="getOpenFilePaths" ID="getOpenFilePaths"></a>
+<h2>getOpenFilePaths</h2>
+<b>getOpenFilePaths</b>(<i>parent=None, caption="", directory="", filterStr="", options=None</i>)
+
+<p>
+    Module function to get a list of paths of files for opening.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+list of file paths to be opened
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+list of pathlib.Path
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
 <a NAME="getSaveFileName" ID="getSaveFileName"></a>
 <h2>getSaveFileName</h2>
 <b>getSaveFileName</b>(<i>parent=None, caption="", directory="", filterStr="", options=None</i>)
 
 <p>
-    Module function to get the name of a file for saving it.
+    Module function to get the name of a file for saving.
 </p>
 <dl>
 
@@ -424,8 +732,8 @@
 <b>getSaveFileNameAndFilter</b>(<i>parent=None, caption="", directory="", filterStr="", initialFilter="", options=None</i>)
 
 <p>
-    Module function to get the name of a file for saving it and the selected
-    file name filter.
+    Module function to get the name of a file for saving and the selected file name
+    filter.
 </p>
 <dl>
 
@@ -468,4 +776,99 @@
 </dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
+<hr />
+<a NAME="getSaveFilePath" ID="getSaveFilePath"></a>
+<h2>getSaveFilePath</h2>
+<b>getSaveFilePath</b>(<i>parent=None, caption="", directory="", filterStr="", options=None</i>)
+
+<p>
+    Module function to get the path of a file for saving.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+path of file to be saved
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+pathlib.Path
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+<hr />
+<a NAME="getSaveFilePathAndFilter" ID="getSaveFilePathAndFilter"></a>
+<h2>getSaveFilePathAndFilter</h2>
+<b>getSaveFilePathAndFilter</b>(<i>parent=None, caption="", directory="", filterStr="", initialFilter="", options=None</i>)
+
+<p>
+    Module function to get the path of a file for saving and the selected
+    file name filter.
+</p>
+<dl>
+
+<dt><i>parent</i> (QWidget)</dt>
+<dd>
+parent widget of the dialog
+</dd>
+<dt><i>caption</i> (str)</dt>
+<dd>
+window title of the dialog
+</dd>
+<dt><i>directory</i> (str or pathlib.Path)</dt>
+<dd>
+working directory of the dialog
+</dd>
+<dt><i>filterStr</i> (str)</dt>
+<dd>
+filter string for the dialog
+</dd>
+<dt><i>initialFilter</i> (str)</dt>
+<dd>
+initial filter for the dialog
+</dd>
+<dt><i>options</i> (QFileDialog.Options)</dt>
+<dd>
+various options for the dialog
+</dd>
+</dl>
+<dl>
+<dt>Return:</dt>
+<dd>
+path of file to be saved and selected filte
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+tuple of (pathlib.Path, str)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
 </body></html>
\ No newline at end of file
--- a/src/eric7/EricWidgets/EricDirFileDialog.py	Sat Jul 16 18:14:30 2022 +0200
+++ b/src/eric7/EricWidgets/EricDirFileDialog.py	Sun Jul 17 12:21:39 2022 +0200
@@ -7,6 +7,8 @@
 Module implementing a dialog to select files and directories simultaneously.
 """
 
+import pathlib
+
 from PyQt6.QtCore import pyqtSlot, QItemSelection
 from PyQt6.QtGui import QFileSystemModel
 from PyQt6.QtWidgets import QFileDialog, QPushButton, QLineEdit, QTreeView
@@ -143,3 +145,32 @@
         dlg.exec()
 
         return dlg.__selectedFilesFolders
+
+    @staticmethod
+    def getOpenFileAndDirPaths(
+        parent=None, caption="", directory="", filterStr="", options=None
+    ):
+        """
+        Static method to get the paths of files and directories for opening it.
+
+        @param parent parent widget of the dialog
+        @type QWidget
+        @param caption window title of the dialog
+        @type str
+        @param directory working directory of the dialog
+        @type str or pathlib.Path
+        @param filterStr filter string for the dialog
+        @type str
+        @param options various options for the dialog
+        @type QFileDialog.Options
+        @return paths of the selected files and folders
+        @rtype list of pathlib.Path
+        """
+        if options is None:
+            options = QFileDialog.Option(0)
+        options |= QFileDialog.Option.DontUseNativeDialog
+        dlg = EricDirFileDialog(parent, caption, str(directory), filterStr)
+        dlg.setOptions(options)
+        dlg.exec()
+
+        return [pathlib.Path(p) for p in dlg.__selectedFilesFolders]
--- a/src/eric7/EricWidgets/EricFileDialog.py	Sat Jul 16 18:14:30 2022 +0200
+++ b/src/eric7/EricWidgets/EricFileDialog.py	Sun Jul 17 12:21:39 2022 +0200
@@ -7,6 +7,8 @@
 Module implementing alternative functions for the QFileDialog static methods.
 """
 
+import pathlib
+
 from PyQt6.QtWidgets import QFileDialog
 
 import Globals
@@ -44,6 +46,11 @@
         return filterStr
 
 
+###########################################################################
+## String based interface
+###########################################################################
+
+
 def getOpenFileName(parent=None, caption="", directory="", filterStr="", options=None):
     """
     Module function to get the name of a file for opening it.
@@ -180,7 +187,7 @@
 
 def getSaveFileName(parent=None, caption="", directory="", filterStr="", options=None):
     """
-    Module function to get the name of a file for saving it.
+    Module function to get the name of a file for saving.
 
     @param parent parent widget of the dialog
     @type QWidget
@@ -206,8 +213,8 @@
     parent=None, caption="", directory="", filterStr="", initialFilter="", options=None
 ):
     """
-    Module function to get the name of a file for saving it and the selected
-    file name filter.
+    Module function to get the name of a file for saving and the selected file name
+    filter.
 
     @param parent parent widget of the dialog
     @type QWidget
@@ -252,3 +259,225 @@
     if options is None:
         options = QFileDialog.Option(0)
     return QFileDialog.getExistingDirectory(parent, caption, directory, options)
+
+
+###########################################################################
+## pathlib.Path based interface
+###########################################################################
+
+
+def getOpenFilePath(parent=None, caption="", directory="", filterStr="", options=None):
+    """
+    Module function to get the path of a file for opening it.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param filterStr filter string for the dialog
+    @type str
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return path of file to be opened
+    @rtype pathlib.Path
+    """
+    if options is None:
+        options = QFileDialog.Option(0)
+    filename = QFileDialog.getOpenFileName(
+        parent, caption, str(directory), filterStr, "", options
+    )[0]
+    return pathlib.Path(filename)
+
+
+def getOpenFilePathAndFilter(
+    parent=None, caption="", directory="", filterStr="", initialFilter="", options=None
+):
+    """
+    Module function to get the path of a file for opening it and the selected
+    file name filter.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param filterStr filter string for the dialog
+    @type str
+    @param initialFilter initial filter for the dialog
+    @type str
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return path of file to be opened and selected filter
+    @rtype tuple of (pathlib.Path, str)
+    """
+    if options is None:
+        options = QFileDialog.Option(0)
+    newfilter = __reorderFilter(filterStr, initialFilter)
+    filename, selectedFilter = QFileDialog.getOpenFileName(
+        parent, caption, str(directory), newfilter, initialFilter, options
+    )
+    return pathlib.Path(filename), selectedFilter
+
+
+def getOpenFilePaths(parent=None, caption="", directory="", filterStr="", options=None):
+    """
+    Module function to get a list of paths of files for opening.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param filterStr filter string for the dialog
+    @type str
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return list of file paths to be opened
+    @rtype list of pathlib.Path
+    """
+    if options is None:
+        options = QFileDialog.Option(0)
+    filenames = QFileDialog.getOpenFileNames(
+        parent, caption, str(directory), filterStr, "", options
+    )[0]
+    return [pathlib.Path(f) for f in filenames]
+
+
+def getOpenFilPathsAndFilter(
+    parent=None, caption="", directory="", filterStr="", initialFilter="", options=None
+):
+    """
+    Module function to get a list of paths of files for opening and the
+    selected file name filter.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param filterStr filter string for the dialog
+    @type str
+    @param initialFilter initial filter for the dialog
+    @type str
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return list of file paths to be opened and selected filter
+    @rtype tuple of (list of pathlib.Path, str)
+    """
+    if options is None:
+        options = QFileDialog.Option(0)
+    newfilter = __reorderFilter(filterStr, initialFilter)
+    filenames, selectedFilter = QFileDialog.getOpenFileNames(
+        parent, caption, str(directory), newfilter, initialFilter, options
+    )
+    return [pathlib.Path(f) for f in filenames], selectedFilter
+
+
+def getOpenFileAndDirPaths(
+    parent=None, caption="", directory="", filterStr="", options=None
+):
+    """
+    Module function to get the paths of files and directories for opening.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param filterStr filter string for the dialog
+    @type str
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return paths of the selected files and folders
+    @rtype list of pathlib.Path
+    """
+    from .EricDirFileDialog import EricDirFileDialog
+
+    return EricDirFileDialog.getOpenFileAndDirPaths(
+        parent, caption, directory, filterStr, options
+    )
+
+
+def getSaveFilePath(parent=None, caption="", directory="", filterStr="", options=None):
+    """
+    Module function to get the path of a file for saving.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param filterStr filter string for the dialog
+    @type str
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return path of file to be saved
+    @rtype pathlib.Path
+    """
+    if options is None:
+        options = QFileDialog.Option(0)
+    filename = QFileDialog.getSaveFileName(
+        parent, caption, str(directory), filterStr, "", options
+    )[0]
+    return pathlib.Path(filename)
+
+
+def getSaveFilePathAndFilter(
+    parent=None, caption="", directory="", filterStr="", initialFilter="", options=None
+):
+    """
+    Module function to get the path of a file for saving and the selected
+    file name filter.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param filterStr filter string for the dialog
+    @type str
+    @param initialFilter initial filter for the dialog
+    @type str
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return path of file to be saved and selected filte
+    @rtype tuple of (pathlib.Path, str)
+    """
+    if options is None:
+        options = QFileDialog.Option(0)
+    newfilter = __reorderFilter(filterStr, initialFilter)
+    filename, selectedFilter = QFileDialog.getSaveFileName(
+        parent, caption, directory, newfilter, initialFilter, options
+    )
+    return pathlib.Path(filename), selectedFilter
+
+
+def getExistingDirectoryPath(
+    parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly
+):
+    """
+    Module function to get the path of a directory.
+
+    @param parent parent widget of the dialog
+    @type QWidget
+    @param caption window title of the dialog
+    @type str
+    @param directory working directory of the dialog
+    @type str or pathlib.Path
+    @param options various options for the dialog
+    @type QFileDialog.Options
+    @return path of selected directory
+    @rtype pathlib.Path
+    """
+    if options is None:
+        options = QFileDialog.Option(0)
+    dirname = QFileDialog.getExistingDirectory(parent, caption, str(directory), options)
+    return pathlib.Path(dirname)

eric ide

mercurial