13 import Globals |
13 import Globals |
14 |
14 |
15 Options = QFileDialog.Options |
15 Options = QFileDialog.Options |
16 Option = QFileDialog.Option |
16 Option = QFileDialog.Option |
17 |
17 |
18 ShowDirsOnly = QFileDialog.ShowDirsOnly |
18 ShowDirsOnly = QFileDialog.Option.ShowDirsOnly |
19 DontResolveSymlinks = QFileDialog.DontResolveSymlinks |
19 DontResolveSymlinks = QFileDialog.Option.DontResolveSymlinks |
20 DontConfirmOverwrite = QFileDialog.DontConfirmOverwrite |
20 DontConfirmOverwrite = QFileDialog.Option.DontConfirmOverwrite |
21 DontUseNativeDialog = QFileDialog.DontUseNativeDialog |
21 DontUseNativeDialog = QFileDialog.Option.DontUseNativeDialog |
22 ReadOnly = QFileDialog.ReadOnly |
22 ReadOnly = QFileDialog.Option.ReadOnly |
23 HideNameFilterDetails = QFileDialog.HideNameFilterDetails |
23 HideNameFilterDetails = QFileDialog.Option.HideNameFilterDetails |
24 DontUseSheet = QFileDialog.DontUseSheet |
24 DontUseSheet = QFileDialog.Option.DontUseSheet |
25 DontUseCustomDirectoryIcons = QFileDialog.DontUseCustomDirectoryIcons |
25 DontUseCustomDirectoryIcons = QFileDialog.Option.DontUseCustomDirectoryIcons |
26 |
26 |
27 |
27 |
28 def __reorderFilter(filterStr, initialFilter=""): |
28 def __reorderFilter(filterStr, initialFilter=""): |
29 """ |
29 """ |
30 Private function to reorder the file filter to cope with a KDE issue |
30 Private function to reorder the file filter to cope with a KDE issue |
57 @return name of file to be opened (string) |
57 @return name of file to be opened (string) |
58 """ |
58 """ |
59 if options is None: |
59 if options is None: |
60 options = QFileDialog.Options() |
60 options = QFileDialog.Options() |
61 if Globals.isLinuxPlatform(): |
61 if Globals.isLinuxPlatform(): |
62 options |= QFileDialog.DontUseNativeDialog |
62 options |= QFileDialog.Option.DontUseNativeDialog |
63 return QFileDialog.getOpenFileName( |
63 return QFileDialog.getOpenFileName( |
64 parent, caption, directory, filterStr, "", options)[0] |
64 parent, caption, directory, filterStr, "", options)[0] |
65 |
65 |
66 |
66 |
67 def getOpenFileNameAndFilter(parent=None, caption="", directory="", |
67 def getOpenFileNameAndFilter(parent=None, caption="", directory="", |
80 @return name of file to be opened and selected filter (string, string) |
80 @return name of file to be opened and selected filter (string, string) |
81 """ |
81 """ |
82 if options is None: |
82 if options is None: |
83 options = QFileDialog.Options() |
83 options = QFileDialog.Options() |
84 if Globals.isLinuxPlatform(): |
84 if Globals.isLinuxPlatform(): |
85 options |= QFileDialog.DontUseNativeDialog |
85 options |= QFileDialog.Option.DontUseNativeDialog |
86 newfilter = __reorderFilter(filterStr, initialFilter) |
86 newfilter = __reorderFilter(filterStr, initialFilter) |
87 return QFileDialog.getOpenFileName( |
87 return QFileDialog.getOpenFileName( |
88 parent, caption, directory, newfilter, initialFilter, options) |
88 parent, caption, directory, newfilter, initialFilter, options) |
89 |
89 |
90 |
90 |
101 @return list of file names to be opened (list of string) |
101 @return list of file names to be opened (list of string) |
102 """ |
102 """ |
103 if options is None: |
103 if options is None: |
104 options = QFileDialog.Options() |
104 options = QFileDialog.Options() |
105 if Globals.isLinuxPlatform(): |
105 if Globals.isLinuxPlatform(): |
106 options |= QFileDialog.DontUseNativeDialog |
106 options |= QFileDialog.Option.DontUseNativeDialog |
107 return QFileDialog.getOpenFileNames( |
107 return QFileDialog.getOpenFileNames( |
108 parent, caption, directory, filterStr, "", options)[0] |
108 parent, caption, directory, filterStr, "", options)[0] |
109 |
109 |
110 |
110 |
111 def getOpenFileNamesAndFilter(parent=None, caption="", directory="", |
111 def getOpenFileNamesAndFilter(parent=None, caption="", directory="", |
125 (list of string, string) |
125 (list of string, string) |
126 """ |
126 """ |
127 if options is None: |
127 if options is None: |
128 options = QFileDialog.Options() |
128 options = QFileDialog.Options() |
129 if Globals.isLinuxPlatform(): |
129 if Globals.isLinuxPlatform(): |
130 options |= QFileDialog.DontUseNativeDialog |
130 options |= QFileDialog.Option.DontUseNativeDialog |
131 newfilter = __reorderFilter(filterStr, initialFilter) |
131 newfilter = __reorderFilter(filterStr, initialFilter) |
132 return QFileDialog.getOpenFileNames( |
132 return QFileDialog.getOpenFileNames( |
133 parent, caption, directory, newfilter, initialFilter, options) |
133 parent, caption, directory, newfilter, initialFilter, options) |
134 |
134 |
135 |
135 |
146 @return name of file to be saved (string) |
146 @return name of file to be saved (string) |
147 """ |
147 """ |
148 if options is None: |
148 if options is None: |
149 options = QFileDialog.Options() |
149 options = QFileDialog.Options() |
150 if Globals.isLinuxPlatform(): |
150 if Globals.isLinuxPlatform(): |
151 options |= QFileDialog.DontUseNativeDialog |
151 options |= QFileDialog.Option.DontUseNativeDialog |
152 return QFileDialog.getSaveFileName( |
152 return QFileDialog.getSaveFileName( |
153 parent, caption, directory, filterStr, "", options)[0] |
153 parent, caption, directory, filterStr, "", options)[0] |
154 |
154 |
155 |
155 |
156 def getSaveFileNameAndFilter(parent=None, caption="", directory="", |
156 def getSaveFileNameAndFilter(parent=None, caption="", directory="", |
169 @return name of file to be saved and selected filter (string, string) |
169 @return name of file to be saved and selected filter (string, string) |
170 """ |
170 """ |
171 if options is None: |
171 if options is None: |
172 options = QFileDialog.Options() |
172 options = QFileDialog.Options() |
173 if Globals.isLinuxPlatform(): |
173 if Globals.isLinuxPlatform(): |
174 options |= QFileDialog.DontUseNativeDialog |
174 options |= QFileDialog.Option.DontUseNativeDialog |
175 newfilter = __reorderFilter(filterStr, initialFilter) |
175 newfilter = __reorderFilter(filterStr, initialFilter) |
176 return QFileDialog.getSaveFileName( |
176 return QFileDialog.getSaveFileName( |
177 parent, caption, directory, newfilter, initialFilter, options) |
177 parent, caption, directory, newfilter, initialFilter, options) |
178 |
178 |
179 |
179 |
180 def getExistingDirectory(parent=None, caption="", |
180 def getExistingDirectory(parent=None, caption="", |
181 directory="", options=QFileDialog.ShowDirsOnly): |
181 directory="", |
|
182 options=QFileDialog.Option.ShowDirsOnly): |
182 """ |
183 """ |
183 Module function to get the name of a directory. |
184 Module function to get the name of a directory. |
184 |
185 |
185 @param parent parent widget of the dialog (QWidget) |
186 @param parent parent widget of the dialog (QWidget) |
186 @param caption window title of the dialog (string) |
187 @param caption window title of the dialog (string) |
187 @param directory working directory of the dialog (string) |
188 @param directory working directory of the dialog (string) |
188 @param options various options for the dialog (QFileDialog.Options) |
189 @param options various options for the dialog (QFileDialog.Options) |
189 @return name of selected directory (string) |
190 @return name of selected directory (string) |
190 """ |
191 """ |
191 if Globals.isLinuxPlatform(): |
192 if Globals.isLinuxPlatform(): |
192 options |= QFileDialog.DontUseNativeDialog |
193 options |= QFileDialog.Option.DontUseNativeDialog |
193 return QFileDialog.getExistingDirectory(parent, caption, directory, |
194 return QFileDialog.getExistingDirectory(parent, caption, directory, |
194 options) |
195 options) |