45 else: |
45 else: |
46 return filterStr |
46 return filterStr |
47 |
47 |
48 |
48 |
49 def getOpenFileName(parent=None, caption="", directory="", |
49 def getOpenFileName(parent=None, caption="", directory="", |
50 filterStr="", options=QFileDialog.Options()): |
50 filterStr="", options=None): |
51 """ |
51 """ |
52 Module function to get the name of a file for opening it. |
52 Module function to get the name of a file for opening it. |
53 |
53 |
54 @param parent parent widget of the dialog (QWidget) |
54 @param parent parent widget of the dialog (QWidget) |
55 @param caption window title of the dialog (string) |
55 @param caption window title of the dialog (string) |
56 @param directory working directory of the dialog (string) |
56 @param directory working directory of the dialog (string) |
57 @param filterStr filter string for the dialog (string) |
57 @param filterStr filter string for the dialog (string) |
58 @param options various options for the dialog (QFileDialog.Options) |
58 @param options various options for the dialog (QFileDialog.Options) |
59 @return name of file to be opened (string) |
59 @return name of file to be opened (string) |
60 """ |
60 """ |
|
61 if options is None: |
|
62 options = QFileDialog.Options() |
61 if Globals.isLinuxPlatform(): |
63 if Globals.isLinuxPlatform(): |
62 options |= QFileDialog.DontUseNativeDialog |
64 options |= QFileDialog.DontUseNativeDialog |
63 if PYQT_VERSION_STR >= "5.0.0": |
65 if PYQT_VERSION_STR >= "5.0.0": |
64 return QFileDialog.getOpenFileName( |
66 return QFileDialog.getOpenFileName( |
65 parent, caption, directory, filterStr, "", options)[0] |
67 parent, caption, directory, filterStr, "", options)[0] |
68 parent, caption, directory, filterStr, options) |
70 parent, caption, directory, filterStr, options) |
69 |
71 |
70 |
72 |
71 def getOpenFileNameAndFilter(parent=None, caption="", directory="", |
73 def getOpenFileNameAndFilter(parent=None, caption="", directory="", |
72 filterStr="", initialFilter="", |
74 filterStr="", initialFilter="", |
73 options=QFileDialog.Options()): |
75 options=None): |
74 """ |
76 """ |
75 Module function to get the name of a file for opening it and the selected |
77 Module function to get the name of a file for opening it and the selected |
76 file name filter. |
78 file name filter. |
77 |
79 |
78 @param parent parent widget of the dialog (QWidget) |
80 @param parent parent widget of the dialog (QWidget) |
81 @param filterStr filter string for the dialog (string) |
83 @param filterStr filter string for the dialog (string) |
82 @param initialFilter initial filter for the dialog (string) |
84 @param initialFilter initial filter for the dialog (string) |
83 @param options various options for the dialog (QFileDialog.Options) |
85 @param options various options for the dialog (QFileDialog.Options) |
84 @return name of file to be opened and selected filter (string, string) |
86 @return name of file to be opened and selected filter (string, string) |
85 """ |
87 """ |
|
88 if options is None: |
|
89 options = QFileDialog.Options() |
86 if Globals.isLinuxPlatform(): |
90 if Globals.isLinuxPlatform(): |
87 options |= QFileDialog.DontUseNativeDialog |
91 options |= QFileDialog.DontUseNativeDialog |
88 newfilter = __reorderFilter(filterStr, initialFilter) |
92 newfilter = __reorderFilter(filterStr, initialFilter) |
89 if PYQT_VERSION_STR >= "5.0.0": |
93 if PYQT_VERSION_STR >= "5.0.0": |
90 return QFileDialog.getOpenFileName( |
94 return QFileDialog.getOpenFileName( |
93 return QFileDialog.getOpenFileNameAndFilter( |
97 return QFileDialog.getOpenFileNameAndFilter( |
94 parent, caption, directory, newfilter, initialFilter, options) |
98 parent, caption, directory, newfilter, initialFilter, options) |
95 |
99 |
96 |
100 |
97 def getOpenFileNames(parent=None, caption="", directory="", |
101 def getOpenFileNames(parent=None, caption="", directory="", |
98 filterStr="", options=QFileDialog.Options()): |
102 filterStr="", options=None): |
99 """ |
103 """ |
100 Module function to get a list of names of files for opening. |
104 Module function to get a list of names of files for opening. |
101 |
105 |
102 @param parent parent widget of the dialog (QWidget) |
106 @param parent parent widget of the dialog (QWidget) |
103 @param caption window title of the dialog (string) |
107 @param caption window title of the dialog (string) |
104 @param directory working directory of the dialog (string) |
108 @param directory working directory of the dialog (string) |
105 @param filterStr filter string for the dialog (string) |
109 @param filterStr filter string for the dialog (string) |
106 @param options various options for the dialog (QFileDialog.Options) |
110 @param options various options for the dialog (QFileDialog.Options) |
107 @return list of file names to be opened (list of string) |
111 @return list of file names to be opened (list of string) |
108 """ |
112 """ |
|
113 if options is None: |
|
114 options = QFileDialog.Options() |
109 if Globals.isLinuxPlatform(): |
115 if Globals.isLinuxPlatform(): |
110 options |= QFileDialog.DontUseNativeDialog |
116 options |= QFileDialog.DontUseNativeDialog |
111 if PYQT_VERSION_STR >= "5.0.0": |
117 if PYQT_VERSION_STR >= "5.0.0": |
112 return QFileDialog.getOpenFileNames( |
118 return QFileDialog.getOpenFileNames( |
113 parent, caption, directory, filterStr, "", options)[0] |
119 parent, caption, directory, filterStr, "", options)[0] |
116 parent, caption, directory, filterStr, options) |
122 parent, caption, directory, filterStr, options) |
117 |
123 |
118 |
124 |
119 def getOpenFileNamesAndFilter(parent=None, caption="", directory="", |
125 def getOpenFileNamesAndFilter(parent=None, caption="", directory="", |
120 filterStr="", initialFilter="", |
126 filterStr="", initialFilter="", |
121 options=QFileDialog.Options()): |
127 options=None): |
122 """ |
128 """ |
123 Module function to get a list of names of files for opening and the |
129 Module function to get a list of names of files for opening and the |
124 selected file name filter. |
130 selected file name filter. |
125 |
131 |
126 @param parent parent widget of the dialog (QWidget) |
132 @param parent parent widget of the dialog (QWidget) |
130 @param initialFilter initial filter for the dialog (string) |
136 @param initialFilter initial filter for the dialog (string) |
131 @param options various options for the dialog (QFileDialog.Options) |
137 @param options various options for the dialog (QFileDialog.Options) |
132 @return list of file names to be opened and selected filter |
138 @return list of file names to be opened and selected filter |
133 (list of string, string) |
139 (list of string, string) |
134 """ |
140 """ |
|
141 if options is None: |
|
142 options = QFileDialog.Options() |
135 if Globals.isLinuxPlatform(): |
143 if Globals.isLinuxPlatform(): |
136 options |= QFileDialog.DontUseNativeDialog |
144 options |= QFileDialog.DontUseNativeDialog |
137 newfilter = __reorderFilter(filterStr, initialFilter) |
145 newfilter = __reorderFilter(filterStr, initialFilter) |
138 if PYQT_VERSION_STR >= "5.0.0": |
146 if PYQT_VERSION_STR >= "5.0.0": |
139 return QFileDialog.getOpenFileNames( |
147 return QFileDialog.getOpenFileNames( |
142 return QFileDialog.getOpenFileNamesAndFilter( |
150 return QFileDialog.getOpenFileNamesAndFilter( |
143 parent, caption, directory, newfilter, initialFilter, options) |
151 parent, caption, directory, newfilter, initialFilter, options) |
144 |
152 |
145 |
153 |
146 def getSaveFileName(parent=None, caption="", directory="", |
154 def getSaveFileName(parent=None, caption="", directory="", |
147 filterStr="", options=QFileDialog.Options()): |
155 filterStr="", options=None): |
148 """ |
156 """ |
149 Module function to get the name of a file for saving it. |
157 Module function to get the name of a file for saving it. |
150 |
158 |
151 @param parent parent widget of the dialog (QWidget) |
159 @param parent parent widget of the dialog (QWidget) |
152 @param caption window title of the dialog (string) |
160 @param caption window title of the dialog (string) |
153 @param directory working directory of the dialog (string) |
161 @param directory working directory of the dialog (string) |
154 @param filterStr filter string for the dialog (string) |
162 @param filterStr filter string for the dialog (string) |
155 @param options various options for the dialog (QFileDialog.Options) |
163 @param options various options for the dialog (QFileDialog.Options) |
156 @return name of file to be saved (string) |
164 @return name of file to be saved (string) |
157 """ |
165 """ |
|
166 if options is None: |
|
167 options = QFileDialog.Options() |
158 if Globals.isLinuxPlatform(): |
168 if Globals.isLinuxPlatform(): |
159 options |= QFileDialog.DontUseNativeDialog |
169 options |= QFileDialog.DontUseNativeDialog |
160 if PYQT_VERSION_STR >= "5.0.0": |
170 if PYQT_VERSION_STR >= "5.0.0": |
161 return QFileDialog.getSaveFileName( |
171 return QFileDialog.getSaveFileName( |
162 parent, caption, directory, filterStr, "", options)[0] |
172 parent, caption, directory, filterStr, "", options)[0] |
165 parent, caption, directory, filterStr, options) |
175 parent, caption, directory, filterStr, options) |
166 |
176 |
167 |
177 |
168 def getSaveFileNameAndFilter(parent=None, caption="", directory="", |
178 def getSaveFileNameAndFilter(parent=None, caption="", directory="", |
169 filterStr="", initialFilter="", |
179 filterStr="", initialFilter="", |
170 options=QFileDialog.Options()): |
180 options=None): |
171 """ |
181 """ |
172 Module function to get the name of a file for saving it and the selected |
182 Module function to get the name of a file for saving it and the selected |
173 file name filter. |
183 file name filter. |
174 |
184 |
175 @param parent parent widget of the dialog (QWidget) |
185 @param parent parent widget of the dialog (QWidget) |
178 @param filterStr filter string for the dialog (string) |
188 @param filterStr filter string for the dialog (string) |
179 @param initialFilter initial filter for the dialog (string) |
189 @param initialFilter initial filter for the dialog (string) |
180 @param options various options for the dialog (QFileDialog.Options) |
190 @param options various options for the dialog (QFileDialog.Options) |
181 @return name of file to be saved and selected filter (string, string) |
191 @return name of file to be saved and selected filter (string, string) |
182 """ |
192 """ |
|
193 if options is None: |
|
194 options = QFileDialog.Options() |
183 if Globals.isLinuxPlatform(): |
195 if Globals.isLinuxPlatform(): |
184 options |= QFileDialog.DontUseNativeDialog |
196 options |= QFileDialog.DontUseNativeDialog |
185 newfilter = __reorderFilter(filterStr, initialFilter) |
197 newfilter = __reorderFilter(filterStr, initialFilter) |
186 if PYQT_VERSION_STR >= "5.0.0": |
198 if PYQT_VERSION_STR >= "5.0.0": |
187 return QFileDialog.getSaveFileName( |
199 return QFileDialog.getSaveFileName( |