41 @param parent parent widget of this dialog |
42 @param parent parent widget of this dialog |
42 @type QWidget |
43 @type QWidget |
43 """ |
44 """ |
44 QDialog.__init__(self, parent) |
45 QDialog.__init__(self, parent) |
45 self.setupUi(self) |
46 self.setupUi(self) |
46 |
47 |
47 self.selectFileOrFolderButton.setIcon( |
48 self.selectFileOrFolderButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
48 UI.PixmapCache.getIcon("open.png")) |
49 |
49 |
50 self.targetDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
50 self.targetDirPicker.setMode( |
51 self.targetDirPicker.setWindowTitle(self.tr("Select target directory")) |
51 EricPathPickerModes.DIRECTORY_MODE) |
52 |
52 self.targetDirPicker.setWindowTitle( |
|
53 self.tr("Select target directory")) |
|
54 |
|
55 iconsI18N = self.tr("Icons") |
53 iconsI18N = self.tr("Icons") |
56 allFilesI18N = self.tr("All files") |
54 allFilesI18N = self.tr("All files") |
57 if Utilities.isWindowsPlatform(): |
55 if Utilities.isWindowsPlatform(): |
58 iconFilter = "{0} (*.ico);;{1} (*.*)".format( |
56 iconFilter = "{0} (*.ico);;{1} (*.*)".format(iconsI18N, allFilesI18N) |
59 iconsI18N, allFilesI18N) |
|
60 elif Utilities.isMacPlatform(): |
57 elif Utilities.isMacPlatform(): |
61 iconFilter = "{0} (*.icns *.png);;{1} (*.*)".format( |
58 iconFilter = "{0} (*.icns *.png);;{1} (*.*)".format(iconsI18N, allFilesI18N) |
62 iconsI18N, allFilesI18N) |
|
63 else: |
59 else: |
64 iconFilter = "{0} (*.png);;{1} (*.*)".format( |
60 iconFilter = "{0} (*.png);;{1} (*.*)".format(iconsI18N, allFilesI18N) |
65 iconsI18N, allFilesI18N) |
61 self.applicationIconPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
66 self.applicationIconPicker.setMode( |
|
67 EricPathPickerModes.OPEN_FILE_MODE) |
|
68 self.applicationIconPicker.setWindowTitle( |
62 self.applicationIconPicker.setWindowTitle( |
69 self.tr("Select the application icon")) |
63 self.tr("Select the application icon") |
|
64 ) |
70 self.applicationIconPicker.setFilters(iconFilter) |
65 self.applicationIconPicker.setFilters(iconFilter) |
71 |
66 |
72 self.extListFilePicker.setMode( |
67 self.extListFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
73 EricPathPickerModes.OPEN_FILE_MODE) |
68 self.extListFilePicker.setWindowTitle(self.tr("Select external list file")) |
74 self.extListFilePicker.setWindowTitle( |
69 |
75 self.tr("Select external list file")) |
|
76 |
|
77 self.__project = project |
70 self.__project = project |
78 self.__initializeDefaults() |
71 self.__initializeDefaults() |
79 |
72 |
80 # get a copy of the defaults to store the user settings |
73 # get a copy of the defaults to store the user settings |
81 self.__parameters = copy.deepcopy(self.defaults) |
74 self.__parameters = copy.deepcopy(self.defaults) |
82 |
75 |
83 # combine it with the values of parms |
76 # combine it with the values of parms |
84 if parms is not None: |
77 if parms is not None: |
85 self.__parameters.update(parms) |
78 self.__parameters.update(parms) |
86 |
79 |
87 self.cxfreezeExecCombo.addItems(exe) |
80 self.cxfreezeExecCombo.addItems(exe) |
88 # try to set the saved script path |
81 # try to set the saved script path |
89 with contextlib.suppress(ValueError): |
82 with contextlib.suppress(ValueError): |
90 idx = exe.index(self.__parameters['script']) |
83 idx = exe.index(self.__parameters["script"]) |
91 self.cxfreezeExecCombo.setCurrentIndex(idx) |
84 self.cxfreezeExecCombo.setCurrentIndex(idx) |
92 |
85 |
93 # initialize general tab |
86 # initialize general tab |
94 self.targetDirPicker.setText( |
87 self.targetDirPicker.setText(self.__parameters["targetDirectory"]) |
95 self.__parameters['targetDirectory']) |
88 self.targetNameEdit.setText(self.__parameters["targetName"]) |
96 self.targetNameEdit.setText( |
89 self.basenameCombo.setEditText(self.__parameters["baseName"]) |
97 self.__parameters['targetName']) |
90 self.initscriptCombo.setEditText(self.__parameters["initScript"]) |
98 self.basenameCombo.setEditText( |
91 self.applicationIconPicker.setText(self.__parameters["applicationIcon"]) |
99 self.__parameters['baseName']) |
92 self.keeppathCheckBox.setChecked(self.__parameters["keepPath"]) |
100 self.initscriptCombo.setEditText( |
93 self.compressCheckBox.setChecked(self.__parameters["compress"]) |
101 self.__parameters['initScript']) |
94 if self.__parameters["optimize"] == 0: |
102 self.applicationIconPicker.setText( |
|
103 self.__parameters['applicationIcon']) |
|
104 self.keeppathCheckBox.setChecked( |
|
105 self.__parameters['keepPath']) |
|
106 self.compressCheckBox.setChecked( |
|
107 self.__parameters['compress']) |
|
108 if self.__parameters['optimize'] == 0: |
|
109 self.nooptimizeRadioButton.setChecked(True) |
95 self.nooptimizeRadioButton.setChecked(True) |
110 elif self.__parameters['optimize'] == 1: |
96 elif self.__parameters["optimize"] == 1: |
111 self.optimizeRadioButton.setChecked(True) |
97 self.optimizeRadioButton.setChecked(True) |
112 else: |
98 else: |
113 self.optimizeDocRadioButton.setChecked(True) |
99 self.optimizeDocRadioButton.setChecked(True) |
114 |
100 |
115 # initialize advanced tab |
101 # initialize advanced tab |
116 self.defaultPathEdit.setText( |
102 self.defaultPathEdit.setText(os.pathsep.join(self.__parameters["defaultPath"])) |
117 os.pathsep.join(self.__parameters['defaultPath'])) |
103 self.includePathEdit.setText(os.pathsep.join(self.__parameters["includePath"])) |
118 self.includePathEdit.setText( |
|
119 os.pathsep.join(self.__parameters['includePath'])) |
|
120 self.replacePathsEdit.setText( |
104 self.replacePathsEdit.setText( |
121 os.pathsep.join(self.__parameters['replacePaths'])) |
105 os.pathsep.join(self.__parameters["replacePaths"]) |
122 self.includeModulesEdit.setText( |
106 ) |
123 ','.join(self.__parameters['includeModules'])) |
107 self.includeModulesEdit.setText(",".join(self.__parameters["includeModules"])) |
124 self.excludeModulesEdit.setText( |
108 self.excludeModulesEdit.setText(",".join(self.__parameters["excludeModules"])) |
125 ','.join(self.__parameters['excludeModules'])) |
109 self.extListFilePicker.setText(self.__parameters["extListFile"]) |
126 self.extListFilePicker.setText(self.__parameters['extListFile']) |
110 |
127 |
|
128 # initialize additional files tab |
111 # initialize additional files tab |
129 self.fileOrFolderList.addItems(self.__parameters['additionalFiles']) |
112 self.fileOrFolderList.addItems(self.__parameters["additionalFiles"]) |
130 |
113 |
131 def __initializeDefaults(self): |
114 def __initializeDefaults(self): |
132 """ |
115 """ |
133 Private method to set the default values. |
116 Private method to set the default values. |
134 |
117 |
135 These are needed later on to generate the command line parameters. |
118 These are needed later on to generate the command line parameters. |
136 """ |
119 """ |
137 self.defaults = { |
120 self.defaults = { |
138 # general options |
121 # general options |
139 'targetDirectory': '', |
122 "targetDirectory": "", |
140 'targetName': '', |
123 "targetName": "", |
141 'baseName': 'Console', |
124 "baseName": "Console", |
142 'initScript': 'Console', |
125 "initScript": "Console", |
143 'applicationIcon': '', |
126 "applicationIcon": "", |
144 'script': '', |
127 "script": "", |
145 'keepPath': False, |
128 "keepPath": False, |
146 'compress': False, |
129 "compress": False, |
147 'optimize': 0, # 0, 1 or 2 |
130 "optimize": 0, # 0, 1 or 2 |
148 |
|
149 # advanced options |
131 # advanced options |
150 'defaultPath': [], |
132 "defaultPath": [], |
151 'includePath': [], |
133 "includePath": [], |
152 'replacePaths': [], |
134 "replacePaths": [], |
153 'includeModules': [], |
135 "includeModules": [], |
154 'excludeModules': [], |
136 "excludeModules": [], |
155 'extListFile': '', |
137 "extListFile": "", |
156 |
|
157 # additional files tab |
138 # additional files tab |
158 'additionalFiles': [], |
139 "additionalFiles": [], |
159 } |
140 } |
160 # overwrite 'baseName' if OS is Windows |
141 # overwrite 'baseName' if OS is Windows |
161 if sys.platform == 'win32': |
142 if sys.platform == "win32": |
162 self.defaults['baseName'] = 'Win32GUI' |
143 self.defaults["baseName"] = "Win32GUI" |
163 # overwrite 'initScript' if version 3 interpreter |
144 # overwrite 'initScript' if version 3 interpreter |
164 if self.__project.getProjectLanguage() == 'Python3': |
145 if self.__project.getProjectLanguage() == "Python3": |
165 self.defaults['initScript'] = 'Console3' |
146 self.defaults["initScript"] = "Console3" |
166 |
147 |
167 def generateParameters(self): |
148 def generateParameters(self): |
168 """ |
149 """ |
169 Public method that generates the command line parameters. |
150 Public method that generates the command line parameters. |
170 |
151 |
171 It generates a list of strings to be used to set the QProcess arguments |
152 It generates a list of strings to be used to set the QProcess arguments |
172 for the cxfreeze call and a list containing the non default parameters. |
153 for the cxfreeze call and a list containing the non default parameters. |
173 The second list can be passed back upon object generation to overwrite |
154 The second list can be passed back upon object generation to overwrite |
174 the default settings. |
155 the default settings. |
175 |
156 |
176 @return a tuple of the command line parameters and non default |
157 @return a tuple of the command line parameters and non default |
177 parameters |
158 parameters |
178 @rtype tuple of (list of str, dict) |
159 @rtype tuple of (list of str, dict) |
179 """ |
160 """ |
180 parms = {} |
161 parms = {} |
181 args = [] |
162 args = [] |
182 |
163 |
183 # 1. the program name |
164 # 1. the program name |
184 args.append(self.cxfreezeExecCombo.currentText()) |
165 args.append(self.cxfreezeExecCombo.currentText()) |
185 |
166 |
186 # 2. the commandline options |
167 # 2. the commandline options |
187 # 2.1 general options |
168 # 2.1 general options |
188 if ( |
169 if self.__parameters["targetDirectory"] != self.defaults["targetDirectory"]: |
189 self.__parameters['targetDirectory'] != |
170 parms["targetDirectory"] = self.__parameters["targetDirectory"] |
190 self.defaults['targetDirectory'] |
171 args.append("--target-dir={0}".format(self.__parameters["targetDirectory"])) |
191 ): |
172 if self.__parameters["targetName"] != self.defaults["targetName"]: |
192 parms['targetDirectory'] = self.__parameters['targetDirectory'] |
173 parms["targetName"] = self.__parameters["targetName"][:] |
193 args.append('--target-dir={0}'.format( |
174 args.append("--target-name={0}".format(self.__parameters["targetName"])) |
194 self.__parameters['targetDirectory'])) |
175 parms["baseName"] = self.__parameters["baseName"][:] |
195 if self.__parameters['targetName'] != self.defaults['targetName']: |
176 if self.__parameters["baseName"] != "": |
196 parms['targetName'] = self.__parameters['targetName'][:] |
177 args.append("--base-name={0}".format(self.__parameters["baseName"])) |
197 args.append('--target-name={0}'.format( |
178 parms["initScript"] = self.__parameters["initScript"][:] |
198 self.__parameters['targetName'])) |
179 if self.__parameters["initScript"] != "": |
199 parms['baseName'] = self.__parameters['baseName'][:] |
180 args.append("--init-script={0}".format(self.__parameters["initScript"])) |
200 if self.__parameters['baseName'] != '': |
181 parms["applicationIcon"] = self.__parameters["applicationIcon"][:] |
|
182 if self.__parameters["applicationIcon"] != self.defaults["applicationIcon"]: |
|
183 args.append("--icon={0}".format(self.__parameters["applicationIcon"])) |
|
184 parms["script"] = self.__parameters["script"][:] |
|
185 if self.__parameters["keepPath"] != self.defaults["keepPath"]: |
|
186 parms["keepPath"] = self.__parameters["keepPath"] |
|
187 args.append("--no-copy-deps") |
|
188 if self.__parameters["compress"] != self.defaults["compress"]: |
|
189 parms["compress"] = self.__parameters["compress"] |
|
190 args.append("--compress") |
|
191 if self.__parameters["optimize"] != self.defaults["optimize"]: |
|
192 parms["optimize"] = self.__parameters["optimize"] |
|
193 if self.__parameters["optimize"] == 1: |
|
194 args.append("-O") |
|
195 elif self.__parameters["optimize"] == 2: |
|
196 args.append("-OO") |
|
197 |
|
198 # 2.2 advanced options |
|
199 if self.__parameters["defaultPath"] != self.defaults["defaultPath"]: |
|
200 parms["defaultPath"] = self.__parameters["defaultPath"][:] |
201 args.append( |
201 args.append( |
202 '--base-name={0}'.format(self.__parameters['baseName'])) |
202 "--default-path={0}".format( |
203 parms['initScript'] = self.__parameters['initScript'][:] |
203 os.pathsep.join(self.__parameters["defaultPath"]) |
204 if self.__parameters['initScript'] != '': |
204 ) |
205 args.append('--init-script={0}'.format( |
205 ) |
206 self.__parameters['initScript'])) |
206 if self.__parameters["includePath"] != self.defaults["includePath"]: |
207 parms['applicationIcon'] = self.__parameters['applicationIcon'][:] |
207 parms["includePath"] = self.__parameters["includePath"][:] |
208 if ( |
208 args.append( |
209 self.__parameters['applicationIcon'] != |
209 "--include-path={0}".format( |
210 self.defaults['applicationIcon'] |
210 os.pathsep.join(self.__parameters["includePath"]) |
211 ): |
211 ) |
212 args.append('--icon={0}'.format( |
212 ) |
213 self.__parameters['applicationIcon'])) |
213 if self.__parameters["replacePaths"] != self.defaults["replacePaths"]: |
214 parms['script'] = self.__parameters['script'][:] |
214 parms["replacePaths"] = self.__parameters["replacePaths"][:] |
215 if self.__parameters['keepPath'] != self.defaults['keepPath']: |
215 args.append( |
216 parms['keepPath'] = self.__parameters['keepPath'] |
216 "--replace-paths={0}".format( |
217 args.append('--no-copy-deps') |
217 os.pathsep.join(self.__parameters["replacePaths"]) |
218 if self.__parameters['compress'] != self.defaults['compress']: |
218 ) |
219 parms['compress'] = self.__parameters['compress'] |
219 ) |
220 args.append('--compress') |
220 if self.__parameters["includeModules"] != self.defaults["includeModules"]: |
221 if self.__parameters['optimize'] != self.defaults['optimize']: |
221 parms["includeModules"] = self.__parameters["includeModules"][:] |
222 parms['optimize'] = self.__parameters['optimize'] |
222 args.append( |
223 if self.__parameters['optimize'] == 1: |
223 "--include-modules={0}".format( |
224 args.append('-O') |
224 ",".join(self.__parameters["includeModules"]) |
225 elif self.__parameters['optimize'] == 2: |
225 ) |
226 args.append('-OO') |
226 ) |
227 |
227 if self.__parameters["excludeModules"] != self.defaults["excludeModules"]: |
228 # 2.2 advanced options |
228 parms["excludeModules"] = self.__parameters["excludeModules"][:] |
229 if self.__parameters['defaultPath'] != self.defaults['defaultPath']: |
229 args.append( |
230 parms['defaultPath'] = self.__parameters['defaultPath'][:] |
230 "--exclude-modules={0}".format( |
231 args.append('--default-path={0}'.format( |
231 ",".join(self.__parameters["excludeModules"]) |
232 os.pathsep.join(self.__parameters['defaultPath']))) |
232 ) |
233 if self.__parameters['includePath'] != self.defaults['includePath']: |
233 ) |
234 parms['includePath'] = self.__parameters['includePath'][:] |
234 if self.__parameters["extListFile"] != self.defaults["extListFile"]: |
235 args.append('--include-path={0}'.format( |
235 parms["extListFile"] = self.__parameters["extListFile"] |
236 os.pathsep.join(self.__parameters['includePath']))) |
236 args.append("--ext-list-file={0}".format(self.__parameters["extListFile"])) |
237 if self.__parameters['replacePaths'] != self.defaults['replacePaths']: |
237 |
238 parms['replacePaths'] = self.__parameters['replacePaths'][:] |
|
239 args.append('--replace-paths={0}'.format( |
|
240 os.pathsep.join(self.__parameters['replacePaths']))) |
|
241 if ( |
|
242 self.__parameters['includeModules'] != |
|
243 self.defaults['includeModules'] |
|
244 ): |
|
245 parms['includeModules'] = self.__parameters['includeModules'][:] |
|
246 args.append('--include-modules={0}'.format( |
|
247 ','.join(self.__parameters['includeModules']))) |
|
248 if ( |
|
249 self.__parameters['excludeModules'] != |
|
250 self.defaults['excludeModules'] |
|
251 ): |
|
252 parms['excludeModules'] = self.__parameters['excludeModules'][:] |
|
253 args.append('--exclude-modules={0}'.format( |
|
254 ','.join(self.__parameters['excludeModules']))) |
|
255 if self.__parameters['extListFile'] != self.defaults['extListFile']: |
|
256 parms['extListFile'] = self.__parameters['extListFile'] |
|
257 args.append('--ext-list-file={0}'.format( |
|
258 self.__parameters['extListFile'])) |
|
259 |
|
260 # 2.3 additional files tab |
238 # 2.3 additional files tab |
261 if self.__parameters['additionalFiles'] != []: |
239 if self.__parameters["additionalFiles"] != []: |
262 parms['additionalFiles'] = self.__parameters['additionalFiles'][:] |
240 parms["additionalFiles"] = self.__parameters["additionalFiles"][:] |
263 |
241 |
264 return (args, parms) |
242 return (args, parms) |
265 |
243 |
266 @pyqtSlot(str) |
244 @pyqtSlot(str) |
267 def on_cxfreezeExecCombo_currentIndexChanged(self, text): |
245 def on_cxfreezeExecCombo_currentIndexChanged(self, text): |
268 """ |
246 """ |
269 Private slot to handle the selection of a cxfreeze executable. |
247 Private slot to handle the selection of a cxfreeze executable. |
270 |
248 |
271 @param text selected cxfreeze executable |
249 @param text selected cxfreeze executable |
272 @type str |
250 @type str |
273 """ |
251 """ |
274 # version specific setup |
252 # version specific setup |
275 if Utilities.isWindowsPlatform(): |
253 if Utilities.isWindowsPlatform(): |
276 # remove "\Scripts\cx_Freeze.bat" from path |
254 # remove "\Scripts\cx_Freeze.bat" from path |
277 dirname = os.path.dirname(text) |
255 dirname = os.path.dirname(text) |
278 dirname = os.path.dirname(dirname) |
256 dirname = os.path.dirname(dirname) |
279 |
257 |
280 # first try the fast way |
258 # first try the fast way |
281 modpath = os.path.join( |
259 modpath = os.path.join(dirname, "Lib", "site-packages", "cx_Freeze") |
282 dirname, "Lib", "site-packages", "cx_Freeze") |
|
283 if not os.path.exists(modpath): |
260 if not os.path.exists(modpath): |
284 # but if it failed search in the whole directory tree |
261 # but if it failed search in the whole directory tree |
285 modpath = None |
262 modpath = None |
286 for dirpath, dirnames, _ in os.walk(dirname): |
263 for dirpath, dirnames, _ in os.walk(dirname): |
287 if 'cx_Freeze' in dirnames: |
264 if "cx_Freeze" in dirnames: |
288 modpath = os.path.join(dirpath, "cx_Freeze") |
265 modpath = os.path.join(dirpath, "cx_Freeze") |
289 break |
266 break |
290 else: |
267 else: |
291 with open(text, 'r') as f: |
268 with open(text, "r") as f: |
292 args = f.readline() |
269 args = f.readline() |
293 if not args: |
270 if not args: |
294 return |
271 return |
295 |
272 |
296 args = args.strip('!#\n').split(' ') |
273 args = args.strip("!#\n").split(" ") |
297 program = args.pop(0) |
274 program = args.pop(0) |
298 |
275 |
299 script = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
276 script = os.path.join( |
300 'CxfreezeFindPath.py') |
277 os.path.dirname(os.path.abspath(__file__)), "CxfreezeFindPath.py" |
|
278 ) |
301 if not os.path.exists(script): |
279 if not os.path.exists(script): |
302 return |
280 return |
303 |
281 |
304 args.append(script) |
282 args.append(script) |
305 process = QProcess() |
283 process = QProcess() |
306 process.start(program, args) |
284 process.start(program, args) |
307 process.waitForFinished(5000) |
285 process.waitForFinished(5000) |
308 # get a QByteArray of the output |
286 # get a QByteArray of the output |
309 cxPath = process.readAllStandardOutput() |
287 cxPath = process.readAllStandardOutput() |
310 modpath = str(cxPath, encoding='utf-8').strip('\n\r') |
288 modpath = str(cxPath, encoding="utf-8").strip("\n\r") |
311 if not modpath.endswith('cx_Freeze'): |
289 if not modpath.endswith("cx_Freeze"): |
312 return |
290 return |
313 |
291 |
314 # populate combo boxes |
292 # populate combo boxes |
315 if modpath: |
293 if modpath: |
316 d = QDir(os.path.join(modpath, 'bases')) |
294 d = QDir(os.path.join(modpath, "bases")) |
317 basesList = d.entryList(QDir.Filter.Files) |
295 basesList = d.entryList(QDir.Filter.Files) |
318 if Utilities.isWindowsPlatform(): |
296 if Utilities.isWindowsPlatform(): |
319 # strip the final '.exe' from the bases |
297 # strip the final '.exe' from the bases |
320 tmpBasesList = basesList[:] |
298 tmpBasesList = basesList[:] |
321 basesList = [] |
299 basesList = [] |
377 if txt: |
354 if txt: |
378 self.fileOrFolderList.addItem(txt) |
355 self.fileOrFolderList.addItem(txt) |
379 self.fileOrFolderEdit.clear() |
356 self.fileOrFolderEdit.clear() |
380 row = self.fileOrFolderList.currentRow() |
357 row = self.fileOrFolderList.currentRow() |
381 self.on_fileOrFolderList_currentRowChanged(row) |
358 self.on_fileOrFolderList_currentRowChanged(row) |
382 |
359 |
383 @pyqtSlot(str) |
360 @pyqtSlot(str) |
384 def on_fileOrFolderEdit_textChanged(self, txt): |
361 def on_fileOrFolderEdit_textChanged(self, txt): |
385 """ |
362 """ |
386 Private slot to handle the textChanged signal of the directory edit. |
363 Private slot to handle the textChanged signal of the directory edit. |
387 |
364 |
388 @param txt the text of the directory edit |
365 @param txt the text of the directory edit |
389 @type str |
366 @type str |
390 """ |
367 """ |
391 self.addFileOrFolderButton.setEnabled(txt != "") |
368 self.addFileOrFolderButton.setEnabled(txt != "") |
392 |
369 |
393 @pyqtSlot() |
370 @pyqtSlot() |
394 def on_deleteSelectedButton_clicked(self): |
371 def on_deleteSelectedButton_clicked(self): |
395 """ |
372 """ |
396 Private slot to delete the selected entry from the list view. |
373 Private slot to delete the selected entry from the list view. |
397 """ |
374 """ |
398 row = self.fileOrFolderList.currentRow() |
375 row = self.fileOrFolderList.currentRow() |
399 itm = self.fileOrFolderList.takeItem(row) |
376 itm = self.fileOrFolderList.takeItem(row) |
400 del itm |
377 del itm |
401 row = self.fileOrFolderList.currentRow() |
378 row = self.fileOrFolderList.currentRow() |
402 self.on_fileOrFolderList_currentRowChanged(row) |
379 self.on_fileOrFolderList_currentRowChanged(row) |
403 |
380 |
404 @pyqtSlot() |
381 @pyqtSlot() |
405 def on_selectFileOrFolderButton_clicked(self): |
382 def on_selectFileOrFolderButton_clicked(self): |
406 """ |
383 """ |
407 Private slot to select files or folders. |
384 Private slot to select files or folders. |
408 |
385 |
409 It displays a file and directory selection dialog to |
386 It displays a file and directory selection dialog to |
410 select the files and directories which should be copied |
387 select the files and directories which should be copied |
411 into the distribution folder. |
388 into the distribution folder. |
412 """ |
389 """ |
413 items = EricDirFileDialog.getOpenFileAndDirNames( |
390 items = EricDirFileDialog.getOpenFileAndDirNames( |
414 self, |
391 self, self.tr("Select files and folders"), self.__project.getProjectPath() |
415 self.tr("Select files and folders"), |
392 ) |
416 self.__project.getProjectPath()) |
393 |
417 |
|
418 for itm in items: |
394 for itm in items: |
419 itm = self.__project.getRelativePath(itm) |
395 itm = self.__project.getRelativePath(itm) |
420 self.fileOrFolderList.addItem(Utilities.toNativeSeparators(itm)) |
396 self.fileOrFolderList.addItem(Utilities.toNativeSeparators(itm)) |
421 row = self.fileOrFolderList.currentRow() |
397 row = self.fileOrFolderList.currentRow() |
422 self.on_fileOrFolderList_currentRowChanged(row) |
398 self.on_fileOrFolderList_currentRowChanged(row) |
423 |
399 |
424 def accept(self): |
400 def accept(self): |
425 """ |
401 """ |
426 Public method called by the Ok button. |
402 Public method called by the Ok button. |
427 |
403 |
428 It saves the values in the parameters dictionary. |
404 It saves the values in the parameters dictionary. |
429 """ |
405 """ |
430 # get data of general tab |
406 # get data of general tab |
431 self.__parameters['targetDirectory'] = self.__project.getRelativePath( |
407 self.__parameters["targetDirectory"] = self.__project.getRelativePath( |
432 self.targetDirPicker.text()) |
408 self.targetDirPicker.text() |
433 self.__parameters['targetName'] = self.targetNameEdit.text() |
409 ) |
434 self.__parameters['baseName'] = self.basenameCombo.currentText() |
410 self.__parameters["targetName"] = self.targetNameEdit.text() |
435 self.__parameters['initScript'] = self.initscriptCombo.currentText() |
411 self.__parameters["baseName"] = self.basenameCombo.currentText() |
436 self.__parameters['applicationIcon'] = self.__project.getRelativePath( |
412 self.__parameters["initScript"] = self.initscriptCombo.currentText() |
437 self.applicationIconPicker.text()) |
413 self.__parameters["applicationIcon"] = self.__project.getRelativePath( |
438 self.__parameters['script'] = self.cxfreezeExecCombo.currentText() |
414 self.applicationIconPicker.text() |
439 self.__parameters['keepPath'] = self.keeppathCheckBox.isChecked() |
415 ) |
440 self.__parameters['compress'] = self.compressCheckBox.isChecked() |
416 self.__parameters["script"] = self.cxfreezeExecCombo.currentText() |
|
417 self.__parameters["keepPath"] = self.keeppathCheckBox.isChecked() |
|
418 self.__parameters["compress"] = self.compressCheckBox.isChecked() |
441 if self.nooptimizeRadioButton.isChecked(): |
419 if self.nooptimizeRadioButton.isChecked(): |
442 self.__parameters['optimize'] = 0 |
420 self.__parameters["optimize"] = 0 |
443 elif self.optimizeRadioButton.isChecked(): |
421 elif self.optimizeRadioButton.isChecked(): |
444 self.__parameters['optimize'] = 1 |
422 self.__parameters["optimize"] = 1 |
445 else: |
423 else: |
446 self.__parameters['optimize'] = 2 |
424 self.__parameters["optimize"] = 2 |
447 |
425 |
448 # get data of advanced tab |
426 # get data of advanced tab |
449 self.__parameters['defaultPath'] = self.__splitIt( |
427 self.__parameters["defaultPath"] = self.__splitIt( |
450 self.defaultPathEdit.text(), os.pathsep) |
428 self.defaultPathEdit.text(), os.pathsep |
451 self.__parameters['includePath'] = self.__splitIt( |
429 ) |
452 self.includePathEdit.text(), os.pathsep) |
430 self.__parameters["includePath"] = self.__splitIt( |
453 self.__parameters['replacePaths'] = self.__splitIt( |
431 self.includePathEdit.text(), os.pathsep |
454 self.replacePathsEdit.text(), os.pathsep) |
432 ) |
455 self.__parameters['includeModules'] = self.__splitIt( |
433 self.__parameters["replacePaths"] = self.__splitIt( |
456 self.includeModulesEdit.text(), ',') |
434 self.replacePathsEdit.text(), os.pathsep |
457 self.__parameters['excludeModules'] = self.__splitIt( |
435 ) |
458 self.excludeModulesEdit.text(), ',') |
436 self.__parameters["includeModules"] = self.__splitIt( |
459 self.__parameters['extListFile'] = self.__project.getRelativePath( |
437 self.includeModulesEdit.text(), "," |
460 self.extListFilePicker.text()) |
438 ) |
461 |
439 self.__parameters["excludeModules"] = self.__splitIt( |
|
440 self.excludeModulesEdit.text(), "," |
|
441 ) |
|
442 self.__parameters["extListFile"] = self.__project.getRelativePath( |
|
443 self.extListFilePicker.text() |
|
444 ) |
|
445 |
462 # get data of the additional files tab |
446 # get data of the additional files tab |
463 additionalFiles = [self.fileOrFolderList.item(x).text() |
447 additionalFiles = [ |
464 for x in range(self.fileOrFolderList.count())] |
448 self.fileOrFolderList.item(x).text() |
465 self.__parameters['additionalFiles'] = additionalFiles |
449 for x in range(self.fileOrFolderList.count()) |
|
450 ] |
|
451 self.__parameters["additionalFiles"] = additionalFiles |
466 |
452 |
467 # call the accept slot of the base class |
453 # call the accept slot of the base class |
468 QDialog.accept(self) |
454 QDialog.accept(self) |
469 |
455 |
470 def __splitIt(self, s, sep): |
456 def __splitIt(self, s, sep): |
471 """ |
457 """ |
472 Private method to split a string observing various conditions. |
458 Private method to split a string observing various conditions. |
473 |
459 |
474 @param s string to split |
460 @param s string to split |
475 @type str |
461 @type str |
476 @param sep separator string |
462 @param sep separator string |
477 @type str |
463 @type str |
478 @return list of split values |
464 @return list of split values |
479 @rtype list of str |
465 @rtype list of str |
480 """ |
466 """ |
481 if s == "" or s is None: |
467 if s == "" or s is None: |
482 return [] |
468 return [] |
483 |
469 |
484 if s.endswith(sep): |
470 if s.endswith(sep): |
485 s = s[:-1] |
471 s = s[:-1] |
486 |
472 |
487 return s.split(sep) |
473 return s.split(sep) |