eric6/CondaInterface/CondaPackagesWidget.py

Sat, 31 Aug 2019 12:58:11 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Aug 2019 12:58:11 +0200
branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 7107
fccf607a5326
child 7229
53054eb5b15a
permissions
-rw-r--r--

Started removing runtime support for Python2 and PyQt4.

6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the conda packages management widget.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
12 import os
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
13
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt5.QtCore import pyqtSlot, Qt
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
15 from PyQt5.QtGui import QCursor
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
16 from PyQt5.QtWidgets import QWidget, QToolButton, QMenu, QTreeWidgetItem, \
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
17 QApplication, QLineEdit, QDialog
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
19 from E5Gui import E5FileDialog, E5MessageBox, E5TextInputDialog
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
20 from E5Gui.E5Application import e5App
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
21
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 from .Ui_CondaPackagesWidget import Ui_CondaPackagesWidget
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import UI.PixmapCache
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
26 import CondaInterface
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
27
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 class CondaPackagesWidget(QWidget, Ui_CondaPackagesWidget):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Class implementing the conda packages management widget.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
33 # Role definition of packages list
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
34 PackageVersionRole = Qt.UserRole + 1
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
35 PackageBuildRole = Qt.UserRole + 2
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
36
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
37 # Role definitions of search results list
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
38 PackageDetailedDataRole = Qt.UserRole + 1
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
39
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
40 def __init__(self, conda, parent=None):
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Constructor
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
44 @param conda reference to the conda interface
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
45 @type Conda
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @param parent reference to the parent widget
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @type QWidget
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 super(CondaPackagesWidget, self).__init__(parent)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.setupUi(self)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
52 self.__conda = conda
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
53
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
54 if not CondaInterface.isCondaAvailable():
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
55 self.baseWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
56 self.searchWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
57
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
58 else:
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
59 self.notAvailableWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
60
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
61 self.__initCondaInterface()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
62
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
63 def __initCondaInterface(self):
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
64 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
65 Private method to initialize the conda interface elements.
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
66 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
67 self.statusLabel.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
68
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.condaMenuButton.setObjectName(
7107
fccf607a5326 CondaPackagesWidget, PipPackagesWidget: fixed a little issue related to naming some Qt objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
70 "conda_supermenu_button")
6796
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
71 self.condaMenuButton.setIcon(UI.PixmapCache.getIcon("superMenu"))
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.condaMenuButton.setToolTip(self.tr("Conda Menu"))
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.condaMenuButton.setPopupMode(QToolButton.InstantPopup)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.condaMenuButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.condaMenuButton.setFocusPolicy(Qt.NoFocus)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.condaMenuButton.setAutoRaise(True)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.condaMenuButton.setShowMenuInside(True)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
6796
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
79 self.refreshButton.setIcon(UI.PixmapCache.getIcon("reload"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
80 self.upgradeButton.setIcon(UI.PixmapCache.getIcon("1uparrow"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
81 self.upgradeAllButton.setIcon(UI.PixmapCache.getIcon("2uparrow"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
82 self.uninstallButton.setIcon(UI.PixmapCache.getIcon("minus"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
83 self.searchToggleButton.setIcon(UI.PixmapCache.getIcon("find"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
84 self.searchButton.setIcon(UI.PixmapCache.getIcon("findNext"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
85 self.installButton.setIcon(UI.PixmapCache.getIcon("plus"))
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
86 self.showDetailsButton.setIcon(UI.PixmapCache.getIcon("info"))
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
87
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
88 if CondaInterface.condaVersion() >= (4, 4, 0):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
89 self.searchOptionsWidget.hide()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
90 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
91 self.platformComboBox.addItems(sorted([
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
92 "", "win-32", "win-64", "osx-64", "linux-32", "linux-64",
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
93 ]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
94
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__initCondaMenu()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__populateEnvironments()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
97 self.__updateActionButtons()
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
98
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
99 self.searchWidget.hide()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
100
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
101 self.__conda.condaEnvironmentCreated.connect(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
102 self.on_refreshButton_clicked)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
103 self.__conda.condaEnvironmentRemoved.connect(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
104 self.on_refreshButton_clicked)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def __populateEnvironments(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 Private method to get a list of environments and populate the selector.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
110 environments = [("", "")] + sorted(
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
111 self.__conda.getCondaEnvironmentsList())
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
112 for environment in environments:
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
113 self.environmentsComboBox.addItem(environment[0], environment[1])
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 def __initCondaMenu(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 Private method to create the super menu and attach it to the super
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 menu button.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.__condaMenu = QMenu(self)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
121 self.__envActs = []
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
122
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
123 self.__cleanMenu = QMenu(self.tr("Clean"), self)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
124 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
125 self.tr("All"), lambda: self.__conda.cleanConda("all"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
126 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
127 self.tr("Cache"), lambda: self.__conda.cleanConda("index-cache"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
128 self.__cleanMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
129 self.tr("Lock Files"),
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
130 lambda: self.__conda.cleanConda("lock"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
131 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
132 self.tr("Packages"), lambda: self.__conda.cleanConda("packages"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
133 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
134 self.tr("Tarballs"), lambda: self.__conda.cleanConda("tarballs"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
135
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
136 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
137 self.tr("About Conda..."), self.__aboutConda)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
138 self.__condaMenu.addSeparator()
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
139 self.__condaMenu.addAction(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
140 self.tr("Update Conda"), self.__conda.updateConda)
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
141 self.__condaMenu.addSeparator()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
142 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
143 self.tr("Install Packages"), self.__installPackages))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
144 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
145 self.tr("Install Requirements"), self.__installRequirements))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
146 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
147 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
148 self.tr("Generate Requirements"), self.__generateRequirements))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
149 self.__condaMenu.addSeparator()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
150 self.__condaMenu.addAction(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
151 self.tr("Create Environment from Requirements"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
152 self.__createEnvironment)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
153 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
154 self.tr("Clone Environment"), self.__cloneEnvironment))
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
155 self.__deleteEnvAct = self.__condaMenu.addAction(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
156 self.tr("Delete Environment"), self.__deleteEnvironment)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
157 self.__condaMenu.addSeparator()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
158 self.__condaMenu.addMenu(self.__cleanMenu)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
159 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
160 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
161 self.tr("Edit User Configuration..."),
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
162 self.__editUserConfiguration)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
163 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
164 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
165 self.tr("Configure..."), self.__condaConfigure)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 self.condaMenuButton.setMenu(self.__condaMenu)
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
168
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
169 self.__condaMenu.aboutToShow.connect(self.__aboutToShowCondaMenu)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
171 def __selectedUpdateableItems(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
172 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
173 Private method to get a list of selected items that can be updated.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
174
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
175 @return list of selected items that can be updated
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
176 @rtype list of QTreeWidgetItem
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
177 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
178 return [
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
179 itm for itm in self.packagesList.selectedItems()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
180 if bool(itm.text(2))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
181 ]
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
182
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
183 def __allUpdateableItems(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
184 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
185 Private method to get a list of all items that can be updated.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
186
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
187 @return list of all items that can be updated
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
188 @rtype list of QTreeWidgetItem
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
190 updateableItems = []
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
191 for index in range(self.packagesList.topLevelItemCount()):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
192 itm = self.packagesList.topLevelItem(index)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
193 if itm.text(2):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
194 updateableItems.append(itm)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
196 return updateableItems
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
197
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
198 def __updateActionButtons(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
199 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
200 Private method to set the state of the action buttons.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
201 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
202 self.upgradeButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
203 bool(self.__selectedUpdateableItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
204 self.uninstallButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
205 bool(self.packagesList.selectedItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
206 self.upgradeAllButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
207 bool(self.__allUpdateableItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
208
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
209 @pyqtSlot(int)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
210 def on_environmentsComboBox_currentIndexChanged(self, index):
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
211 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
212 Private slot handling the selection of a conda environment.
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
213
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
214 @param index index of the selected conda environment
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
215 @type int
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
217 self.packagesList.clear()
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
218 prefix = self.environmentsComboBox.itemData(index)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
219 if prefix:
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
220 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
221 self.statusLabel.show()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
222 self.statusLabel.setText(self.tr("Getting installed packages..."))
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
223 QApplication.processEvents()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
224
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
225 # 1. populate with installed packages
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
226 self.packagesList.setUpdatesEnabled(False)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
227 installedPackages = \
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
228 self.__conda.getInstalledPackages(prefix=prefix)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
229 for package, version, build in installedPackages:
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
230 itm = QTreeWidgetItem(self.packagesList, [package, version])
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
231 itm.setData(1, self.PackageVersionRole, version)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
232 itm.setData(1, self.PackageBuildRole, build)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
233 self.packagesList.setUpdatesEnabled(True)
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
234 self.statusLabel.setText(self.tr("Getting outdated packages..."))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
235 QApplication.processEvents()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
236
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
237 # 2. update with update information
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
238 self.packagesList.setUpdatesEnabled(False)
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
239 updateablePackages = \
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
240 self.__conda.getUpdateablePackages(prefix=prefix)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
241 for package, version, build in updateablePackages:
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
242 items = self.packagesList.findItems(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
243 package, Qt.MatchExactly | Qt.MatchCaseSensitive)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
244 if items:
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
245 itm = items[0]
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
246 itm.setText(2, version)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
247 itm.setData(2, self.PackageVersionRole, version)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
248 itm.setData(2, self.PackageBuildRole, build)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
249 if itm.data(1, self.PackageVersionRole) == version:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
250 # build must be different, show in version display
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
251 itm.setText(1, self.tr("{0} (Build: {1})").format(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
252 itm.data(1, self.PackageVersionRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
253 itm.data(1, self.PackageBuildRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
254 ))
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
255 itm.setText(2, self.tr("{0} (Build: {1})").format(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
256 itm.data(2, self.PackageVersionRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
257 itm.data(2, self.PackageBuildRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
258 ))
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
259
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
260 self.packagesList.sortItems(0, Qt.AscendingOrder)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
261 for col in range(self.packagesList.columnCount()):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
262 self.packagesList.resizeColumnToContents(col)
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
263 self.packagesList.setUpdatesEnabled(True)
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
264 QApplication.restoreOverrideCursor()
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
265 self.statusLabel.hide()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
266
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
267 self.__updateActionButtons()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
268 self.__updateSearchActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 def on_packagesList_itemSelectionChanged(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
273 Private slot to handle the selection of some items..
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
275 self.__updateActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 def on_refreshButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
280 Private slot to refresh the display.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
282 currentEnvironment = self.environmentsComboBox.currentText()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
283 self.environmentsComboBox.clear()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
284 self.packagesList.clear()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
285
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
286 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
287 QApplication.processEvents()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
288
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
289 self.__populateEnvironments()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
290
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
291 index = self.environmentsComboBox.findText(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
292 currentEnvironment, Qt.MatchExactly | Qt.MatchCaseSensitive)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
293 if index != -1:
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
294 self.environmentsComboBox.setCurrentIndex(index)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
295
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
296 QApplication.restoreOverrideCursor()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
297 self.__updateActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 def on_upgradeButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
302 Private slot to upgrade selected packages of the selected environment.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
304 packages = [itm.text(0) for itm in self.__selectedUpdateableItems()]
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
305 if packages:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
306 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
307 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
308 ok = self.__conda.updatePackages(packages, prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
309 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
310 self.on_refreshButton_clicked()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 def on_upgradeAllButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
315 Private slot to upgrade all packages of the selected environment.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
317 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
318 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
319 ok = self.__conda.updateAllPackages(prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
320 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
321 self.on_refreshButton_clicked()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 def on_uninstallButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
326 Private slot to remove selected packages of the selected environment.
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
328 packages = [itm.text(0) for itm in self.packagesList.selectedItems()]
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
329 if packages:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
330 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
331 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
332 ok = self.__conda.uninstallPackages(packages, prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
333 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
334 self.on_refreshButton_clicked()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
335
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
336 #######################################################################
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
337 ## Search widget related methods below
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
338 #######################################################################
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
339
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
340 def __updateSearchActionButtons(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
341 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
342 Private method to update the action button states of the search widget.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
343 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
344 enable = len(self.searchResultList.selectedItems()) == 1
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
345 self.installButton.setEnabled(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
346 enable and self.environmentsComboBox.currentIndex() > 0)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
347 self.showDetailsButton.setEnabled(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
348 enable and bool(self.searchResultList.selectedItems()[0].parent()))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
349
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
350 def __doSearch(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
351 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
352 Private method to search for packages.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
353 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
354 self.searchResultList.clear()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
355 pattern = self.searchEdit.text()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
356 if pattern:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
357 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
358 QApplication.processEvents()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
359
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
360 if CondaInterface.condaVersion() >= (4, 4, 0):
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
361 prefix = ""
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
362 else:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
363 prefix = self.environmentsComboBox.itemData(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
364 self.environmentsComboBox.currentIndex())
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
365 ok, result = self.__conda.searchPackages(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
366 pattern,
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
367 fullNameOnly=self.fullNameButton.isChecked(),
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
368 packageSpec=self.packageSpecButton.isChecked(),
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
369 platform=self.platformComboBox.currentText(),
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
370 prefix=prefix,
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
371 )
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
372
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
373 if result:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
374 if ok:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
375 self.searchResultList.setUpdatesEnabled(False)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
376 for package in result:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
377 itm = QTreeWidgetItem(self.searchResultList, [package])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
378 itm.setExpanded(False)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
379 for detail in result[package]:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
380 version = detail["version"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
381 build = detail["build"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
382 if "subdir" in detail:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
383 platform = detail["subdir"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
384 elif "platform" in detail:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
385 platform = detail["platform"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
386 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
387 platform = ""
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
388 citm = QTreeWidgetItem(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
389 itm, ["", version, build, platform])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
390 citm.setData(0, self.PackageDetailedDataRole,
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
391 detail)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
392
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
393 self.searchResultList.sortItems(0, Qt.AscendingOrder)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
394 self.searchResultList.resizeColumnToContents(0)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
395 self.searchResultList.setUpdatesEnabled(True)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
396 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
397 QApplication.restoreOverrideCursor()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
398 try:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
399 message = result["message"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
400 except KeyError:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
401 message = result["error"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
402 E5MessageBox.warning(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
403 self,
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
404 self.tr("Conda Search Package Error"),
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
405 message)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
406 QApplication.restoreOverrideCursor()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
407
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
408 def __showDetails(self, item):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
409 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
410 Private method to show a dialog with details about a package item.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
411
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
412 @param item reference to the package item
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
413 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
414 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
415 details = item.data(0, self.PackageDetailedDataRole)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
416 if details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
417 from .CondaPackageDetailsWidget import CondaPackageDetailsDialog
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
418 dlg = CondaPackageDetailsDialog(details, self)
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
419 dlg.exec_()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
420
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
421 @pyqtSlot(str)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
422 def on_searchEdit_textChanged(self, txt):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
423 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
424 Private slot handling changes of the entered search specification.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
425
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
426 @param txt current search entry
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
427 @type str
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
428 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
429 self.searchButton.setEnabled(bool(txt))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
430
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
431 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
432 def on_searchEdit_returnPressed(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
433 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
434 Private slot handling the user pressing the Return button in the
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
435 search edit.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
436 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
437 self.__doSearch()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
438
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
439 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
440 def on_searchButton_clicked(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
441 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
442 Private slot handling the press of the search button.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
443 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
444 self.__doSearch()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
445
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
446 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
447 def on_installButton_clicked(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
448 """
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
449 Private slot to install a selected package.
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
450 """
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
451 if len(self.searchResultList.selectedItems()) == 1:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
452 item = self.searchResultList.selectedItems()[0]
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
453 if item.parent() is None:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
454 # it is just the package item
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
455 package = item.text(0)
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
456 else:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
457 # item with version and build
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
458 package = "{0}={1}={2}".format(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
459 item.parent().text(0),
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
460 item.text(1),
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
461 item.text(2),
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
462 )
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
463
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
464 prefix = self.environmentsComboBox.itemData(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
465 self.environmentsComboBox.currentIndex())
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
466 ok = self.__conda.installPackages([package], prefix=prefix)
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
467 if ok:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
468 self.on_refreshButton_clicked()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
469
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
470 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
471 def on_showDetailsButton_clicked(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
472 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
473 Private slot handling the 'Show Details' button.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
474 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
475 item = self.searchResultList.selectedItems()[0]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
476 self.__showDetails(item)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
477
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
478 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
479 def on_searchResultList_itemSelectionChanged(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
480 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
481 Private slot handling a change of selected search results.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
482 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
483 self.__updateSearchActionButtons()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
484
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
485 @pyqtSlot(QTreeWidgetItem)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
486 def on_searchResultList_itemExpanded(self, item):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
487 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
488 Private slot handling the expansion of an item.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
489
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
490 @param item reference to the expanded item
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
491 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
492 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
493 for col in range(1, self.searchResultList.columnCount()):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
494 self.searchResultList.resizeColumnToContents(col)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
495
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
496 @pyqtSlot(QTreeWidgetItem, int)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
497 def on_searchResultList_itemDoubleClicked(self, item, column):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
498 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
499 Private slot handling a double click of an item.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
500
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
501 @param item reference to the item that was double clicked
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
502 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
503 @param column column of the double click
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
504 @type int
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
505 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
506 if item.parent() is not None:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
507 self.__showDetails(item)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
508
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
509 @pyqtSlot(bool)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
510 def on_searchToggleButton_toggled(self, checked):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
511 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
512 Private slot to togle the search widget.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
513
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
514 @param checked state of the search widget button
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
515 @type bool
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
516 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
517 self.searchWidget.setVisible(checked)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
518
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
519 if checked:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
520 self.searchEdit.setFocus(Qt.OtherFocusReason)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
521 self.searchEdit.selectAll()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
522
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
523 self.__updateSearchActionButtons()
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
524
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
525 #######################################################################
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
526 ## Menu related methods below
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
527 #######################################################################
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
528
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
529 @pyqtSlot()
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
530 def __aboutToShowCondaMenu(self):
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
531 """
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
532 Private slot to handle the conda menu about to be shown.
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
533 """
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
534 selectedEnvironment = self.environmentsComboBox.currentText()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
535 enable = selectedEnvironment not in [""]
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
536 for act in self.__envActs:
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
537 act.setEnabled(enable)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
538
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
539 self.__deleteEnvAct.setEnabled(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
540 selectedEnvironment not in ["", self.__conda.RootName])
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
541
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
542 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
543 def __aboutConda(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
544 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
545 Private slot to show some information about the conda installation.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
546 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
547 infoDict = self.__conda.getCondaInformation()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
548
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
549 from .CondaInfoDialog import CondaInfoDialog
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
550 dlg = CondaInfoDialog(infoDict, self)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
551 dlg.exec_()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
552
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
553 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
554 def __installPackages(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
555 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
556 Private slot to install packages.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
557 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
558 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
559 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
560 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
561 ok, packageSpecs = E5TextInputDialog.getText(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
562 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
563 self.tr("Install Packages"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
564 self.tr("Package Specifications (separated by whitespace):"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
565 QLineEdit.Normal,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
566 minimumWidth=600)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
567 if ok and packageSpecs.strip():
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
568 packages = [p.strip() for p in packageSpecs.split()]
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
569 ok = self.__conda.installPackages(packages, prefix=prefix)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
570 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
571 self.on_refreshButton_clicked()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
572
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
573 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
574 def __installRequirements(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
575 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
576 Private slot to install packages from requirements files.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
577 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
578 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
579 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
580 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
581 requirements = E5FileDialog.getOpenFileNames(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
582 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
583 self.tr("Install Packages"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
584 "",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
585 self.tr("Text Files (*.txt);;All Files (*)"))
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
586 if requirements:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
587 args = []
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
588 for requirement in requirements:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
589 args.extend(["--file", requirement])
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
590 ok = self.__conda.installPackages(args, prefix=prefix)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
591 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
592 self.on_refreshButton_clicked()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
593
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
594 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
595 def __generateRequirements(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
596 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
597 Private slot to generate a requirements file.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
598 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
599 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
600 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
601 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
602 env = self.environmentsComboBox.currentText()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
603
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
604 from .CondaExportDialog import CondaExportDialog
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
605
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
606 self.__requirementsDialog = CondaExportDialog(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
607 self.__conda, env, prefix)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
608 self.__requirementsDialog.show()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
609 QApplication.processEvents()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
610 self.__requirementsDialog.start()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
611
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
612 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
613 def __cloneEnvironment(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
614 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
615 Private slot to clone a conda environment.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
616 """
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
617 from .CondaNewEnvironmentDataDialog import \
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
618 CondaNewEnvironmentDataDialog
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
619
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
620 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
621 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
622 if prefix:
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
623 dlg = CondaNewEnvironmentDataDialog(self.tr("Clone Environment"),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
624 False, self)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
625 if dlg.exec_() == QDialog.Accepted:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
626 virtEnvName, envName, _ = dlg.getData()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
627 args = [
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
628 "--name",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
629 envName.strip(),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
630 "--clone",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
631 prefix,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
632 ]
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
633 ok, prefix, interpreter = \
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
634 self.__conda.createCondaEnvironment(args)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
635 if ok:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
636 e5App().getObject("VirtualEnvManager").addVirtualEnv(
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
637 virtEnvName, prefix, interpreter, isConda=True)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
638
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
639 @pyqtSlot()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
640 def __createEnvironment(self):
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
641 """
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
642 Private slot to create a conda environment from a requirements file.
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
643 """
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
644 from .CondaNewEnvironmentDataDialog import \
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
645 CondaNewEnvironmentDataDialog
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
646
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
647 dlg = CondaNewEnvironmentDataDialog(self.tr("Create Environment"),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
648 True, self)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
649 if dlg.exec_() == QDialog.Accepted:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
650 virtEnvName, envName, requirements = dlg.getData()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
651 args = [
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
652 "--name",
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
653 envName.strip(),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
654 "--file",
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
655 requirements,
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
656 ]
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
657 ok, prefix, interpreter = \
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
658 self.__conda.createCondaEnvironment(args)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
659 if ok:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
660 e5App().getObject("VirtualEnvManager").addVirtualEnv(
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
661 virtEnvName, prefix, interpreter, isConda=True)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
662
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
663 @pyqtSlot()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
664 def __deleteEnvironment(self):
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
665 """
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
666 Private slot to delete a conda environment.
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
667 """
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
668 envName = self.environmentsComboBox.currentText()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
669 ok = E5MessageBox.yesNo(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
670 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
671 self.tr("Delete Environment"),
6771
bcffbb627791 Updated the translations for the new conda interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6738
diff changeset
672 self.tr("""<p>Shall the environment <b>{0}</b> really be"""
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
673 """ deleted?</p>""").format(envName)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
674 )
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
675 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
676 self.__conda.removeCondaEnvironment(name=envName)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
677
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
678 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
679 def __editUserConfiguration(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
680 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
681 Private slot to edit the user configuration.
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
682 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
683 from QScintilla.MiniEditor import MiniEditor
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
684
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
685 cfgFile = CondaInterface.userConfiguration()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
686 if not cfgFile:
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
687 return
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
688
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
689 if not os.path.exists(cfgFile):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
690 self.__conda.writeDefaultConfiguration()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
691
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
692 # check, if the destination is writeable
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
693 if not os.access(cfgFile, os.W_OK):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
694 E5MessageBox.critical(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
695 None,
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
696 self.tr("Edit Configuration"),
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
697 self.tr("""The configuration file "{0}" does not exist"""
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
698 """ or is not writable."""))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
699 return
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
700
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
701 self.__editor = MiniEditor(cfgFile, "YAML")
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
702 self.__editor.show()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
703
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
704 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
705 def __condaConfigure(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
706 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
707 Private slot to open the configuration page.
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
708 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
709 e5App().getObject("UserInterface").showPreferences("condaPage")
6738
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
710
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
711 @pyqtSlot()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
712 def on_recheckButton_clicked(self):
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
713 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
714 Private slot to re-check the availability of conda and adjust the
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
715 interface if it became available.
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
716 """
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
717 if CondaInterface.isCondaAvailable():
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
718 self.__initCondaInterface()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
719
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
720 self.notAvailableWidget.hide()
a7f835b41606 CondaPackagesWidget: show an error string if conda is not available. No other interface element are shown in that case.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6731
diff changeset
721 self.baseWidget.show()

eric ide

mercurial