eric6/E5Gui/E5PathPickerDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

6440
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2018 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
6440
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter a file system path using a file picker.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from .E5PathPicker import E5PathPicker, E5PathPickerModes
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
6466
dac80ad0de75 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6444
diff changeset
14
6440
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 class E5PathPickerDialog(QDialog):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 Class implementing a dialog to enter a file system path using a file
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 picker.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 def __init__(self, parent=None):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Constructor
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 @param parent reference to the parent widget
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @type QWidget
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 super(E5PathPickerDialog, self).__init__(parent)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.setMinimumWidth(400)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.__layout = QVBoxLayout(self)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.__label = QLabel(self)
6444
7ce7a43aeeba E5PathPickerDialog: enabled word wrap for the label text to be able to cope with longer texts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6441
diff changeset
34 self.__label.setWordWrap(True)
6440
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__pathPicker = E5PathPicker(self)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.__buttonBox = QDialogButtonBox(
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 QDialogButtonBox.Cancel | QDialogButtonBox.Ok, self)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__layout.addWidget(self.__label)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__layout.addWidget(self.__pathPicker)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.__layout.addWidget(self.__buttonBox)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__buttonBox.accepted.connect(self.accept)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__buttonBox.rejected.connect(self.reject)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def setLabelText(self, text):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Public method to set the label text.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param text label text
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__label.setText(text)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 def setTitle(self, title):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 Public method to set the window title.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @param title window title
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.setWindowTitle(title)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__pathPicker.setWindowTitle(title)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 def setPickerMode(self, mode):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 Public method to set the mode of the path picker.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @param mode picker mode
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 @type E5PathPickerModes
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__pathPicker.setMode(mode)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 def setPickerPath(self, path):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 Public method to set the path of the path picker.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 @param path path to be set
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__pathPicker.setPath(path)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 def setDefaultDirectory(self, directory):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 Public method to set the default directory of the path picker.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @param directory default directory
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__pathPicker.setDefaultDirectory(directory)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 def setPickerFilters(self, filters):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 Public method to set the filters of the path picker.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 Note: Multiple filters must be separated by ';;'.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @param filters string containing the file filters
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__pathPicker.setFilters(filters)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def getPath(self):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Public method to get the current path.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @return current path
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 @rtype str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 return self.__pathPicker.path()
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 def getPath(parent, title, label, mode=E5PathPickerModes.OpenFileMode,
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 path="", defaultDirectory="", filters=None):
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 Function to get a file or directory path from the user.
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 @param parent reference to the parent widget
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 @type QWidget
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 @param title title of the dialog
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 @param label text to be shown above the path picker
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 @param mode mode of the path picker
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 @type E5PathPickerModes
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 @param path initial path to be shown
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 @param defaultDirectory default directory of the path picker selection
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 dialog
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 @type str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 @param filters list of file filters
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 @type list of str
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 @return tuple containing the entered path and a flag indicating that the
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 user pressed the OK button
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 @rtype tuple of (str, bool)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 """
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 # step 1: setup of the dialog
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 dlg = E5PathPickerDialog(parent)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 if title:
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 dlg.setTitle(title)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if label:
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 dlg.setLabelText(label)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 dlg.setPickerMode(mode)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 if path:
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 dlg.setPickerPath(path)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 if defaultDirectory:
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 dlg.setDefaultDirectory(defaultDirectory)
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 if filters is not None and len(filters) > 0:
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 dlg.setPickerFilters(";;".join(filters))
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 # step 2: show the dialog and get the result
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
153 if dlg.exec() == QDialog.Accepted:
6440
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 ok = True
6441
b7c3b34661d5 E5PathPickerDialog: fixed an issue causing file paths with leading or trailing whitespace being returned.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6440
diff changeset
155 path = dlg.getPath().strip()
6440
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 else:
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 ok = False
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 path = ""
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 # step 3: return the result
81a4bebbc028 E5PathPickerDialog: added an input dialog using the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 return path, ok

eric ide

mercurial