Plugins/PluginVirtualenvInterface.py

changeset 6014
d3375a0a3240
child 6048
82ad8ec9548c
equal deleted inserted replaced
6013:333ab48b89a7 6014:d3375a0a3240
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2017 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the virtualenv interface plug-in.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import QObject
13 from PyQt5.QtWidgets import QDialog
14
15 from E5Gui.E5Application import e5App
16 from E5Gui.E5Action import E5Action
17
18 import UI.Info
19
20 # Start-of-Header
21 name = "virtualenv Configurator Plug-in"
22 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
23 autoactivate = True
24 deactivateable = True
25 version = UI.Info.VersionOnly
26 className = "VirtualenvInterfacePlugin"
27 packageName = "__core__"
28 shortDescription = "Configurator for Python virtual environments."
29 longDescription = \
30 """This plug-in implements a configuration interface to create Python""" \
31 """ virtual environments using 'virtualenv' or 'pyvenv."""
32 needsRestart = False
33 pyqtApi = 2
34 python2Compatible = True
35 # End-of-Header
36
37 error = ""
38
39
40 class VirtualenvInterfacePlugin(QObject):
41 """
42 Class implementing the virtualenv wizard plug-in.
43 """
44 def __init__(self, ui):
45 """
46 Constructor
47
48 @param ui reference to the user interface object (UI.UserInterface)
49 """
50 super(VirtualenvInterfacePlugin, self).__init__(ui)
51 self.__ui = ui
52 self.__action = None
53
54 self.__initAction()
55
56 def activate(self):
57 """
58 Public method to activate this plug-in.
59
60 @return tuple of None and activation status (boolean)
61 """
62 e5App().getObject("ToolbarManager").addAction(self.__action, "Tools")
63
64 menu = self.__ui.getMenu("extras")
65 menu.addAction(self.__action)
66
67 return None, True
68
69 def deactivate(self):
70 """
71 Public method to deactivate this plug-in.
72 """
73 e5App().getObject("ToolbarManager").removeAction(self.__action)
74
75 menu = self.__ui.getMenu("extras")
76 menu.removeAction(self.__action)
77
78 def __initAction(self):
79 """
80 Private method to initialize the action.
81 """
82 self.__action = E5Action(
83 self.tr('Virtualenv Configurator'),
84 self.tr('&Virtualenv Configurator...'),
85 0, 0, self,
86 'virtualenv_configurator')
87 self.__action.setStatusTip(self.tr('Virtualenv Configurator'))
88 self.__action.setWhatsThis(self.tr(
89 """<b>Virtualenv Configurator</b>"""
90 """<p>This opens a dialog for entering all the parameters"""
91 """ needed to create a Python virtual environment using"""
92 """ virtualenv or pyvenv.</p>"""
93 ))
94 self.__action.triggered.connect(self.__handle)
95
96 def __handle(self):
97 """
98 Private method to handle the creation of a virtual environment.
99 """
100 from UiExtensionPlugins.VirtualenvInterface\
101 .VirtualenvConfigurationDialog import VirtualenvConfigurationDialog
102
103 dlg = VirtualenvConfigurationDialog()
104 if dlg.exec_() == QDialog.Accepted:
105 (pyvenv, args, openTarget, createLog, createScript, targetDir,
106 interpreter) = dlg.getData()
107
108 # now do the call
109 from UiExtensionPlugins.VirtualenvInterface.VirtualenvExecDialog \
110 import VirtualenvExecDialog
111 dia = VirtualenvExecDialog(pyvenv, targetDir, openTarget,
112 createLog, createScript, interpreter)
113 dia.show()
114 dia.start(args)
115 dia.exec_()
116
117 #
118 # eflag: noqa = M801

eric ide

mercurial