eric6/Plugins/PluginWizardSetup.py

Mon, 15 Apr 2019 19:53:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 15 Apr 2019 19:53:29 +0200
branch
setup.py
changeset 6949
a5255f1ba3f0
parent 6942
2602857055c5
child 7199
c71bd6f21748
permissions
-rw-r--r--

setup.py: continued implementing support for setup.py.

6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2013 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the setup.py wizard plug-in.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import QObject
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QDialog
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from E5Gui.E5Application import e5App
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui.E5Action import E5Action
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from E5Gui import E5MessageBox
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import UI.Info
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 # Start-of-Header
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 name = "setup.py Wizard Plug-in"
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 autoactivate = True
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 deactivateable = True
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 version = UI.Info.VersionOnly
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 className = "SetupWizard"
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 packageName = "__core__"
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 shortDescription = "Wizard for the creation of a setup.py file."
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 longDescription = \
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """This plug-in implements a wizard to generate code for""" \
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """ a setup.py file. It supports the 'distutils' and 'setuptools'""" \
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """ variants."""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 needsRestart = False
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 pyqtApi = 2
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 python2Compatible = True
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 # End-of-Header
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 error = ""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 class SetupWizard(QObject):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 Class implementing the setup.py wizard plug-in.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 def __init__(self, ui):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 Constructor
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @param ui reference to the user interface object (UI.UserInterface)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 super(SetupWizard, self).__init__(ui)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.__ui = ui
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__action = None
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 def __initialize(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 Private slot to (re)initialize the plug-in.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__act = None
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def activate(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 Public method to activate this plug-in.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @return tuple of None and activation status (boolean)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__initAction()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__initMenu()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 return None, True
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 def deactivate(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 Public method to deactivate this plug-in.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 menu = self.__ui.getMenu("wizards")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 if menu:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 menu.removeAction(self.__action)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__ui.removeE5Actions([self.__action], 'wizards')
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 def __initAction(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 Private method to initialize the action.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__action = E5Action(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.tr('setup.py Wizard'),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.tr('&setup.py Wizard...'),
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 0, 0, self,
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 'wizards_setup_py')
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__action.setStatusTip(self.tr('setup.py Wizard'))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__action.setWhatsThis(self.tr(
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """<b>setup.py Wizard</b>"""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """<p>This wizard opens a dialog for entering all the parameters"""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """ needed to create the basic contents of a setup.py file. The"""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """ generated code is inserted at the current cursor position."""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """</p>"""
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 ))
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.__action.triggered.connect(self.__handle)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__ui.addE5Actions([self.__action], 'wizards')
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 def __initMenu(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 Private method to add the actions to the right menu.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 menu = self.__ui.getMenu("wizards")
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 if menu:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 menu.addAction(self.__action)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 def __callForm(self, editor):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 Private method to display a dialog and get the code.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @param editor reference to the current editor
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @return the generated code (string)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 from WizardPlugins.SetupWizard.SetupWizardDialog import \
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 SetupWizardDialog
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 dlg = SetupWizardDialog(None)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 if dlg.exec_() == QDialog.Accepted:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 line, index = editor.getCursorPosition()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 indLevel = editor.indentation(line) // editor.indentationWidth()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if editor.indentationsUseTabs():
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 indString = '\t'
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 indString = editor.indentationWidth() * ' '
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 return (dlg.getCode(indLevel, indString), True)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 return (None, False)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 def __handle(self):
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 Private method to handle the wizards action.
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 editor = e5App().getObject("ViewManager").activeWindow()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 if editor is None:
6735
31e263d49c04 Fixed some code style issues detected by the updated style checker (over-indented lines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
139 E5MessageBox.critical(
31e263d49c04 Fixed some code style issues detected by the updated style checker (over-indented lines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
140 self.__ui,
31e263d49c04 Fixed some code style issues detected by the updated style checker (over-indented lines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
141 self.tr('No current editor'),
31e263d49c04 Fixed some code style issues detected by the updated style checker (over-indented lines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
142 self.tr('Please open or create a file first.'))
6015
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 else:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 code, ok = self.__callForm(editor)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 if ok:
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 line, index = editor.getCursorPosition()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 # It should be done on this way to allow undo
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 editor.beginUndoAction()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 editor.insertAt(code, line, index)
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 editor.endUndoAction()
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 #
26fc8e08f4ac Added the setup.py wizard plug-in to the core plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 # eflag: noqa = M801

eric ide

mercurial