PluginCxFreeze.py

branch
eric7
changeset 134
7880b294d1d1
parent 131
86d810eea380
child 136
d9228f38cfe8
--- a/PluginCxFreeze.py	Thu Jun 03 14:27:52 2021 +0200
+++ b/PluginCxFreeze.py	Thu Jun 03 17:51:56 2021 +0200
@@ -10,12 +10,12 @@
 import os
 import platform
 
-from PyQt5.QtCore import QObject, QTranslator, QCoreApplication, QProcess
-from PyQt5.QtWidgets import QDialog
+from PyQt6.QtCore import QObject, QTranslator, QCoreApplication, QProcess
+from PyQt6.QtWidgets import QDialog
 
-from E5Gui import E5MessageBox
-from E5Gui.E5Action import E5Action
-from E5Gui.E5Application import e5App
+from EricWidgets import EricMessageBox
+from EricGui.EricAction import EricAction
+from EricWidgets.EricApplication import ericApp
     
 import Utilities
 
@@ -24,7 +24,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "7.2.0"
+version = "1.0.0"
 className = "CxFreezePlugin"
 packageName = "CxFreeze"
 shortDescription = "Show the CxFreeze dialogs."
@@ -47,6 +47,7 @@
     
     @return dictionary containing the data to query the presence of
         the executable
+    @rtype dict
     """
     dataList = []
     data = {
@@ -75,8 +76,10 @@
     """
     Restricted function to determine the names of the executable.
     
-    @param majorVersion major python version of the executables (int)
-    @return names of the executable (list)
+    @param majorVersion major Python version of the executables
+    @type int
+    @return names of the executable
+    @rtype list of str
     """
     # Determine Python Version
     if majorVersion == 3:
@@ -202,7 +205,8 @@
     """
     Restricted function to check the availability of cxfreeze.
     
-    @return flag indicating availability (boolean)
+    @return flag indicating availability
+    @rtype bool
     """
     global error, exePy3
     
@@ -230,7 +234,8 @@
         """
         Constructor
         
-        @param ui reference to the user interface object (UI.UserInterface)
+        @param ui reference to the user interface object
+        @type UserInterface
         """
         super().__init__(ui)
         self.__ui = ui
@@ -251,7 +256,8 @@
         """
         Public method to activate this plugin.
         
-        @return tuple of None and activation status (boolean)
+        @return tuple of None and activation status
+        @rtype tuple of (None, bool)
         """
         global error
         
@@ -263,10 +269,10 @@
         if not _checkProgram():
             return None, False
         
-        project = e5App().getObject("Project")
+        project = ericApp().getObject("Project")
         menu = project.getMenu("Packagers")
         if menu:
-            self.__projectAct = E5Action(
+            self.__projectAct = EricAction(
                 self.tr('Use cx_freeze'),
                 self.tr('Use cx_&freeze'), 0, 0,
                 self, 'packagers_cxfreeze')
@@ -280,7 +286,7 @@
                 """ relative to the project directory.</p>"""
             ))
             self.__projectAct.triggered.connect(self.__cxfreeze)
-            project.addE5Actions([self.__projectAct])
+            project.addEricActions([self.__projectAct])
             self.__projectSeparator = menu.addSeparator()
             menu.addAction(self.__projectAct)
             project.showMenu.connect(self.__projectShowMenu)
@@ -292,11 +298,11 @@
         """
         Public method to deactivate this plugin.
         """
-        menu = e5App().getObject("Project").getMenu("Packagers")
+        menu = ericApp().getObject("Project").getMenu("Packagers")
         if menu:
             if self.__projectAct:
                 menu.removeAction(self.__projectAct)
-                e5App().getObject("Project").removeE5Actions(
+                ericApp().getObject("Project").removeEricActions(
                     [self.__projectAct])
             if self.__projectSeparator:
                 menu.removeAction(self.__projectSeparator)
@@ -308,15 +314,17 @@
         Private slot called, when the the project menu or a submenu is
         about to be shown.
         
-        @param menuName name of the menu to be shown (string)
-        @param menu reference to the menu (QMenu)
+        @param menuName name of the menu to be shown
+        @type str
+        @param menu reference to the menu
+        @type QMenu
         """
         if (
             menuName == "Packagers" and
             self.__projectAct is not None
         ):
             self.__projectAct.setEnabled(
-                e5App().getObject("Project").getProjectLanguage() ==
+                ericApp().getObject("Project").getProjectLanguage() ==
                 "Python3"
             )
     
@@ -334,7 +342,7 @@
                 loaded = translator.load(translation, locale_dir)
                 if loaded:
                     self.__translator = translator
-                    e5App().installTranslator(self.__translator)
+                    ericApp().installTranslator(self.__translator)
                 else:
                     print("Warning: translation file '{0}' could not be"
                           " loaded.".format(translation))
@@ -344,22 +352,22 @@
         """
         Private slot to handle the cxfreeze execution.
         """
-        project = e5App().getObject("Project")
+        project = ericApp().getObject("Project")
         if not project.getMainScript():
             # no main script defined
-            E5MessageBox.critical(
+            EricMessageBox.critical(
                 self.__ui,
                 self.tr("cxfreeze"),
                 self.tr(
                     """There is no main script defined for the current"""
                     """ project."""),
-                E5MessageBox.StandardButtons(E5MessageBox.Abort))
+                EricMessageBox.StandardButtons(EricMessageBox.Abort))
             return
         
         majorVersionStr = project.getProjectLanguage()
         exe = {"Python3": exePy3}.get(majorVersionStr)
         if exe == []:
-            E5MessageBox.critical(
+            EricMessageBox.critical(
                 self.__ui,
                 self.tr("cxfreeze"),
                 self.tr("""The cxfreeze executable could not be found."""))
@@ -372,7 +380,7 @@
         from CxFreeze.CxfreezeConfigDialog import CxfreezeConfigDialog
         parms = project.getData('PACKAGERSPARMS', "CXFREEZE")
         dlg = CxfreezeConfigDialog(project, exe, parms)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             args, parms = dlg.generateParameters()
             project.setData('PACKAGERSPARMS', "CXFREEZE", parms)
             
@@ -385,5 +393,18 @@
             if res:
                 dia.exec()
 
+
+def installDependencies(pipInstall):
+    """
+    Function to install dependencies of this plug-in.
+    
+    @param pipInstall function to be called with a list of package names.
+    @type function
+    """
+    try:
+        import cx_Freeze         # __IGNORE_WARNING__
+    except ImportError:
+        pipInstall(["cx-Freeze"])
+
 #
 # eflag: noqa = M801

eric ide

mercurial