src/eric7/PipInterface/PipPackagesWidget.py

branch
eric7-maintenance
changeset 9654
7328efba128b
parent 9549
67295777d9fe
parent 9653
e67609152c5e
child 9725
b9a29a7aa820
--- a/src/eric7/PipInterface/PipPackagesWidget.py	Thu Dec 01 10:18:07 2022 +0100
+++ b/src/eric7/PipInterface/PipPackagesWidget.py	Mon Jan 02 11:16:03 2023 +0100
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2019 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2019 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 
 """
@@ -201,7 +201,8 @@
         self.upgradeAllButton.setIcon(EricPixmapCache.getIcon("2uparrow"))
         self.uninstallButton.setIcon(EricPixmapCache.getIcon("minus"))
         self.showPackageDetailsButton.setIcon(EricPixmapCache.getIcon("info"))
-        self.searchToggleButton.setIcon(EricPixmapCache.getIcon("find"))
+        self.searchToggleButton_1.setIcon(EricPixmapCache.getIcon("find"))
+        self.searchToggleButton_2.setIcon(EricPixmapCache.getIcon("find"))
         self.searchButton.setIcon(EricPixmapCache.getIcon("findNext"))
         self.searchMoreButton.setIcon(EricPixmapCache.getIcon("plus"))
         self.installButton.setIcon(EricPixmapCache.getIcon("plus"))
@@ -482,10 +483,13 @@
         if name != self.__selectedEnvironment:
             if not name:
                 self.environmentPathLabel.setPath("")
+                self.searchNameEdit.clear()
+                self.searchNameEdit.setEnabled(False)
             else:
                 self.environmentPathLabel.setPath(
                     self.__pip.getVirtualenvInterpreter(name)
                 )
+                self.searchNameEdit.setEnabled(True)
 
             if self.viewToggleButton.isChecked():
                 self.__refreshDependencyTree()
@@ -542,7 +546,7 @@
                 mode = self.ShowProcessGeneralMode
                 for line in output.splitlines():
                     line = line.rstrip()
-                    if line != "---":
+                    if line and line != "---":
                         if mode != self.ShowProcessGeneralMode:
                             if line[0] == " ":
                                 QTreeWidgetItem(infoWidget, [" ", line.strip()])
@@ -791,7 +795,7 @@
         Private method to update the state of the search button.
         """
         self.searchButton.setEnabled(
-            bool(self.searchEditName.text()) and self.__isPipAvailable()
+            bool(self.searchNameEdit.text()) and self.__isPipAvailable()
         )
 
     def __updateSearchMoreButton(self, enable):
@@ -802,29 +806,40 @@
         @type bool
         """
         self.searchMoreButton.setEnabled(
-            enable and bool(self.searchEditName.text()) and self.__isPipAvailable()
+            enable and bool(self.searchNameEdit.text()) and self.__isPipAvailable()
         )
 
     @pyqtSlot(bool)
-    def on_searchToggleButton_toggled(self, checked):
+    def on_searchToggleButton_1_toggled(self, checked):
         """
-        Private slot to togle the search widget.
+        Private slot to toggle the search widget.
 
         @param checked state of the search widget button
         @type bool
         """
         self.searchWidget.setVisible(checked)
+        self.searchToggleButton_2.setChecked(checked)
 
         if checked:
-            self.searchEditName.setFocus(Qt.FocusReason.OtherFocusReason)
-            self.searchEditName.selectAll()
+            self.searchNameEdit.setFocus(Qt.FocusReason.OtherFocusReason)
+            self.searchNameEdit.selectAll()
 
             self.__updateSearchActionButtons()
             self.__updateSearchButton()
             self.__updateSearchMoreButton(False)
 
+    @pyqtSlot(bool)
+    def on_searchToggleButton_2_toggled(self, checked):
+        """
+        Private slot to toggle the search widget.
+
+        @param checked state of the search widget button
+        @type bool
+        """
+        self.searchToggleButton_1.setChecked(checked)
+
     @pyqtSlot(str)
-    def on_searchEditName_textChanged(self, txt):
+    def on_searchNameEdit_textChanged(self, txt):
         """
         Private slot handling a change of the search term.
 
@@ -834,11 +849,11 @@
         self.__updateSearchButton()
 
     @pyqtSlot()
-    def on_searchEditName_returnPressed(self):
+    def on_searchNameEdit_returnPressed(self):
         """
         Private slot initiating a search via a press of the Return key.
         """
-        if bool(self.searchEditName.text()) and self.__isPipAvailable():
+        if bool(self.searchNameEdit.text()) and self.__isPipAvailable():
             self.__searchFirst()
 
     @pyqtSlot()
@@ -884,7 +899,7 @@
 
         self.searchButton.setEnabled(False)
 
-        searchTerm = self.searchEditName.text().strip()
+        searchTerm = self.searchNameEdit.text().strip()
         searchTerm = bytes(QUrl.toPercentEncoding(searchTerm)).decode()
         urlQuery = QUrlQuery()
         urlQuery.addQueryItem("q", searchTerm)
@@ -968,7 +983,7 @@
                     self,
                     self.tr("Search PyPI"),
                     self.tr(
-                        """<p>There were no more results for""" """ <b>{0}</b>.</p>"""
+                        """<p>There were no more results for <b>{0}</b>.</p>"""
                     ).format(searchTerm),
                 )
             lastItem = None
@@ -1019,7 +1034,7 @@
         self.__updateSearchActionButtons()
         self.__updateSearchButton()
 
-        self.searchEditName.setFocus(Qt.FocusReason.OtherFocusReason)
+        self.searchNameEdit.setFocus(Qt.FocusReason.OtherFocusReason)
 
     @pyqtSlot()
     def on_installButton_clicked(self):
@@ -1237,7 +1252,7 @@
         )
         self.__pipMenu.addSeparator()
         self.__checkVulnerabilityAct = self.__pipMenu.addAction(
-            self.tr("Check Vulnerabilities"), self.__updateVulnerabilityData
+            self.tr("Check Vulnerabilities"), self.__checkVulnerability
         )
         # updateVulnerabilityDbAct
         self.__pipMenu.addAction(
@@ -1456,7 +1471,7 @@
             EricMessageBox.critical(
                 None,
                 self.tr("Edit Configuration"),
-                self.tr("""No valid configuration path determined.""" """ Aborting"""),
+                self.tr("""No valid configuration path determined. Aborting"""),
             )
             return
 
@@ -1467,7 +1482,7 @@
             EricMessageBox.critical(
                 None,
                 self.tr("Edit Configuration"),
-                self.tr("""No valid configuration path determined.""" """ Aborting"""),
+                self.tr("""No valid configuration path determined. Aborting"""),
             )
             return
 
@@ -1480,7 +1495,7 @@
             EricMessageBox.critical(
                 None,
                 self.tr("Edit Configuration"),
-                self.tr("""No valid configuration path determined.""" """ Aborting"""),
+                self.tr("""No valid configuration path determined. Aborting"""),
             )
             return
 
@@ -1549,6 +1564,14 @@
         )
 
     @pyqtSlot()
+    def __checkVulnerability(self):
+        """
+        Private slot to update and show the vulnerability data (called from the menu).
+        """
+        self.vulnerabilityCheckBox.setChecked(True)
+        self.on_vulnerabilityCheckBox_clicked(True)
+
+    @pyqtSlot()
     def __clearVulnerabilityInfo(self):
         """
         Private slot to clear the vulnerability info.

eric ide

mercurial