Esempio n. 1
0
 def _integrate_gui(self, startup_info):
     """ Integrate event loop of GUI toolkit (or use pure Python
     event loop).
     """
     
     self.guiApp = guiintegration.App_base()
     self.guiName = guiName = startup_info['gui'].upper()
     guiError = ''
     
     try:
         if guiName in ['', 'NONE']:
             guiName = ''
         elif guiName == 'AUTO':
             for tryName, tryApp in [('PYQT5', guiintegration.App_pyqt5),
                                     ('PYQT4', guiintegration.App_pyqt4),
                                     ('PYSIDE2', guiintegration.App_pyside2),
                                     ('PYSIDE', guiintegration.App_pyside),
                                     #('WX', guiintegration.App_wx),
                                     ('ASYNCIO', guiintegration.App_asyncio),
                                     ('TK', guiintegration.App_tk),
                                     ]:
                 try:
                     self.guiApp = tryApp()
                 except Exception:
                     continue
                 guiName = tryName
                 break
             else:
                 guiName = ''
         elif guiName == 'ASYNCIO':
             self.guiApp = guiintegration.App_asyncio()
         elif guiName == 'TK':
             self.guiApp = guiintegration.App_tk()
         elif guiName == 'WX':
             self.guiApp = guiintegration.App_wx()
         elif guiName == 'TORNADO':
             self.guiApp = guiintegration.App_tornado()
         elif guiName == 'PYSIDE':
             self.guiApp = guiintegration.App_pyside()
         elif guiName == 'PYSIDE2':
             self.guiApp = guiintegration.App_pyside2()
         elif guiName in ['PYQT5', 'QT5']:
             self.guiApp = guiintegration.App_pyqt5()
         elif guiName in ['PYQT4', 'QT4']:
             self.guiApp = guiintegration.App_pyqt4()
         elif guiName == 'FLTK':
             self.guiApp = guiintegration.App_fltk()
         elif guiName == 'GTK':
             self.guiApp = guiintegration.App_gtk()
         else:
             guiError = 'Unkown gui: %s' % guiName
             guiName = ''
     except Exception: # Catch any error
         # Get exception info (we do it using sys.exc_info() because
         # we cannot catch the exception in a version independent way.
         type, value, tb = sys.exc_info()
         del tb
         guiError = 'Failed to integrate event loop for %s: %s' % (
             guiName, str(value))
     
     return guiName, guiError
Esempio n. 2
0
    def _integrate_gui(self, startup_info):
        """Integrate event loop of GUI toolkit (or use pure Python
        event loop).
        """

        self.guiApp = guiintegration.App_base()
        self.guiName = guiName = startup_info["gui"].upper()
        guiError = ""

        try:
            if guiName in ["", "NONE"]:
                guiName = ""
            elif guiName == "AUTO":
                for tryName, tryApp in [
                    ("PYSIDE6", guiintegration.App_pyside6),
                    ("PYQT6", guiintegration.App_pyqt6),
                    ("PYSIDE2", guiintegration.App_pyside2),
                    ("PYQT5", guiintegration.App_pyqt5),
                    ("PYSIDE", guiintegration.App_pyside),
                    ("PYQT4", guiintegration.App_pyqt4),
                        # ('WX', guiintegration.App_wx),
                    ("ASYNCIO", guiintegration.App_asyncio),
                    ("TK", guiintegration.App_tk),
                ]:
                    try:
                        self.guiApp = tryApp()
                    except Exception:
                        continue
                    guiName = tryName
                    break
                else:
                    guiName = ""
            elif guiName == "ASYNCIO":
                self.guiApp = guiintegration.App_asyncio()
            elif guiName == "TK":
                self.guiApp = guiintegration.App_tk()
            elif guiName == "WX":
                self.guiApp = guiintegration.App_wx()
            elif guiName == "TORNADO":
                self.guiApp = guiintegration.App_tornado()
            elif guiName == "PYSIDE6":
                self.guiApp = guiintegration.App_pyside6()
            elif guiName == "PYSIDE2":
                self.guiApp = guiintegration.App_pyside2()
            elif guiName == "PYSIDE":
                self.guiApp = guiintegration.App_pyside()
            elif guiName in ["PYQT6", "QT6"]:
                self.guiApp = guiintegration.App_pyqt6()
            elif guiName in ["PYQT5", "QT5"]:
                self.guiApp = guiintegration.App_pyqt5()
            elif guiName in ["PYQT4", "QT4"]:
                self.guiApp = guiintegration.App_pyqt4()
            elif guiName == "FLTK":
                self.guiApp = guiintegration.App_fltk()
            elif guiName == "GTK":
                self.guiApp = guiintegration.App_gtk()
            else:
                guiError = "Unkown gui: %s" % guiName
                guiName = ""
        except Exception:  # Catch any error
            # Get exception info (we do it using sys.exc_info() because
            # we cannot catch the exception in a version independent way.
            type, value, tb = sys.exc_info()
            del tb
            guiError = "Failed to integrate event loop for %s: %s" % (
                guiName,
                str(value),
            )

        return guiName, guiError