eric6/CondaInterface/CondaPackagesWidget.py

Sun, 02 Feb 2020 11:04:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 Feb 2020 11:04:32 +0100
changeset 7380
c99320e859ca
parent 7360
9190402e4505
child 7722
db3a6d341913
permissions
-rw-r--r--

Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7250
diff changeset
3 # Copyright (c) 2019 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
6698
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
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
11 import os
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
12
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtCore import pyqtSlot, Qt
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
14 from PyQt5.QtGui import QCursor
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 from PyQt5.QtWidgets import (
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
16 QWidget, QToolButton, QMenu, QTreeWidgetItem, QApplication, QLineEdit,
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
17 QDialog
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
18 )
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
20 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
21 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
22
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 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
24
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 import UI.PixmapCache
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
27 import CondaInterface
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
28
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 class CondaPackagesWidget(QWidget, Ui_CondaPackagesWidget):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 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
33 """
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
34 # Role definition of packages list
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
35 PackageVersionRole = Qt.UserRole + 1
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
36 PackageBuildRole = Qt.UserRole + 2
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
37
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
38 # 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
39 PackageDetailedDataRole = Qt.UserRole + 1
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
40
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
41 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
42 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 Constructor
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
45 @param conda reference to the conda interface
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
46 @type Conda
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @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
48 @type QWidget
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 super(CondaPackagesWidget, self).__init__(parent)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.setupUi(self)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
53 self.__conda = conda
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
54
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
55 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
56 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
57 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
58
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 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
60 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
61
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 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
63
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 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
65 """
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 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
67 """
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 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
69
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 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
71 "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
72 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
73 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
74 self.condaMenuButton.setPopupMode(QToolButton.InstantPopup)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.condaMenuButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.condaMenuButton.setFocusPolicy(Qt.NoFocus)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.condaMenuButton.setAutoRaise(True)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.condaMenuButton.setShowMenuInside(True)
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
6796
eebd0a5f10f4 Conda Interface: converted the verbal action buttons to iconic ones.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6771
diff changeset
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
89 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
90 self.searchOptionsWidget.hide()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
91 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
92 self.platformComboBox.addItems(sorted([
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
93 "", "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
94 ]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
95
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__initCondaMenu()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.__populateEnvironments()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
98 self.__updateActionButtons()
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
99
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
100 self.searchWidget.hide()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
101
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
102 self.__conda.condaEnvironmentCreated.connect(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
103 self.on_refreshButton_clicked)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
104 self.__conda.condaEnvironmentRemoved.connect(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
105 self.on_refreshButton_clicked)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 def __populateEnvironments(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 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
110 """
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
111 environments = [("", "")] + sorted(
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
112 self.__conda.getCondaEnvironmentsList())
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
113 for environment in environments:
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
114 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
115
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 def __initCondaMenu(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 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
119 menu button.
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.__condaMenu = QMenu(self)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
122 self.__envActs = []
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
123
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
124 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
125 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
126 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
127 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
128 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
129 self.__cleanMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
130 self.tr("Lock Files"),
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
131 lambda: self.__conda.cleanConda("lock"))
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
132 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
133 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
134 self.__cleanMenu.addAction(
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
135 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
136
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
137 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
138 self.tr("About Conda..."), self.__aboutConda)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
139 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
140 self.__condaMenu.addAction(
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
141 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
142 self.__condaMenu.addSeparator()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
143 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
144 self.tr("Install Packages"), self.__installPackages))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
145 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
146 self.tr("Install Requirements"), self.__installRequirements))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
147 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
148 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
149 self.tr("Generate Requirements"), self.__generateRequirements))
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
150 self.__condaMenu.addSeparator()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
151 self.__condaMenu.addAction(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
152 self.tr("Create Environment from Requirements"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
153 self.__createEnvironment)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
154 self.__envActs.append(self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
155 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
156 self.__deleteEnvAct = self.__condaMenu.addAction(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
157 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
158 self.__condaMenu.addSeparator()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
159 self.__condaMenu.addMenu(self.__cleanMenu)
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
160 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
161 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
162 self.tr("Edit User Configuration..."),
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
163 self.__editUserConfiguration)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
164 self.__condaMenu.addSeparator()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
165 self.__condaMenu.addAction(
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
166 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
167
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 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
169
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
170 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
171
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
172 def __selectedUpdateableItems(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
173 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
174 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
175
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
176 @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
177 @rtype list of QTreeWidgetItem
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
178 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
179 return [
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
180 itm for itm in self.packagesList.selectedItems()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
181 if bool(itm.text(2))
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
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
184 def __allUpdateableItems(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
185 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
186 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
187
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
188 @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
189 @rtype list of QTreeWidgetItem
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
191 updateableItems = []
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
192 for index in range(self.packagesList.topLevelItemCount()):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
193 itm = self.packagesList.topLevelItem(index)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
194 if itm.text(2):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
195 updateableItems.append(itm)
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
197 return updateableItems
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
198
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
199 def __updateActionButtons(self):
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
200 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
201 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
202 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
203 self.upgradeButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
204 bool(self.__selectedUpdateableItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
205 self.uninstallButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
206 bool(self.packagesList.selectedItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
207 self.upgradeAllButton.setEnabled(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
208 bool(self.__allUpdateableItems()))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
209
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
210 @pyqtSlot(int)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
211 def on_environmentsComboBox_currentIndexChanged(self, index):
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
212 """
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
213 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
214
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
215 @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
216 @type int
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
218 self.packagesList.clear()
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
219 prefix = self.environmentsComboBox.itemData(index)
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
220 if prefix:
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
221 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
222 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
223 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
224 QApplication.processEvents()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
225
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
226 # 1. populate with installed packages
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
227 self.packagesList.setUpdatesEnabled(False)
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
228 installedPackages = self.__conda.getInstalledPackages(
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
229 prefix=prefix)
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
230 for package, version, build in installedPackages:
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
231 itm = QTreeWidgetItem(self.packagesList, [package, version])
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
232 itm.setData(1, self.PackageVersionRole, version)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
233 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
234 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
235 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
236 QApplication.processEvents()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
237
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
238 # 2. update with update information
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
239 self.packagesList.setUpdatesEnabled(False)
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
240 updateablePackages = self.__conda.getUpdateablePackages(
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
241 prefix=prefix)
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
242 for package, version, build in updateablePackages:
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
243 items = self.packagesList.findItems(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
244 package, Qt.MatchExactly | Qt.MatchCaseSensitive)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
245 if items:
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
246 itm = items[0]
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
247 itm.setText(2, version)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
248 itm.setData(2, self.PackageVersionRole, version)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
249 itm.setData(2, self.PackageBuildRole, build)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
250 if itm.data(1, self.PackageVersionRole) == version:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
251 # 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
252 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
253 itm.data(1, self.PackageVersionRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
254 itm.data(1, self.PackageBuildRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
255 ))
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
256 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
257 itm.data(2, self.PackageVersionRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
258 itm.data(2, self.PackageBuildRole),
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
259 ))
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
260
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
261 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
262 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
263 self.packagesList.resizeColumnToContents(col)
6705
8cf1c3851b5c Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6701
diff changeset
264 self.packagesList.setUpdatesEnabled(True)
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
265 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
266 self.statusLabel.hide()
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
267
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
268 self.__updateActionButtons()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
269 self.__updateSearchActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 def on_packagesList_itemSelectionChanged(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
274 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
275 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
276 self.__updateActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 def on_refreshButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
281 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
282 """
6701
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
283 currentEnvironment = self.environmentsComboBox.currentText()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
284 self.environmentsComboBox.clear()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
285 self.packagesList.clear()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
286
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
287 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
288 QApplication.processEvents()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
289
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
290 self.__populateEnvironments()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
291
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
292 index = self.environmentsComboBox.findText(
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
293 currentEnvironment, Qt.MatchExactly | Qt.MatchCaseSensitive)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
294 if index != -1:
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
295 self.environmentsComboBox.setCurrentIndex(index)
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
296
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
297 QApplication.restoreOverrideCursor()
af29cf6ca309 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6698
diff changeset
298 self.__updateActionButtons()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 def on_upgradeButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
303 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
304 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
305 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
306 if packages:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
307 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
308 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
309 ok = self.__conda.updatePackages(packages, prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
310 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
311 self.on_refreshButton_clicked()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 def on_upgradeAllButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
316 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
317 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
318 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
319 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
320 ok = self.__conda.updateAllPackages(prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
321 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
322 self.on_refreshButton_clicked()
6698
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 @pyqtSlot()
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 def on_uninstallButton_clicked(self):
bc5aa4cda1ee Conda: started to implement the Conda Packages Manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
327 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
328 """
6706
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
329 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
330 if packages:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
331 prefix = self.environmentsComboBox.itemData(
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
332 self.environmentsComboBox.currentIndex())
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
333 ok = self.__conda.uninstallPackages(packages, prefix=prefix)
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
334 if ok:
d792e054cde2 Conda, CondaPackagesWidget: continued implementing list functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6705
diff changeset
335 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
336
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
337 #######################################################################
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
338 ## 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
339 #######################################################################
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
340
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
341 def __updateSearchActionButtons(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
342 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
343 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
344 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
345 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
346 self.installButton.setEnabled(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
347 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
348 self.showDetailsButton.setEnabled(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
349 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
350
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
351 def __doSearch(self):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
352 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
353 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
354 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
355 self.searchResultList.clear()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
356 pattern = self.searchEdit.text()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
357 if pattern:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
358 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
359 QApplication.processEvents()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
360
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
361 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
362 prefix = ""
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
363 else:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
364 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
365 self.environmentsComboBox.currentIndex())
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
366 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
367 pattern,
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
368 fullNameOnly=self.fullNameButton.isChecked(),
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
369 packageSpec=self.packageSpecButton.isChecked(),
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
370 platform=self.platformComboBox.currentText(),
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
371 prefix=prefix,
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
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
374 if result:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
375 if ok:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
376 self.searchResultList.setUpdatesEnabled(False)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
377 for package in result:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
378 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
379 itm.setExpanded(False)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
380 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
381 version = detail["version"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
382 build = detail["build"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
383 if "subdir" in detail:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
384 platform = detail["subdir"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
385 elif "platform" in detail:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
386 platform = detail["platform"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
387 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
388 platform = ""
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
389 citm = QTreeWidgetItem(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
390 itm, ["", version, build, platform])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
391 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
392 detail)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
393
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
394 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
395 self.searchResultList.resizeColumnToContents(0)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
396 self.searchResultList.setUpdatesEnabled(True)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
397 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
398 QApplication.restoreOverrideCursor()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
399 try:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
400 message = result["message"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
401 except KeyError:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
402 message = result["error"]
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
403 E5MessageBox.warning(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
404 self,
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
405 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
406 message)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
407 QApplication.restoreOverrideCursor()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
408
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
409 def __showDetails(self, item):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
410 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
411 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
412
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
413 @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
414 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
415 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
416 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
417 if details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
418 from .CondaPackageDetailsWidget import CondaPackageDetailsDialog
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
419 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
420 dlg.exec_()
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
421
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
422 @pyqtSlot(str)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
423 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
424 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
425 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
426
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
427 @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
428 @type str
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
429 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
430 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
431
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
432 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
433 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
434 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
435 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
436 search edit.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
437 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
438 self.__doSearch()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
439
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
440 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
441 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
442 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
443 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
444 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
445 self.__doSearch()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
446
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
447 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
448 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
449 """
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
450 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
451 """
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
452 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
453 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
454 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
455 # 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
456 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
457 else:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
458 # 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
459 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
460 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
461 item.text(1),
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
462 item.text(2),
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
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
465 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
466 self.environmentsComboBox.currentIndex())
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
467 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
468 if ok:
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
469 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
470
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
471 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
472 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
473 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
474 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
475 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
476 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
477 self.__showDetails(item)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
478
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
479 @pyqtSlot()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
480 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
481 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
482 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
483 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
484 self.__updateSearchActionButtons()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
485
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
486 @pyqtSlot(QTreeWidgetItem)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
487 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
488 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
489 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
490
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
491 @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
492 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
493 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
494 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
495 self.searchResultList.resizeColumnToContents(col)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
496
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
497 @pyqtSlot(QTreeWidgetItem, int)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
498 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
499 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
500 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
501
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
502 @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
503 @type QTreeWidgetItem
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
504 @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
505 @type int
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
506 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
507 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
508 self.__showDetails(item)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
509
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
510 @pyqtSlot(bool)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
511 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
512 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
513 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
514
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
515 @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
516 @type bool
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
517 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
518 self.searchWidget.setVisible(checked)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
519
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
520 if checked:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
521 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
522 self.searchEdit.selectAll()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
523
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6706
diff changeset
524 self.__updateSearchActionButtons()
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
525
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
526 #######################################################################
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
527 ## Menu related methods below
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
528 #######################################################################
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
529
6715
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
530 @pyqtSlot()
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
531 def __aboutToShowCondaMenu(self):
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
532 """
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
533 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
534 """
f1bf1985434e Conda, CondaPackagesWidget: implemented install functionality and strted with Conda menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
535 selectedEnvironment = self.environmentsComboBox.currentText()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
536 enable = selectedEnvironment not in [""]
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
537 for act in self.__envActs:
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
538 act.setEnabled(enable)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
539
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
540 self.__deleteEnvAct.setEnabled(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
541 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
542
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
543 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
544 def __aboutConda(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
545 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
546 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
547 """
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
548 infoDict = self.__conda.getCondaInformation()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
549
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
550 from .CondaInfoDialog import CondaInfoDialog
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
551 dlg = CondaInfoDialog(infoDict, self)
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
552 dlg.exec_()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
553
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
554 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
555 def __installPackages(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
556 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
557 Private slot to install packages.
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
558 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
559 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
560 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
561 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
562 ok, packageSpecs = E5TextInputDialog.getText(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
563 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
564 self.tr("Install Packages"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
565 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
566 QLineEdit.Normal,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
567 minimumWidth=600)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
568 if ok and packageSpecs.strip():
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
569 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
570 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
571 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
572 self.on_refreshButton_clicked()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
573
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
574 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
575 def __installRequirements(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
576 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
577 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
578 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
579 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
580 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
581 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
582 requirements = E5FileDialog.getOpenFileNames(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
583 self,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
584 self.tr("Install Packages"),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
585 "",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
586 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
587 if requirements:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
588 args = []
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
589 for requirement in requirements:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
590 args.extend(["--file", requirement])
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
591 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
592 if ok:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
593 self.on_refreshButton_clicked()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
594
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
595 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
596 def __generateRequirements(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
597 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
598 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
599 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
600 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
601 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
602 if prefix:
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
603 env = self.environmentsComboBox.currentText()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
604
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
605 from .CondaExportDialog import CondaExportDialog
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
606
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
607 self.__requirementsDialog = CondaExportDialog(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
608 self.__conda, env, prefix)
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
609 self.__requirementsDialog.show()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
610 QApplication.processEvents()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
611 self.__requirementsDialog.start()
6724
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
612
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
613 @pyqtSlot()
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
614 def __cloneEnvironment(self):
ca89c7d94c94 Conda: started implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6715
diff changeset
615 """
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
616 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
617 """
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
618 from .CondaNewEnvironmentDataDialog import (
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
619 CondaNewEnvironmentDataDialog)
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
620
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
621 prefix = self.environmentsComboBox.itemData(
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
622 self.environmentsComboBox.currentIndex())
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
623 if prefix:
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
624 dlg = CondaNewEnvironmentDataDialog(self.tr("Clone Environment"),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
625 False, self)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
626 if dlg.exec_() == QDialog.Accepted:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
627 virtEnvName, envName, _ = dlg.getData()
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
628 args = [
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
629 "--name",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
630 envName.strip(),
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
631 "--clone",
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
632 prefix,
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
633 ]
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
634 ok, prefix, interpreter = self.__conda.createCondaEnvironment(
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
635 args)
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
636 if ok:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
637 e5App().getObject("VirtualEnvManager").addVirtualEnv(
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
638 virtEnvName, prefix, interpreter, isConda=True)
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
639
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
640 @pyqtSlot()
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
641 def __createEnvironment(self):
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
642 """
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6724
diff changeset
643 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
644 """
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
645 from .CondaNewEnvironmentDataDialog import (
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
646 CondaNewEnvironmentDataDialog)
6731
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
647
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
648 dlg = CondaNewEnvironmentDataDialog(self.tr("Create Environment"),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
649 True, self)
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
650 if dlg.exec_() == QDialog.Accepted:
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
651 virtEnvName, envName, requirements = dlg.getData()
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
652 args = [
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
653 "--name",
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
654 envName.strip(),
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
655 "--file",
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
656 requirements,
c70eaa492741 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6728
diff changeset
657 ]
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
658 ok, prefix, interpreter = self.__conda.createCondaEnvironment(args)
6731
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