49 ########################################################################### |
49 ########################################################################### |
50 ## String based interface |
50 ## String based interface |
51 ########################################################################### |
51 ########################################################################### |
52 |
52 |
53 |
53 |
54 def getOpenFileName(parent=None, caption="", directory="", filterStr="", options=None): |
54 def getOpenFileName( |
|
55 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
|
56 ): |
55 """ |
57 """ |
56 Module function to get the name of a file for opening it. |
58 Module function to get the name of a file for opening it. |
57 |
59 |
58 @param parent parent widget of the dialog |
60 @param parent parent widget of the dialog (defaults to None) |
59 @type QWidget |
61 @type QWidget (optional) |
60 @param caption window title of the dialog |
62 @param caption window title of the dialog (defaults to "") |
61 @type str |
63 @type str (optional) |
62 @param directory working directory of the dialog |
64 @param directory working directory of the dialog (defaults to "") |
63 @type str |
65 @type str (optional) |
64 @param filterStr filter string for the dialog |
66 @param filterStr filter string for the dialog (defaults to "") |
65 @type str |
67 @type str (optional) |
66 @param options various options for the dialog |
68 @param initialFilter initial filter for the dialog (defaults to "") |
67 @type QFileDialog.Options |
69 @type str (optional) |
|
70 @param options various options for the dialog (defaults to None) |
|
71 @type QFileDialog.Options ((optional) |
68 @return name of file to be opened |
72 @return name of file to be opened |
69 @rtype str |
73 @rtype str |
70 """ |
74 """ |
71 if options is None: |
75 return getOpenFileNameAndFilter( |
72 options = QFileDialog.Option(0) |
76 parent, caption, directory, filterStr, initialFilter, options |
73 return QFileDialog.getOpenFileName( |
|
74 parent, caption, directory, filterStr, "", options |
|
75 )[0] |
77 )[0] |
76 |
78 |
77 |
79 |
78 def getOpenFileNameAndFilter( |
80 def getOpenFileNameAndFilter( |
79 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
81 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
80 ): |
82 ): |
81 """ |
83 """ |
82 Module function to get the name of a file for opening it and the selected |
84 Module function to get the name of a file for opening it and the selected |
83 file name filter. |
85 file name filter. |
84 |
86 |
85 @param parent parent widget of the dialog |
87 @param parent parent widget of the dialog (defaults to None) |
86 @type QWidget |
88 @type QWidget (optional) |
87 @param caption window title of the dialog |
89 @param caption window title of the dialog (defaults to "") |
88 @type str |
90 @type str (optional) |
89 @param directory working directory of the dialog |
91 @param directory working directory of the dialog (defaults to "") |
90 @type str |
92 @type str (optional) |
91 @param filterStr filter string for the dialog |
93 @param filterStr filter string for the dialog (defaults to "") |
92 @type str |
94 @type str (optional) |
93 @param initialFilter initial filter for the dialog |
95 @param initialFilter initial filter for the dialog (defaults to "") |
94 @type str |
96 @type str (optional) |
95 @param options various options for the dialog |
97 @param options various options for the dialog (defaults to None) |
96 @type QFileDialog.Options |
98 @type QFileDialog.Options ((optional) |
97 @return name of file to be opened and selected filter |
99 @return name of file to be opened and selected filter |
98 @rtype tuple of (str, str) |
100 @rtype tuple of (str, str) |
99 """ |
101 """ |
100 if options is None: |
102 if options is None: |
101 options = QFileDialog.Option(0) |
103 options = QFileDialog.Option(0) |
103 return QFileDialog.getOpenFileName( |
105 return QFileDialog.getOpenFileName( |
104 parent, caption, directory, newfilter, initialFilter, options |
106 parent, caption, directory, newfilter, initialFilter, options |
105 ) |
107 ) |
106 |
108 |
107 |
109 |
108 def getOpenFileNames(parent=None, caption="", directory="", filterStr="", options=None): |
110 def getOpenFileNames( |
|
111 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
|
112 ): |
109 """ |
113 """ |
110 Module function to get a list of names of files for opening. |
114 Module function to get a list of names of files for opening. |
111 |
115 |
112 @param parent parent widget of the dialog |
116 @param parent parent widget of the dialog (defaults to None) |
113 @type QWidget |
117 @type QWidget (optional) |
114 @param caption window title of the dialog |
118 @param caption window title of the dialog (defaults to "") |
115 @type str |
119 @type str (optional) |
116 @param directory working directory of the dialog |
120 @param directory working directory of the dialog (defaults to "") |
117 @type str |
121 @type str (optional) |
118 @param filterStr filter string for the dialog |
122 @param filterStr filter string for the dialog (defaults to "") |
119 @type str |
123 @type str (optional) |
120 @param options various options for the dialog |
124 @param initialFilter initial filter for the dialog (defaults to "") |
121 @type QFileDialog.Options |
125 @type str (optional) |
|
126 @param options various options for the dialog (defaults to None) |
|
127 @type QFileDialog.Options ((optional) |
122 @return list of file names to be opened |
128 @return list of file names to be opened |
123 @rtype list of str |
129 @rtype list of str |
124 """ |
130 """ |
125 if options is None: |
131 return getOpenFileNamesAndFilter( |
126 options = QFileDialog.Option(0) |
132 parent, caption, directory, filterStr, initialFilter, options |
127 return QFileDialog.getOpenFileNames( |
|
128 parent, caption, directory, filterStr, "", options |
|
129 )[0] |
133 )[0] |
130 |
134 |
131 |
135 |
132 def getOpenFileNamesAndFilter( |
136 def getOpenFileNamesAndFilter( |
133 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
137 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
134 ): |
138 ): |
135 """ |
139 """ |
136 Module function to get a list of names of files for opening and the |
140 Module function to get a list of names of files for opening and the |
137 selected file name filter. |
141 selected file name filter. |
138 |
142 |
139 @param parent parent widget of the dialog |
143 @param parent parent widget of the dialog (defaults to None) |
140 @type QWidget |
144 @type QWidget (optional) |
141 @param caption window title of the dialog |
145 @param caption window title of the dialog (defaults to "") |
142 @type str |
146 @type str (optional) |
143 @param directory working directory of the dialog |
147 @param directory working directory of the dialog (defaults to "") |
144 @type str |
148 @type str (optional) |
145 @param filterStr filter string for the dialog |
149 @param filterStr filter string for the dialog (defaults to "") |
146 @type str |
150 @type str (optional) |
147 @param initialFilter initial filter for the dialog |
151 @param initialFilter initial filter for the dialog (defaults to "") |
148 @type str |
152 @type str (optional) |
149 @param options various options for the dialog |
153 @param options various options for the dialog (defaults to None) |
150 @type QFileDialog.Options |
154 @type QFileDialog.Options ((optional) |
151 @return list of file names to be opened and selected filter |
155 @return list of file names to be opened and selected filter |
152 @rtype tuple of (list of str, str) |
156 @rtype tuple of (list of str, str) |
153 """ |
157 """ |
154 if options is None: |
158 if options is None: |
155 options = QFileDialog.Option(0) |
159 options = QFileDialog.Option(0) |
163 parent=None, caption="", directory="", filterStr="", options=None |
167 parent=None, caption="", directory="", filterStr="", options=None |
164 ): |
168 ): |
165 """ |
169 """ |
166 Module function to get the names of files and directories for opening. |
170 Module function to get the names of files and directories for opening. |
167 |
171 |
168 @param parent parent widget of the dialog |
172 @param parent parent widget of the dialog (defaults to None) |
169 @type QWidget |
173 @type QWidget (optional) |
170 @param caption window title of the dialog |
174 @param caption window title of the dialog (defaults to "") |
171 @type str |
175 @type str (optional) |
172 @param directory working directory of the dialog |
176 @param directory working directory of the dialog (defaults to "") |
173 @type str |
177 @type str (optional) |
174 @param filterStr filter string for the dialog |
178 @param filterStr filter string for the dialog (defaults to "") |
175 @type str |
179 @type str (optional) |
176 @param options various options for the dialog |
180 @param options various options for the dialog (defaults to None) |
177 @type QFileDialog.Options |
181 @type QFileDialog.Options ((optional) |
178 @return names of the selected files and folders |
182 @return names of the selected files and folders |
179 @rtype list of str |
183 @rtype list of str |
180 """ |
184 """ |
181 from .EricDirFileDialog import EricDirFileDialog |
185 from .EricDirFileDialog import EricDirFileDialog |
182 |
186 |
183 return EricDirFileDialog.getOpenFileAndDirNames( |
187 return EricDirFileDialog.getOpenFileAndDirNames( |
184 parent, caption, directory, filterStr, options |
188 parent, caption, directory, filterStr, options |
185 ) |
189 ) |
186 |
190 |
187 |
191 |
188 def getSaveFileName(parent=None, caption="", directory="", filterStr="", options=None): |
192 def getSaveFileName( |
|
193 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
|
194 ): |
189 """ |
195 """ |
190 Module function to get the name of a file for saving. |
196 Module function to get the name of a file for saving. |
191 |
197 |
192 @param parent parent widget of the dialog |
198 @param parent parent widget of the dialog (defaults to None) |
193 @type QWidget |
199 @type QWidget (optional) |
194 @param caption window title of the dialog |
200 @param caption window title of the dialog (defaults to "") |
195 @type str |
201 @type str (optional) |
196 @param directory working directory of the dialog |
202 @param directory working directory of the dialog (defaults to "") |
197 @type str |
203 @type str (optional) |
198 @param filterStr filter string for the dialog |
204 @param filterStr filter string for the dialog (defaults to "") |
199 @type str |
205 @type str (optional) |
200 @param options various options for the dialog |
206 @param initialFilter initial filter for the dialog (defaults to "") |
201 @type QFileDialog.Options |
207 @type str (optional) |
|
208 @param options various options for the dialog (defaults to None) |
|
209 @type QFileDialog.Options ((optional) |
202 @return name of file to be saved |
210 @return name of file to be saved |
203 @rtype str |
211 @rtype str |
204 """ |
212 """ |
205 if options is None: |
213 return getSaveFileNameAndFilter( |
206 options = QFileDialog.Option(0) |
214 parent, caption, directory, filterStr, initialFilter, options |
207 return QFileDialog.getSaveFileName( |
|
208 parent, caption, directory, filterStr, "", options |
|
209 )[0] |
215 )[0] |
210 |
216 |
211 |
217 |
212 def getSaveFileNameAndFilter( |
218 def getSaveFileNameAndFilter( |
213 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
219 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
214 ): |
220 ): |
215 """ |
221 """ |
216 Module function to get the name of a file for saving and the selected file name |
222 Module function to get the name of a file for saving and the selected file name |
217 filter. |
223 filter. |
218 |
224 |
219 @param parent parent widget of the dialog |
225 @param parent parent widget of the dialog (defaults to None) |
220 @type QWidget |
226 @type QWidget (optional) |
221 @param caption window title of the dialog |
227 @param caption window title of the dialog (defaults to "") |
222 @type str |
228 @type str (optional) |
223 @param directory working directory of the dialog |
229 @param directory working directory of the dialog (defaults to "") |
224 @type str |
230 @type str (optional) |
225 @param filterStr filter string for the dialog |
231 @param filterStr filter string for the dialog (defaults to "") |
226 @type str |
232 @type str (optional) |
227 @param initialFilter initial filter for the dialog |
233 @param initialFilter initial filter for the dialog (defaults to "") |
228 @type str |
234 @type str (optional) |
229 @param options various options for the dialog |
235 @param options various options for the dialog (defaults to None) |
230 @type QFileDialog.Options |
236 @type QFileDialog.Options ((optional) |
231 @return name of file to be saved and selected filte |
237 @return name of file to be saved and selected filte |
232 @rtype tuple of (str, str) |
238 @rtype tuple of (str, str) |
233 """ |
239 """ |
234 if options is None: |
240 if options is None: |
235 options = QFileDialog.Option(0) |
241 options = QFileDialog.Option(0) |
243 parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly |
249 parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly |
244 ): |
250 ): |
245 """ |
251 """ |
246 Module function to get the name of a directory. |
252 Module function to get the name of a directory. |
247 |
253 |
248 @param parent parent widget of the dialog |
254 @param parent parent widget of the dialog (defaults to None) |
249 @type QWidget |
255 @type QWidget (optional) |
250 @param caption window title of the dialog |
256 @param caption window title of the dialog (defaults to "") |
251 @type str |
257 @type str (optional) |
252 @param directory working directory of the dialog |
258 @param directory working directory of the dialog (defaults to "") |
253 @type str |
259 @type str (optional) |
254 @param options various options for the dialog |
260 @param options various options for the dialog (defaults to |
255 @type QFileDialog.Options |
261 QFileDialog.Option.ShowDirsOnly) |
|
262 @type QFileDialog.Options ((optional) |
256 @return name of selected directory |
263 @return name of selected directory |
257 @rtype str |
264 @rtype str |
258 """ |
265 """ |
259 if options is None: |
266 if options is None: |
260 options = QFileDialog.Option(0) |
267 options = QFileDialog.Option(0) |
264 ########################################################################### |
271 ########################################################################### |
265 ## pathlib.Path based interface |
272 ## pathlib.Path based interface |
266 ########################################################################### |
273 ########################################################################### |
267 |
274 |
268 |
275 |
269 def getOpenFilePath(parent=None, caption="", directory="", filterStr="", options=None): |
276 def getOpenFilePath( |
|
277 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
|
278 ): |
270 """ |
279 """ |
271 Module function to get the path of a file for opening it. |
280 Module function to get the path of a file for opening it. |
272 |
281 |
273 @param parent parent widget of the dialog |
282 @param parent parent widget of the dialog (defaults to None) |
274 @type QWidget |
283 @type QWidget (optional) |
275 @param caption window title of the dialog |
284 @param caption window title of the dialog (defaults to "") |
276 @type str |
285 @type str (optional) |
277 @param directory working directory of the dialog |
286 @param directory working directory of the dialog (defaults to "") |
278 @type str or pathlib.Path |
287 @type str or pathlib.Path (optional) |
279 @param filterStr filter string for the dialog |
288 @param filterStr filter string for the dialog (defaults to "") |
280 @type str |
289 @type str (optional) |
281 @param options various options for the dialog |
290 @param initialFilter initial filter for the dialog (defaults to "") |
282 @type QFileDialog.Options |
291 @type str (optional) |
|
292 @param options various options for the dialog (defaults to None) |
|
293 @type QFileDialog.Options ((optional) |
283 @return path of file to be opened |
294 @return path of file to be opened |
284 @rtype pathlib.Path |
295 @rtype pathlib.Path |
285 """ |
296 """ |
286 if options is None: |
297 return getOpenFilePathAndFilter( |
287 options = QFileDialog.Option(0) |
298 parent, caption, directory, filterStr, initialFilter, options |
288 filename = QFileDialog.getOpenFileName( |
299 )[0] |
289 parent, caption, str(directory), filterStr, "", options |
|
290 )[0] |
|
291 return pathlib.Path(filename) |
|
292 |
300 |
293 |
301 |
294 def getOpenFilePathAndFilter( |
302 def getOpenFilePathAndFilter( |
295 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
303 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
296 ): |
304 ): |
297 """ |
305 """ |
298 Module function to get the path of a file for opening it and the selected |
306 Module function to get the path of a file for opening it and the selected |
299 file name filter. |
307 file name filter. |
300 |
308 |
301 @param parent parent widget of the dialog |
309 @param parent parent widget of the dialog (defaults to None) |
302 @type QWidget |
310 @type QWidget (optional) |
303 @param caption window title of the dialog |
311 @param caption window title of the dialog (defaults to "") |
304 @type str |
312 @type str (optional) |
305 @param directory working directory of the dialog |
313 @param directory working directory of the dialog (defaults to "") |
306 @type str or pathlib.Path |
314 @type str or pathlib.Path (optional) |
307 @param filterStr filter string for the dialog |
315 @param filterStr filter string for the dialog (defaults to "") |
308 @type str |
316 @type str (optional) |
309 @param initialFilter initial filter for the dialog |
317 @param initialFilter initial filter for the dialog (defaults to "") |
310 @type str |
318 @type str (optional) |
311 @param options various options for the dialog |
319 @param options various options for the dialog (defaults to None) |
312 @type QFileDialog.Options |
320 @type QFileDialog.Options ((optional) |
313 @return path of file to be opened and selected filter |
321 @return path of file to be opened and selected filter |
314 @rtype tuple of (pathlib.Path, str) |
322 @rtype tuple of (pathlib.Path, str) |
315 """ |
323 """ |
316 if options is None: |
324 if options is None: |
317 options = QFileDialog.Option(0) |
325 options = QFileDialog.Option(0) |
320 parent, caption, str(directory), newfilter, initialFilter, options |
328 parent, caption, str(directory), newfilter, initialFilter, options |
321 ) |
329 ) |
322 return pathlib.Path(filename), selectedFilter |
330 return pathlib.Path(filename), selectedFilter |
323 |
331 |
324 |
332 |
325 def getOpenFilePaths(parent=None, caption="", directory="", filterStr="", options=None): |
333 def getOpenFilePaths( |
|
334 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
|
335 ): |
326 """ |
336 """ |
327 Module function to get a list of paths of files for opening. |
337 Module function to get a list of paths of files for opening. |
328 |
338 |
329 @param parent parent widget of the dialog |
339 @param parent parent widget of the dialog (defaults to None) |
330 @type QWidget |
340 @type QWidget (optional) |
331 @param caption window title of the dialog |
341 @param caption window title of the dialog (defaults to "") |
332 @type str |
342 @type str (optional) |
333 @param directory working directory of the dialog |
343 @param directory working directory of the dialog (defaults to "") |
334 @type str or pathlib.Path |
344 @type str or pathlib.Path (optional) |
335 @param filterStr filter string for the dialog |
345 @param filterStr filter string for the dialog (defaults to "") |
336 @type str |
346 @type str (optional) |
337 @param options various options for the dialog |
347 @param initialFilter initial filter for the dialog (defaults to "") |
338 @type QFileDialog.Options |
348 @type str (optional) |
|
349 @param options various options for the dialog (defaults to None) |
|
350 @type QFileDialog.Options ((optional) |
339 @return list of file paths to be opened |
351 @return list of file paths to be opened |
340 @rtype list of pathlib.Path |
352 @rtype list of pathlib.Path |
341 """ |
353 """ |
342 if options is None: |
354 return getOpenFilPathsAndFilter( |
343 options = QFileDialog.Option(0) |
355 parent, caption, directory, filterStr, initialFilter, options |
344 filenames = QFileDialog.getOpenFileNames( |
356 )[0] |
345 parent, caption, str(directory), filterStr, "", options |
|
346 )[0] |
|
347 return [pathlib.Path(f) for f in filenames] |
|
348 |
357 |
349 |
358 |
350 def getOpenFilPathsAndFilter( |
359 def getOpenFilPathsAndFilter( |
351 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
360 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
352 ): |
361 ): |
353 """ |
362 """ |
354 Module function to get a list of paths of files for opening and the |
363 Module function to get a list of paths of files for opening and the |
355 selected file name filter. |
364 selected file name filter. |
356 |
365 |
357 @param parent parent widget of the dialog |
366 @param parent parent widget of the dialog (defaults to None) |
358 @type QWidget |
367 @type QWidget (optional) |
359 @param caption window title of the dialog |
368 @param caption window title of the dialog (defaults to "") |
360 @type str |
369 @type str (optional) |
361 @param directory working directory of the dialog |
370 @param directory working directory of the dialog (defaults to "") |
362 @type str or pathlib.Path |
371 @type str or pathlib.Path (optional) |
363 @param filterStr filter string for the dialog |
372 @param filterStr filter string for the dialog (defaults to "") |
364 @type str |
373 @type str (optional) |
365 @param initialFilter initial filter for the dialog |
374 @param initialFilter initial filter for the dialog (defaults to "") |
366 @type str |
375 @type str (optional) |
367 @param options various options for the dialog |
376 @param options various options for the dialog (defaults to None) |
368 @type QFileDialog.Options |
377 @type QFileDialog.Options ((optional) |
369 @return list of file paths to be opened and selected filter |
378 @return list of file paths to be opened and selected filter |
370 @rtype tuple of (list of pathlib.Path, str) |
379 @rtype tuple of (list of pathlib.Path, str) |
371 """ |
380 """ |
372 if options is None: |
381 if options is None: |
373 options = QFileDialog.Option(0) |
382 options = QFileDialog.Option(0) |
382 parent=None, caption="", directory="", filterStr="", options=None |
391 parent=None, caption="", directory="", filterStr="", options=None |
383 ): |
392 ): |
384 """ |
393 """ |
385 Module function to get the paths of files and directories for opening. |
394 Module function to get the paths of files and directories for opening. |
386 |
395 |
387 @param parent parent widget of the dialog |
396 @param parent parent widget of the dialog (defaults to None) |
388 @type QWidget |
397 @type QWidget (optional) |
389 @param caption window title of the dialog |
398 @param caption window title of the dialog (defaults to "") |
390 @type str |
399 @type str (optional) |
391 @param directory working directory of the dialog |
400 @param directory working directory of the dialog (defaults to "") |
392 @type str or pathlib.Path |
401 @type str or pathlib.Path (optional) |
393 @param filterStr filter string for the dialog |
402 @param filterStr filter string for the dialog (defaults to "") |
394 @type str |
403 @type str (optional) |
395 @param options various options for the dialog |
404 @param options various options for the dialog (defaults to None) |
396 @type QFileDialog.Options |
405 @type QFileDialog.Options ((optional) |
397 @return paths of the selected files and folders |
406 @return paths of the selected files and folders |
398 @rtype list of pathlib.Path |
407 @rtype list of pathlib.Path |
399 """ |
408 """ |
400 from .EricDirFileDialog import EricDirFileDialog |
409 from .EricDirFileDialog import EricDirFileDialog |
401 |
410 |
402 return EricDirFileDialog.getOpenFileAndDirPaths( |
411 return EricDirFileDialog.getOpenFileAndDirPaths( |
403 parent, caption, directory, filterStr, options |
412 parent, caption, directory, filterStr, options |
404 ) |
413 ) |
405 |
414 |
406 |
415 |
407 def getSaveFilePath(parent=None, caption="", directory="", filterStr="", options=None): |
416 def getSaveFilePath( |
|
417 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
|
418 ): |
408 """ |
419 """ |
409 Module function to get the path of a file for saving. |
420 Module function to get the path of a file for saving. |
410 |
421 |
411 @param parent parent widget of the dialog |
422 @param parent parent widget of the dialog (defaults to None) |
412 @type QWidget |
423 @type QWidget (optional) |
413 @param caption window title of the dialog |
424 @param caption window title of the dialog (defaults to "") |
414 @type str |
425 @type str (optional) |
415 @param directory working directory of the dialog |
426 @param directory working directory of the dialog (defaults to "") |
416 @type str or pathlib.Path |
427 @type str or pathlib.Path (optional) |
417 @param filterStr filter string for the dialog |
428 @param filterStr filter string for the dialog (defaults to "") |
418 @type str |
429 @type str (optional) |
419 @param options various options for the dialog |
430 @param initialFilter initial filter for the dialog (defaults to "") |
420 @type QFileDialog.Options |
431 @type str (optional) |
|
432 @param options various options for the dialog (defaults to None) |
|
433 @type QFileDialog.Options ((optional) |
421 @return path of file to be saved |
434 @return path of file to be saved |
422 @rtype pathlib.Path |
435 @rtype pathlib.Path |
423 """ |
436 """ |
424 if options is None: |
437 return getSaveFilePathAndFilter( |
425 options = QFileDialog.Option(0) |
438 parent, caption, str(directory), filterStr, initialFilter, options |
426 filename = QFileDialog.getSaveFileName( |
439 )[0] |
427 parent, caption, str(directory), filterStr, "", options |
|
428 )[0] |
|
429 return pathlib.Path(filename) |
|
430 |
440 |
431 |
441 |
432 def getSaveFilePathAndFilter( |
442 def getSaveFilePathAndFilter( |
433 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
443 parent=None, caption="", directory="", filterStr="", initialFilter="", options=None |
434 ): |
444 ): |
435 """ |
445 """ |
436 Module function to get the path of a file for saving and the selected |
446 Module function to get the path of a file for saving and the selected |
437 file name filter. |
447 file name filter. |
438 |
448 |
439 @param parent parent widget of the dialog |
449 @param parent parent widget of the dialog (defaults to None) |
440 @type QWidget |
450 @type QWidget (optional) |
441 @param caption window title of the dialog |
451 @param caption window title of the dialog (defaults to "") |
442 @type str |
452 @type str (optional) |
443 @param directory working directory of the dialog |
453 @param directory working directory of the dialog (defaults to "") |
444 @type str or pathlib.Path |
454 @type str or pathlib.Path (optional) |
445 @param filterStr filter string for the dialog |
455 @param filterStr filter string for the dialog (defaults to "") |
446 @type str |
456 @type str (optional) |
447 @param initialFilter initial filter for the dialog |
457 @param initialFilter initial filter for the dialog (defaults to "") |
448 @type str |
458 @type str (optional) |
449 @param options various options for the dialog |
459 @param options various options for the dialog (defaults to None) |
450 @type QFileDialog.Options |
460 @type QFileDialog.Options ((optional) |
451 @return path of file to be saved and selected filte |
461 @return path of file to be saved and selected filte |
452 @rtype tuple of (pathlib.Path, str) |
462 @rtype tuple of (pathlib.Path, str) |
453 """ |
463 """ |
454 if options is None: |
464 if options is None: |
455 options = QFileDialog.Option(0) |
465 options = QFileDialog.Option(0) |
464 parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly |
474 parent=None, caption="", directory="", options=QFileDialog.Option.ShowDirsOnly |
465 ): |
475 ): |
466 """ |
476 """ |
467 Module function to get the path of a directory. |
477 Module function to get the path of a directory. |
468 |
478 |
469 @param parent parent widget of the dialog |
479 @param parent parent widget of the dialog (defaults to None) |
470 @type QWidget |
480 @type QWidget (optional) |
471 @param caption window title of the dialog |
481 @param caption window title of the dialog (defaults to "") |
472 @type str |
482 @type str (optional) |
473 @param directory working directory of the dialog |
483 @param directory working directory of the dialog (defaults to "") |
474 @type str or pathlib.Path |
484 @type str or pathlib.Path (optional) |
475 @param options various options for the dialog |
485 @param options various options for the dialog (defaults to |
476 @type QFileDialog.Options |
486 QFileDialog.Option.ShowDirsOnly) |
|
487 @type QFileDialog.Options ((optional) |
477 @return path of selected directory |
488 @return path of selected directory |
478 @rtype pathlib.Path |
489 @rtype pathlib.Path |
479 """ |
490 """ |
480 if options is None: |
491 if options is None: |
481 options = QFileDialog.Option(0) |
492 options = QFileDialog.Option(0) |