Plugins/UiExtensionPlugins/PipInterface/PipPackagesInputDialog.py

changeset 6011
e6af0dcfbb35
child 6047
39586a2de99d
equal deleted inserted replaced
6010:7ef7d47a0ad5 6011:e6af0dcfbb35
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2015 - 2017 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter package specifications.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_PipPackagesInputDialog import Ui_PipPackagesInputDialog
16
17
18 class PipPackagesInputDialog(QDialog, Ui_PipPackagesInputDialog):
19 """
20 Class documentation goes here.
21 """
22 def __init__(self, plugin, title, parent=None):
23 """
24 Constructor
25
26 @param plugin reference to the plugin object (ToolPipPlugin)
27 @param title dialog title (string)
28 @param parent reference to the parent widget (QWidget)
29 """
30 super(PipPackagesInputDialog, self).__init__(parent)
31 self.setupUi(self)
32
33 self.setWindowTitle(title)
34
35 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
36
37 self.__default = self.tr("<Default>")
38 pipExecutables = sorted(plugin.getPreferences("PipExecutables"))
39 self.pipComboBox.addItem(self.__default)
40 self.pipComboBox.addItems(pipExecutables)
41
42 msh = self.minimumSizeHint()
43 self.resize(max(self.width(), msh.width()), msh.height())
44
45 @pyqtSlot(str)
46 def on_packagesEdit_textChanged(self, txt):
47 """
48 Private slot handling entering package names.
49
50 @param txt name of the requirements file (string)
51 """
52 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt))
53
54 def getData(self):
55 """
56 Public method to get the entered data.
57
58 @return tuple with the pip command (string) and the list of
59 package specifications (list of string)
60 """
61 command = self.pipComboBox.currentText()
62 if command == self.__default:
63 command = ""
64 packages = [p.strip() for p in self.packagesEdit.text().split()]
65
66 return command, packages

eric ide

mercurial