src/eric7/Plugins/PluginWizardSetup.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
39 39
40 class SetupWizard(QObject): 40 class SetupWizard(QObject):
41 """ 41 """
42 Class implementing the setup.py wizard plug-in. 42 Class implementing the setup.py wizard plug-in.
43 """ 43 """
44
44 def __init__(self, ui): 45 def __init__(self, ui):
45 """ 46 """
46 Constructor 47 Constructor
47 48
48 @param ui reference to the user interface object 49 @param ui reference to the user interface object
49 @type UI.UserInterface 50 @type UI.UserInterface
50 """ 51 """
51 super().__init__(ui) 52 super().__init__(ui)
52 self.__ui = ui 53 self.__ui = ui
53 self.__actions = [] 54 self.__actions = []
54 55
55 def activate(self): 56 def activate(self):
56 """ 57 """
57 Public method to activate this plug-in. 58 Public method to activate this plug-in.
58 59
59 @return tuple of None and activation status 60 @return tuple of None and activation status
60 @rtype tuple of (None, boolean) 61 @rtype tuple of (None, boolean)
61 """ 62 """
62 self.__initActions() 63 self.__initActions()
63 self.__initMenu() 64 self.__initMenu()
64 65
65 return None, True 66 return None, True
66 67
67 def deactivate(self): 68 def deactivate(self):
68 """ 69 """
69 Public method to deactivate this plug-in. 70 Public method to deactivate this plug-in.
70 """ 71 """
71 menu = self.__ui.getMenu("wizards") 72 menu = self.__ui.getMenu("wizards")
72 if menu: 73 if menu:
73 for act in self.__actions: 74 for act in self.__actions:
74 menu.removeAction(act) 75 menu.removeAction(act)
75 self.__ui.removeEricActions(self.__actions, 'wizards') 76 self.__ui.removeEricActions(self.__actions, "wizards")
76 77
77 def __initActions(self): 78 def __initActions(self):
78 """ 79 """
79 Private method to initialize the actions. 80 Private method to initialize the actions.
80 """ 81 """
81 # 1. action for 'setup.py' creation 82 # 1. action for 'setup.py' creation
82 act = EricAction( 83 act = EricAction(
83 self.tr('setup.py Wizard'), 84 self.tr("setup.py Wizard"),
84 self.tr('setup.py Wizard...'), 85 self.tr("setup.py Wizard..."),
85 0, 0, self, 86 0,
86 'wizards_setup_py') 87 0,
87 act.setStatusTip(self.tr('setup.py Wizard')) 88 self,
88 act.setWhatsThis(self.tr( 89 "wizards_setup_py",
89 """<b>setup.py Wizard</b>""" 90 )
90 """<p>This wizard opens a dialog for entering all the parameters""" 91 act.setStatusTip(self.tr("setup.py Wizard"))
91 """ needed to create the basic contents of a setup.py file. The""" 92 act.setWhatsThis(
92 """ generated code is inserted at the current cursor position.""" 93 self.tr(
93 """</p>""" 94 """<b>setup.py Wizard</b>"""
94 )) 95 """<p>This wizard opens a dialog for entering all the parameters"""
96 """ needed to create the basic contents of a setup.py file. The"""
97 """ generated code is inserted at the current cursor position."""
98 """</p>"""
99 )
100 )
95 act.triggered.connect(functools.partial(self.__handle, "setup.py")) 101 act.triggered.connect(functools.partial(self.__handle, "setup.py"))
96 self.__actions.append(act) 102 self.__actions.append(act)
97 103
98 # 2. action for 'setup.cfg' creation 104 # 2. action for 'setup.cfg' creation
99 act = EricAction( 105 act = EricAction(
100 self.tr('setup.cfg Wizard'), 106 self.tr("setup.cfg Wizard"),
101 self.tr('setup.cfg Wizard...'), 107 self.tr("setup.cfg Wizard..."),
102 0, 0, self, 108 0,
103 'wizards_setup_cfg') 109 0,
104 act.setStatusTip(self.tr('setup.cfg Wizard')) 110 self,
105 act.setWhatsThis(self.tr( 111 "wizards_setup_cfg",
106 """<b>setup.cfg Wizard</b>""" 112 )
107 """<p>This wizard opens a dialog for entering all the parameters""" 113 act.setStatusTip(self.tr("setup.cfg Wizard"))
108 """ needed to create the basic contents of a setup.cfg file. The""" 114 act.setWhatsThis(
109 """ generated code is inserted at the current cursor position.""" 115 self.tr(
110 """</p>""" 116 """<b>setup.cfg Wizard</b>"""
111 )) 117 """<p>This wizard opens a dialog for entering all the parameters"""
118 """ needed to create the basic contents of a setup.cfg file. The"""
119 """ generated code is inserted at the current cursor position."""
120 """</p>"""
121 )
122 )
112 act.triggered.connect(functools.partial(self.__handle, "setup.cfg")) 123 act.triggered.connect(functools.partial(self.__handle, "setup.cfg"))
113 self.__actions.append(act) 124 self.__actions.append(act)
114 125
115 # 3. action for 'pyproject.toml' creation 126 # 3. action for 'pyproject.toml' creation
116 act = EricAction( 127 act = EricAction(
117 self.tr('pyproject.toml Wizard'), 128 self.tr("pyproject.toml Wizard"),
118 self.tr('pyproject.toml Wizard...'), 129 self.tr("pyproject.toml Wizard..."),
119 0, 0, self, 130 0,
120 'wizards_pyproject_toml') 131 0,
121 act.setStatusTip(self.tr('pyproject.toml Wizard')) 132 self,
122 act.setWhatsThis(self.tr( 133 "wizards_pyproject_toml",
123 """<b>pyproject.toml Wizard</b>""" 134 )
124 """<p>This wizard opens a dialog for entering all the parameters""" 135 act.setStatusTip(self.tr("pyproject.toml Wizard"))
125 """ needed to create the basic contents of a pyproject.toml file. The""" 136 act.setWhatsThis(
126 """ generated code is inserted at the current cursor position.""" 137 self.tr(
127 """</p>""" 138 """<b>pyproject.toml Wizard</b>"""
128 )) 139 """<p>This wizard opens a dialog for entering all the parameters"""
140 """ needed to create the basic contents of a pyproject.toml file. The"""
141 """ generated code is inserted at the current cursor position."""
142 """</p>"""
143 )
144 )
129 act.triggered.connect(functools.partial(self.__handle, "pyproject.toml")) 145 act.triggered.connect(functools.partial(self.__handle, "pyproject.toml"))
130 self.__actions.append(act) 146 self.__actions.append(act)
131 147
132 self.__ui.addEricActions(self.__actions, 'wizards') 148 self.__ui.addEricActions(self.__actions, "wizards")
133 149
134 def __initMenu(self): 150 def __initMenu(self):
135 """ 151 """
136 Private method to add the actions to the right menu. 152 Private method to add the actions to the right menu.
137 """ 153 """
138 menu = self.__ui.getMenu("wizards") 154 menu = self.__ui.getMenu("wizards")
139 if menu: 155 if menu:
140 menu.addActions(self.__actions) 156 menu.addActions(self.__actions)
141 157
142 def __handle(self, category): 158 def __handle(self, category):
143 """ 159 """
144 Private method to handle the wizards action. 160 Private method to handle the wizards action.
145 161
146 @param category category of setup file to create 162 @param category category of setup file to create
147 @type str 163 @type str
148 """ 164 """
149 from WizardPlugins.SetupWizard.SetupWizardDialog import ( 165 from WizardPlugins.SetupWizard.SetupWizardDialog import SetupWizardDialog
150 SetupWizardDialog 166
151 )
152
153 editor = ericApp().getObject("ViewManager").activeWindow() 167 editor = ericApp().getObject("ViewManager").activeWindow()
154 168
155 if editor is None: 169 if editor is None:
156 EricMessageBox.critical( 170 EricMessageBox.critical(
157 self.__ui, 171 self.__ui,
158 self.tr('No current editor'), 172 self.tr("No current editor"),
159 self.tr('Please open or create a file first.')) 173 self.tr("Please open or create a file first."),
174 )
160 else: 175 else:
161 dlg = SetupWizardDialog(category, editor, self.__ui) 176 dlg = SetupWizardDialog(category, editor, self.__ui)
162 dlg.show() 177 dlg.show()
163 178
179
164 # 180 #
165 # eflag: noqa = M801 181 # eflag: noqa = M801

eric ide

mercurial