Project/CreateDialogCodeDialog.py

Thu, 10 Jan 2019 14:22:59 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 10 Jan 2019 14:22:59 +0100
branch
maintenance
changeset 6646
51eefa621de4
parent 6645
ad476851d7e0
child 6661
19fcbb7be3da
permissions
-rw-r--r--

Merged with default branch to prepare release 19.01.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6590
diff changeset
3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
2297
e8a46f81517c Adjusted some display strings to be independant of the Qt version (Qt4/Qt5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2223
diff changeset
7 Module implementing a dialog to generate code for a Qt4/Qt5 dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3142
diff changeset
10 from __future__ import unicode_literals
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
11 try:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
12 str = unicode # __IGNORE_EXCEPTION__
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
13 except NameError:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
14 pass
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2492
diff changeset
15
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import os
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
17 import json
4259
c90a1cb373f2 Added code to intercept a parse error of form files to the dialog code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4094
diff changeset
18 import xml.etree.ElementTree
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
20 from PyQt5.QtCore import QMetaObject, QByteArray, QRegExp, Qt, pyqtSlot, \
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
21 QMetaMethod, QSortFilterProxyModel, QProcess, QProcessEnvironment
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
22 from PyQt5.QtGui import QStandardItemModel, QBrush, QStandardItem
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
23 from PyQt5.QtWidgets import QWidget, QDialog, QDialogButtonBox, QAction
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
24 from PyQt5 import uic
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
25
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
27 from E5Gui.E5Application import e5App
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
28 from E5Gui import E5MessageBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
30 from .Ui_CreateDialogCodeDialog import Ui_CreateDialogCodeDialog
3110
af7a8dda4c32 Corrected a not working import in the dialog creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3038
diff changeset
31 from .NewDialogClassDialog import NewDialogClassDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
33 from eric6config import getConfig
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
35 from Globals import qVersionTuple
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
36
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
37
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
38 pyqtSignatureRole = Qt.UserRole + 1
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 pythonSignatureRole = Qt.UserRole + 2
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
40 rubySignatureRole = Qt.UserRole + 3
4485
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
41 returnTypeRole = Qt.UserRole + 4
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
42 parameterTypesListRole = Qt.UserRole + 5
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
43 parameterNamesListRole = Qt.UserRole + 6
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
44
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 class CreateDialogCodeDialog(QDialog, Ui_CreateDialogCodeDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
2297
e8a46f81517c Adjusted some display strings to be independant of the Qt version (Qt4/Qt5).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2223
diff changeset
48 Class implementing a dialog to generate code for a Qt4/Qt5 dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
50 DialogClasses = {
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
51 "QDialog", "QWidget", "QMainWindow", "QWizard", "QWizardPage",
2492
91ab554e3465 Added support for more widgets in the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2408
diff changeset
52 "QDockWidget", "QFrame", "QGroupBox", "QScrollArea", "QMdiArea",
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
53 "QTabWidget", "QToolBox", "QStackedWidget"
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
54 }
1869
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
55 Separator = 25 * "="
1275
3db9193a528b Fixed an issue with the Create Dialog Code dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1206
diff changeset
56
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
57 def __init__(self, formName, project, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 @param formName name of the file containing the form (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @param project reference to the project object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @param parent parent widget if the dialog (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2492
diff changeset
65 super(CreateDialogCodeDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.slotsView.header().hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.project = project
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.formFile = formName
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 filename, ext = os.path.splitext(self.formFile)
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
76 self.srcFile = '{0}{1}'.format(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
77 filename, self.project.getDefaultSourceExtension())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.slotsModel = QStandardItemModel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.proxyModel = QSortFilterProxyModel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.proxyModel.setDynamicSortFilter(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.proxyModel.setSourceModel(self.slotsModel)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.slotsView.setModel(self.proxyModel)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 # initialize some member variables
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__initError = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__module = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 if os.path.exists(self.srcFile):
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 45
diff changeset
90 vm = e5App().getObject("ViewManager")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 ed = vm.getOpenEditor(self.srcFile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if ed and not vm.checkDirty(ed):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.__initError = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
1016
72b6b0778e06 Fixed an issue in the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
96 try:
1844
0388a36b5fcf Fixed an issue in the dialog code creation dialog with scanning a Python source file not having the standard extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1819
diff changeset
97 splitExt = os.path.splitext(self.srcFile)
0388a36b5fcf Fixed an issue in the dialog code creation dialog with scanning a Python source file not having the standard extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1819
diff changeset
98 if len(splitExt) == 2:
0388a36b5fcf Fixed an issue in the dialog code creation dialog with scanning a Python source file not having the standard extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1819
diff changeset
99 exts = [splitExt[1]]
0388a36b5fcf Fixed an issue in the dialog code creation dialog with scanning a Python source file not having the standard extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1819
diff changeset
100 else:
0388a36b5fcf Fixed an issue in the dialog code creation dialog with scanning a Python source file not having the standard extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1819
diff changeset
101 exts = None
2408
dc3a7c9d8f6e Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
102 from Utilities import ModuleParser
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
103 self.__module = ModuleParser.readModule(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
104 self.srcFile, extensions=exts, caching=False)
1016
72b6b0778e06 Fixed an issue in the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
105 except ImportError:
72b6b0778e06 Fixed an issue in the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
106 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 if self.__module is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.filenameEdit.setText(self.srcFile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 classesList = []
1869
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
112 vagueClassesList = []
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
113 for cls in list(self.__module.classes.values()):
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
114 if not set(cls.super).isdisjoint(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
115 CreateDialogCodeDialog.DialogClasses):
1275
3db9193a528b Fixed an issue with the Create Dialog Code dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1206
diff changeset
116 classesList.append(cls.name)
1869
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
117 else:
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
118 vagueClassesList.append(cls.name)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 classesList.sort()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.classNameCombo.addItems(classesList)
1869
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
121 if vagueClassesList:
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
122 if classesList:
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
123 self.classNameCombo.addItem(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
124 CreateDialogCodeDialog.Separator)
1869
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
125 self.classNameCombo.addItems(sorted(vagueClassesList))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
1016
72b6b0778e06 Fixed an issue in the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
127 if os.path.exists(self.srcFile) and \
72b6b0778e06 Fixed an issue in the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
128 self.__module is not None and \
72b6b0778e06 Fixed an issue in the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
129 self.classNameCombo.count() == 0:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.__initError = True
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
131 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
132 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
133 self.tr("Create Dialog Code"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
134 self.tr(
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
135 """The file <b>{0}</b> exists but does not contain"""
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
136 """ any classes.""").format(self.srcFile))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.okButton.setEnabled(self.classNameCombo.count() > 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.__updateSlotsModel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 def initError(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 Public method to determine, if there was an initialzation error.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @return flag indicating an initialzation error (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 return self.__initError
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
149
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
150 def __runUicLoadUi(self, command):
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
151 """
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
152 Private method to run the UicLoadUi.py script with the given command
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
153 and return the output.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
155 @param command uic command to be run
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
156 @type str
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
157 @return tuple of process output and error flag
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
158 @rtype tuple of (str, bool)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
159 """
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
160 venvName = self.project.getDebugProperty("VIRTUALENV")
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
161 venvManager = e5App().getObject("VirtualEnvManager")
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
162 interpreter = venvManager.getVirtualenvInterpreter(venvName)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
163 execPath = venvManager.getVirtualenvExecPath(venvName)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
164
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
165 env = QProcessEnvironment.systemEnvironment()
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
166 if execPath:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
167 if env.contains("PATH"):
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
168 env.insert(
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
169 "PATH", os.pathsep.join([execPath, env.value("PATH")])
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
170 )
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
171 else:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
172 env.insert("PATH", execPath)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
173
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
174 loadUi = os.path.join(os.path.dirname(__file__), "UicLoadUi.py")
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
175 args = [
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
176 loadUi,
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
177 command,
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
178 self.formFile,
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
179 self.project.getProjectPath(),
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
180 ]
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
181
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
182 uicText = ""
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
183 ok = False
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
184
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
185 proc = QProcess()
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
186 proc.setWorkingDirectory(self.project.getProjectPath())
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
187 proc.setProcessEnvironment(env)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
188 proc.start(interpreter, args)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
189 started = proc.waitForStarted(5000)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
190 finished = proc.waitForFinished(30000)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
191 if started and finished:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
192 output = proc.readAllStandardOutput()
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
193 outText = str(output, "utf-8", "replace")
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
194 if proc.exitCode() == 0:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
195 ok = True
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
196 uicText = outText.strip()
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
197 else:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
198 E5MessageBox.critical(
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
199 self,
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
200 self.tr("uic error"),
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
201 self.tr(
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
202 """<p>There was an error loading the form <b>{0}</b>"""
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
203 """.</p><p>{1}</p>""").format(
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
204 self.formFile, outText)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
205 )
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
206 else:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
207 E5MessageBox.critical(
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
208 self,
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
209 self.tr("uic error"),
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
210 self.tr(
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
211 """<p>The project specific Python interpreter <b>{0}</b>"""
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
212 """ could not be started or did not finish within 30"""
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
213 """ seconds.</p>""").format(interpreter)
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
214 )
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
215
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
216 return uicText, ok
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
217
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
218 def __objectNameExternal(self):
6544
51996454f89f CreateDialogCodeDialog: extended the logic to support projects loading custom widgets from outside the eric or project directories (via a virtual environment).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6291
diff changeset
219 """
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
220 Private method to get the object name of a form via an external
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
221 interpreter.
6544
51996454f89f CreateDialogCodeDialog: extended the logic to support projects loading custom widgets from outside the eric or project directories (via a virtual environment).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6291
diff changeset
222
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
223 @return object name
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
224 @rtype str
6544
51996454f89f CreateDialogCodeDialog: extended the logic to support projects loading custom widgets from outside the eric or project directories (via a virtual environment).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6291
diff changeset
225 """
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
226 objectName = ""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
227
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
228 output, ok = self.__runUicLoadUi("object_name")
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
229 if ok and output:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
230 objectName = output
6544
51996454f89f CreateDialogCodeDialog: extended the logic to support projects loading custom widgets from outside the eric or project directories (via a virtual environment).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6291
diff changeset
231
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
232 return objectName
6544
51996454f89f CreateDialogCodeDialog: extended the logic to support projects loading custom widgets from outside the eric or project directories (via a virtual environment).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6291
diff changeset
233
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 def __objectName(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
236 Private method to get the object name of a form.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
238 @return object name
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
239 @rtype str
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
240 """
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
241 if self.project.getDebugProperty("VIRTUALENV"):
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
242 return self.__objectNameExternal()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
243 else:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
244 try:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
245 dlg = uic.loadUi(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
246 self.formFile, package=self.project.getProjectPath())
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
247 return dlg.objectName()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
248 except (AttributeError, ImportError,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
249 xml.etree.ElementTree.ParseError) as err:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
250 E5MessageBox.critical(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
251 self,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
252 self.tr("uic error"),
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
253 self.tr(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
254 """<p>There was an error loading the form <b>{0}</b>"""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
255 """.</p><p>{1}</p>""").format(self.formFile, str(err)))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
256 return ""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
257
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
258 def __classNameExternal(self):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
259 """
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
260 Private method to get the class name of a form via an external
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
261 interpreter.
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
262
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
263 @return class name
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
264 @rtype str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 """
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
266 className = ""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
267
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
268 output, ok = self.__runUicLoadUi("class_name")
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
269 if ok and output:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
270 className = output
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
271
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
272 return className
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
273
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 def __className(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 """
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
276 Private method to get the class name of a form.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
278 @return class name
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
279 @rtype str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 """
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
281 if self.project.getDebugProperty("VIRTUALENV"):
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
282 return self.__classNameExternal()
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
283 else:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
284 try:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
285 dlg = uic.loadUi(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
286 self.formFile, package=self.project.getProjectPath())
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
287 return dlg.metaObject().className()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
288 except (AttributeError, ImportError,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
289 xml.etree.ElementTree.ParseError) as err:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
290 E5MessageBox.critical(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
291 self,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
292 self.tr("uic error"),
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
293 self.tr(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
294 """<p>There was an error loading the form <b>{0}</b>"""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
295 """.</p><p>{1}</p>""").format(self.formFile, str(err)))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
296 return ""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
297
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 def __signatures(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 Private slot to get the signatures.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 @return list of signatures (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 if self.__module is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 return []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 signatures = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 clsName = self.classNameCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 if clsName:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 cls = self.__module.classes[clsName]
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
311 for meth in list(cls.methods.values()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 if meth.name.startswith("on_"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 if meth.pyqtSignature is not None:
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
314 sig = ", ".join(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
315 [bytes(QMetaObject.normalizedType(t)).decode()
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
316 for t in meth.pyqtSignature.split(",")])
427
6af5d12cfecb Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
317 signatures.append("{0}({1})".format(meth.name, sig))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 signatures.append(meth.name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 return signatures
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321
42
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
322 def __mapType(self, type_):
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
323 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
324 Private method to map a type as reported by Qt's meta object to the
42
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
325 correct Python type.
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
326
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
327 @param type_ type as reported by Qt (QByteArray)
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
328 @return mapped Python type (string)
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
329 """
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
330 mapped = bytes(type_).decode()
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
331
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
332 # I. always check for *
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
333 mapped = mapped.replace("*", "")
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
334
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
335 if self.project.getProjectLanguage() != "Python2" or \
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
336 self.project.getProjectType in ("PySide", "PySide2"):
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
337 # 1. check for const
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
338 mapped = mapped.replace("const ", "")
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
339
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
340 # 2. replace QString and QStringList
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
341 mapped = mapped.replace("QStringList", "list")\
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
342 .replace("QString", "str")
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
343
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
344 # 3. replace double by float
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
345 mapped = mapped.replace("double", "float")
42
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
346
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
347 return mapped
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
348
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
349 def __updateSlotsModelExternal(self):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
350 """
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
351 Private slot to update the slots tree display getting the data via an
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
352 external interpreter.
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
353 """
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
354 output, ok = self.__runUicLoadUi("signatures")
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
355 if ok and output:
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
356 objectsList = json.loads(output.strip())
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
357
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
358 signatureList = self.__signatures()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
359
6548
21f8260753b5 CreateDialogCodeDialog: fixed an oversight in the recent code changes causing the dialog to be populated multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6547
diff changeset
360 self.slotsModel.clear()
21f8260753b5 CreateDialogCodeDialog: fixed an oversight in the recent code changes causing the dialog to be populated multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6547
diff changeset
361 self.slotsModel.setHorizontalHeaderLabels([""])
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
362 for objectDict in objectsList:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
363 itm = QStandardItem("{0} ({1})".format(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
364 objectDict["name"],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
365 objectDict["class_name"]))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
366 self.slotsModel.appendRow(itm)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
367 for methodDict in objectDict["methods"]:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
368 itm2 = QStandardItem(methodDict["signature"])
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
369 itm.appendRow(itm2)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
370
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
371 if self.__module is not None:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
372 if methodDict["methods"][0] in signatureList or \
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
373 methodDict["methods"][1] in signatureList:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
374 itm2.setFlags(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
375 Qt.ItemFlags(Qt.ItemIsEnabled))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
376 itm2.setCheckState(Qt.Checked)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
377 itm2.setForeground(QBrush(Qt.blue))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
378 continue
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
379
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
380 itm2.setData(methodDict["pyqt_signature"],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
381 pyqtSignatureRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
382 itm2.setData(methodDict["python_signature"],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
383 pythonSignatureRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
384 itm2.setData(methodDict["return_type"],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
385 returnTypeRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
386 itm2.setData(methodDict["parameter_types"],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
387 parameterTypesListRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
388 itm2.setData(methodDict["parameter_names"],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
389 parameterNamesListRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
390
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
391 itm2.setFlags(Qt.ItemFlags(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
392 Qt.ItemIsUserCheckable |
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
393 Qt.ItemIsEnabled |
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
394 Qt.ItemIsSelectable)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
395 )
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
396 itm2.setCheckState(Qt.Unchecked)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
397
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
398 self.slotsView.sortByColumn(0, Qt.AscendingOrder)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
399
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 def __updateSlotsModel(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 Private slot to update the slots tree display.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 self.filterEdit.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405
6590
8cad6f50ff4c CreateDialogCodeDialog: fixed an issue and applied some logic to enhance the form data loading via the external UicLoadUi.py script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6548
diff changeset
406 if self.project.getDebugProperty("VIRTUALENV"):
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
407 self.__updateSlotsModelExternal()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
408 else:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
409 try:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
410 dlg = uic.loadUi(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
411 self.formFile, package=self.project.getProjectPath())
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
412 objects = dlg.findChildren(QWidget) + dlg.findChildren(QAction)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
413
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
414 signatureList = self.__signatures()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
416 self.slotsModel.clear()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
417 self.slotsModel.setHorizontalHeaderLabels([""])
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
418 for obj in objects:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
419 name = obj.objectName()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
420 if not name or name.startswith("qt_"):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
421 # ignore un-named or internal objects
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
422 continue
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
423
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
424 metaObject = obj.metaObject()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
425 className = metaObject.className()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
426 itm = QStandardItem("{0} ({1})".format(name, className))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
427 self.slotsModel.appendRow(itm)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
428 for index in range(metaObject.methodCount()):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
429 metaMethod = metaObject.method(index)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
430 if metaMethod.methodType() == QMetaMethod.Signal:
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
431 if qVersionTuple() >= (5, 0, 0):
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
432 itm2 = QStandardItem("on_{0}_{1}".format(
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
433 name,
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
434 bytes(metaMethod.methodSignature())
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
435 .decode()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
436 ))
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1870
diff changeset
437 else:
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
438 itm2 = QStandardItem("on_{0}_{1}".format(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
439 name, metaMethod.signature()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
440 ))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
441 itm.appendRow(itm2)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
442 if self.__module is not None:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
443 if qVersionTuple() >= (5, 0, 0):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
444 method = "on_{0}_{1}".format(
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
445 name,
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
446 bytes(metaMethod.methodSignature())
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
447 .decode().split("(")[0])
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
448 else:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
449 method = "on_{0}_{1}".format(
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
450 name,
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
451 metaMethod.signature().split("(")[0])
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
452 method2 = "{0}({1})".format(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
453 method,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
454 ", ".join([
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
455 self.__mapType(t)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
456 for t in metaMethod.parameterTypes()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
457 ])
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
458 )
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
459
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
460 if method2 in signatureList or \
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
461 method in signatureList:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
462 itm2.setFlags(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
463 Qt.ItemFlags(Qt.ItemIsEnabled))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
464 itm2.setCheckState(Qt.Checked)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
465 itm2.setForeground(QBrush(Qt.blue))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
466 continue
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
467
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
468 returnType = self.__mapType(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
469 metaMethod.typeName().encode())
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
470 if returnType == 'void':
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
471 returnType = ""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
472 parameterTypesList = [
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
473 self.__mapType(t)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
474 for t in metaMethod.parameterTypes()]
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
475 pyqtSignature = ", ".join(parameterTypesList)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
476
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
477 parameterNames = metaMethod.parameterNames()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
478 if parameterNames:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
479 for index in range(len(parameterNames)):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
480 if not parameterNames[index]:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
481 parameterNames[index] = \
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
482 QByteArray("p{0:d}".format(index)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
483 .encode("utf-8"))
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
484 parameterNamesList = [bytes(n).decode()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
485 for n in parameterNames]
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
486 methNamesSig = ", ".join(parameterNamesList)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
487
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
488 if methNamesSig:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
489 if qVersionTuple() >= (5, 0, 0):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
490 pythonSignature = \
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
491 "on_{0}_{1}(self, {2})".format(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
492 name,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
493 bytes(metaMethod.methodSignature())
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
494 .decode().split("(")[0],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
495 methNamesSig)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
496 else:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
497 pythonSignature = \
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
498 "on_{0}_{1}(self, {2})".format(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
499 name,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
500 metaMethod.signature()
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
501 .split("(")[0],
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
502 methNamesSig)
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1870
diff changeset
503 else:
6547
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
504 if qVersionTuple() >= (5, 0, 0):
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
505 pythonSignature = "on_{0}_{1}(self)"\
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
506 .format(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
507 name,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
508 bytes(metaMethod.methodSignature())
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
509 .decode().split("(")[0])
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
510 else:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
511 pythonSignature = "on_{0}_{1}(self)"\
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
512 .format(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
513 name,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
514 metaMethod.signature().split(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
515 "(")[0])
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
516 itm2.setData(pyqtSignature, pyqtSignatureRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
517 itm2.setData(pythonSignature, pythonSignatureRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
518 itm2.setData(returnType, returnTypeRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
519 itm2.setData(parameterTypesList,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
520 parameterTypesListRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
521 itm2.setData(parameterNamesList,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
522 parameterNamesListRole)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
523
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
524 itm2.setFlags(Qt.ItemFlags(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
525 Qt.ItemIsUserCheckable |
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
526 Qt.ItemIsEnabled |
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
527 Qt.ItemIsSelectable)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
528 )
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
529 itm2.setCheckState(Qt.Unchecked)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
530
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
531 self.slotsView.sortByColumn(0, Qt.AscendingOrder)
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
532 except (AttributeError, ImportError,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
533 xml.etree.ElementTree.ParseError) as err:
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
534 E5MessageBox.critical(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
535 self,
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
536 self.tr("uic error"),
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
537 self.tr(
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
538 """<p>There was an error loading the form <b>{0}</b>"""
77c817301ca1 CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6544
diff changeset
539 """.</p><p>{1}</p>""").format(self.formFile, str(err)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 def __generateCode(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 Private slot to generate the code as requested by the user.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 # first decide on extension
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 if self.filenameEdit.text().endswith(".py") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 self.filenameEdit.text().endswith(".pyw"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 self.__generatePythonCode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 elif self.filenameEdit.text().endswith(".rb"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 # second decide on project language
1137
1a37887aefa7 Fixed a little error in the code generation dialog.
detlev@die-offenbachs.de
parents: 1132
diff changeset
552 elif self.project.getProjectLanguage() in ["Python2", "Python3"]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 self.__generatePythonCode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 elif self.project.getProjectLanguage() == "Ruby":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 # assume Python (our global default)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 self.__generatePythonCode()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 def __generatePythonCode(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 Private slot to generate Python code as requested by the user.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 # init some variables
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 sourceImpl = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 appendAtIndex = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 indentStr = " "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 slotsCode = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 if self.__module is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 # new file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 try:
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
573 if self.project.getProjectLanguage() == "Python2":
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
574 if self.project.getProjectType() == "PySide":
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
575 tmplName = os.path.join(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
576 getConfig('ericCodeTemplatesDir'),
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
577 "impl_pyside.py2.tmpl")
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
578 elif self.project.getProjectType() == "PySide2":
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
579 tmplName = os.path.join(
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
580 getConfig('ericCodeTemplatesDir'),
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
581 "impl_pyside2.py2.tmpl")
2741
d0d7836d0c01 Added PyQt5 support to the project resources and translations viewers and the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2737
diff changeset
582 elif self.project.getProjectType() == "PyQt5":
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
583 tmplName = os.path.join(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
584 getConfig('ericCodeTemplatesDir'),
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
585 "impl_pyqt5.py2.tmpl")
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
586 else:
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
587 tmplName = os.path.join(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
588 getConfig('ericCodeTemplatesDir'),
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
589 "impl_pyqt.py2.tmpl")
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
590 else:
1862
b1498278335f Added dialog code generation capability for PySide and Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1844
diff changeset
591 if self.project.getProjectType() == "PySide":
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
592 tmplName = os.path.join(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
593 getConfig('ericCodeTemplatesDir'),
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
594 "impl_pyside.py.tmpl")
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
595 elif self.project.getProjectType() == "PySide2":
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
596 tmplName = os.path.join(
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
597 getConfig('ericCodeTemplatesDir'),
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
598 "impl_pyside2.py.tmpl")
3858
4f4684967fee Fixed a few little issues in eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
599 elif self.project.getProjectType() in [
4f4684967fee Fixed a few little issues in eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
600 "PyQt5", "E6Plugin"]:
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
601 tmplName = os.path.join(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
602 getConfig('ericCodeTemplatesDir'),
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
603 "impl_pyqt5.py.tmpl")
1862
b1498278335f Added dialog code generation capability for PySide and Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1844
diff changeset
604 else:
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
605 tmplName = os.path.join(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
606 getConfig('ericCodeTemplatesDir'),
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
607 "impl_pyqt.py.tmpl")
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
608 tmplFile = open(tmplName, 'r', encoding="utf-8")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 template = tmplFile.read()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 tmplFile.close()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
611 except IOError as why:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
612 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
613 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
614 self.tr("Code Generation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
615 self.tr(
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
616 """<p>Could not open the code template file"""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
617 """ "{0}".</p><p>Reason: {1}</p>""")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
618 .format(tmplName, str(why)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 objName = self.__objectName()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 if objName:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 template = template\
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
624 .replace(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
625 "$FORMFILE$",
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
626 os.path.splitext(os.path.basename(self.formFile))[0])\
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 .replace("$FORMCLASS$", objName)\
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 .replace("$CLASSNAME$", self.classNameCombo.currentText())\
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 .replace("$SUPERCLASS$", self.__className())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 sourceImpl = template.splitlines(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 appendAtIndex = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 # determine indent string
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 for line in sourceImpl:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 if line.lstrip().startswith("def __init__"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 indentStr = line.replace(line.lstrip(), "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 # extend existing file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 try:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
642 srcFile = open(self.srcFile, 'r', encoding="utf-8")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 sourceImpl = srcFile.readlines()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 srcFile.close()
245
de5c4effc747 Fixed some issues related to Python's universal newline support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 124
diff changeset
645 if not sourceImpl[-1].endswith("\n"):
427
6af5d12cfecb Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
646 sourceImpl[-1] = "{0}{1}".format(sourceImpl[-1], "\n")
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
647 except IOError as why:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
648 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
649 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
650 self.tr("Code Generation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
651 self.tr(
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
652 """<p>Could not open the source file "{0}".</p>"""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
653 """<p>Reason: {1}</p>""")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
654 .format(self.srcFile, str(why)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 cls = self.__module.classes[self.classNameCombo.currentText()]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 if cls.endlineno == len(sourceImpl) or cls.endlineno == -1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 appendAtIndex = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 # delete empty lines at end
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 while not sourceImpl[-1].strip():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 del sourceImpl[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 appendAtIndex = cls.endlineno - 1
1132
f8275b31dbe5 Fixed the dialog code creation code to respect PEP-8 rules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
665 while not sourceImpl[appendAtIndex].strip():
f8275b31dbe5 Fixed the dialog code creation code to respect PEP-8 rules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
666 appendAtIndex -= 1
f8275b31dbe5 Fixed the dialog code creation code to respect PEP-8 rules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
667 appendAtIndex += 1
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 # determine indent string
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
670 for line in sourceImpl[cls.lineno:cls.endlineno + 1]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 if line.lstrip().startswith("def __init__"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 indentStr = line.replace(line.lstrip(), "")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 # do the coding stuff
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
676 if self.project.getProjectLanguage() == "Python2":
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
677 if self.project.getProjectType() in ("PySide", "PySide2"):
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
678 pyqtSignatureFormat = '@Slot({0})'
2741
d0d7836d0c01 Added PyQt5 support to the project resources and translations viewers and the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2737
diff changeset
679 elif self.project.getProjectType() == "PyQt5":
d0d7836d0c01 Added PyQt5 support to the project resources and translations viewers and the code creation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2737
diff changeset
680 pyqtSignatureFormat = '@pyqtSlot({0})'
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
681 else:
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
682 pyqtSignatureFormat = '@pyqtSignature("{0}")'
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
683 else:
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
684 if self.project.getProjectType() in ("PySide", "PySide2"):
1862
b1498278335f Added dialog code generation capability for PySide and Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1844
diff changeset
685 pyqtSignatureFormat = '@Slot({0})'
b1498278335f Added dialog code generation capability for PySide and Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1844
diff changeset
686 else:
b1498278335f Added dialog code generation capability for PySide and Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1844
diff changeset
687 pyqtSignatureFormat = '@pyqtSlot({0})'
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 for row in range(self.slotsModel.rowCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
689 topItem = self.slotsModel.item(row)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 for childRow in range(topItem.rowCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691 child = topItem.child(childRow)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 if child.checkState() and \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 child.flags() & Qt.ItemFlags(Qt.ItemIsUserCheckable):
427
6af5d12cfecb Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
694 slotsCode.append('{0}\n'.format(indentStr))
1139
b18376d58832 Added dialog support for PySide.
detlev@die-offenbachs.de
parents: 1137
diff changeset
695 slotsCode.append('{0}{1}\n'.format(
1148
ddc482ded355 Corrected a PEP-8 related issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1139
diff changeset
696 indentStr,
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
697 pyqtSignatureFormat.format(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
698 child.data(pyqtSignatureRole))))
427
6af5d12cfecb Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
699 slotsCode.append('{0}def {1}:\n'.format(
6af5d12cfecb Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
700 indentStr, child.data(pythonSignatureRole)))
4485
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
701 indentStr2 = indentStr * 2
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
702 slotsCode.append('{0}"""\n'.format(indentStr2))
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
703 slotsCode.append(
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
704 '{0}Slot documentation goes here.\n'.format(
4485
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
705 indentStr2))
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
706 if child.data(returnTypeRole) or \
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
707 child.data(parameterTypesListRole):
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
708 slotsCode.append('{0}\n'.format(indentStr2))
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
709 if child.data(parameterTypesListRole):
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
710 for name, type_ in zip(
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
711 child.data(parameterNamesListRole),
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
712 child.data(parameterTypesListRole)):
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
713 slotsCode.append(
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
714 '{0}@param {1} DESCRIPTION\n'.format(
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
715 indentStr2, name))
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
716 slotsCode.append('{0}@type {1}\n'.format(
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
717 indentStr2, type_))
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
718 if child.data(returnTypeRole):
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
719 slotsCode.append(
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
720 '{0}@returns DESCRIPTION\n'.format(
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
721 indentStr2))
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
722 slotsCode.append('{0}@rtype {1}\n'.format(
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
723 indentStr2, child.data(returnTypeRole)))
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
724 slotsCode.append('{0}"""\n'.format(indentStr2))
427
6af5d12cfecb Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
725 slotsCode.append('{0}# {1}: not implemented yet\n'.format(
4485
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
726 indentStr2, "TODO"))
427
6af5d12cfecb Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 253
diff changeset
727 slotsCode.append('{0}raise NotImplementedError\n'.format(
4485
28743e3251ce Improved the dialog code generation dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4332
diff changeset
728 indentStr2))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 if appendAtIndex == -1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 sourceImpl.extend(slotsCode)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 sourceImpl[appendAtIndex:appendAtIndex] = slotsCode
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 # write the new code
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 try:
253
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
737 if self.project.useSystemEol():
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
738 newline = None
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
739 else:
3ccdf551bde7 Changed code to improve development on multiple platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 245
diff changeset
740 newline = self.project.getEolString()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
741 srcFile = open(self.filenameEdit.text(), 'w', encoding="utf-8",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
742 newline=newline)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 srcFile.write("".join(sourceImpl))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744 srcFile.close()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
745 except IOError as why:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
746 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2995
diff changeset
747 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
748 self.tr("Code Generation"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
749 self.tr("""<p>Could not write the source file "{0}".</p>"""
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
750 """<p>Reason: {1}</p>""")
3038
7fe9a53280bd Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
751 .format(self.filenameEdit.text(), str(why)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753
6
52e8c820d0dd Removed some superfluous unicode() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
754 self.project.appendFile(self.filenameEdit.text())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 @pyqtSlot(int)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 def on_classNameCombo_activated(self, index):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 Private slot to handle the activated signal of the classname combo.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 @param index index of the activated item (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
763 if (self.classNameCombo.currentText() ==
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
764 CreateDialogCodeDialog.Separator):
1869
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
765 self.okButton.setEnabled(False)
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
766 self.filterEdit.clear()
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
767 self.slotsModel.clear()
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
768 self.slotsModel.setHorizontalHeaderLabels([""])
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
769 else:
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
770 self.okButton.setEnabled(True)
3e34d5c362d9 Enhanced the dialog code generation dialog by presenting classes not directly derived from QWidget, QDialog, QMainWindow or QWizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1862
diff changeset
771 self.__updateSlotsModel()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 def on_filterEdit_textChanged(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 Private slot called, when thext of the filter edit has changed.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 @param text changed text (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 re = QRegExp(text, Qt.CaseInsensitive, QRegExp.RegExp2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 self.proxyModel.setFilterRegExp(re)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 def on_newButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 Private slot called to enter the data for a new dialog class.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 path, file = os.path.split(self.srcFile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 objName = self.__objectName()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 if objName:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 dlg = NewDialogClassDialog(objName, file, path, self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791 if dlg.exec_() == QDialog.Accepted:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 className, fileName = dlg.getData()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 self.classNameCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 self.classNameCombo.addItem(className)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 self.srcFile = fileName
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 self.filenameEdit.setText(self.srcFile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 self.__module = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 self.okButton.setEnabled(self.classNameCombo.count() > 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 Private slot to handle the buttonBox clicked signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805
2995
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
806 @param button reference to the button that was clicked
63d874899b8b Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2741
diff changeset
807 (QAbstractButton)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 if button == self.okButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 self.__generateCode()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
811 self.accept()

eric ide

mercurial