Python sip.setdestroyonexit() Examples

The following are 2 code examples of sip.setdestroyonexit(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sip , or try the search function .
Example #1
Source File: installers.py    From ibeis with Apache License 2.0 5 votes vote down vote up
def fix_pyinstaller_sip_api():
    """
    Hack to get the correct version of SIP for win32

    References:
        http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
    """
    import PyInstaller
    from os.path import dirname, join  # NOQA
    hook_fpath = join(dirname(PyInstaller.__file__), 'loader', 'rthooks', 'pyi_rth_qt4plugins.py')
    patch_code = ut.codeblock(
        '''
        try:
            import sip
            # http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
            sip.setapi('QVariant', 2)
            sip.setapi('QString', 2)
            sip.setapi('QTextStream', 2)
            sip.setapi('QTime', 2)
            sip.setapi('QUrl', 2)
            sip.setapi('QDate', 2)
            sip.setapi('QDateTime', 2)
            if hasattr(sip, 'setdestroyonexit'):
                sip.setdestroyonexit(False)  # This prevents a crash on windows
        except ValueError as ex:
            print('Warning: Value Error: %s' % str(ex))
        pass
        ''')
    fpath = hook_fpath
    # Patch the hook file
    tag = 'SIP_API_2'
    ut.inject_python_code(fpath, patch_code, tag)
    #ut.editfile(hook_fpath)
    pass 
Example #2
Source File: main.py    From Yugioh-bot with MIT License 5 votes vote down vote up
def gui(start, config_file):
    if start:
        import sys
        from PyQt5.QtWidgets import QSystemTrayIcon
        from PyQt5.QtWidgets import QMessageBox
        from PyQt5.QtWidgets import QApplication
        from bot.utils.common import make_config_file, default_config
        from bot.duel_links_runtime import DuelLinkRunTime
        from bot.dl_gui import DuelLinksGui
        from bot import logger
        sip.setdestroyonexit(False)
        app = QApplication(sys.argv)

        if not QSystemTrayIcon.isSystemTrayAvailable():
            QMessageBox.critical(None, "Systray",
                                 "Systray not dected on system.")
            sys.exit(1)

        QApplication.setQuitOnLastWindowClosed(False)

        uconfig = default_config()
        uconfig.read(config_file)
        dlRuntime = setup_runtime(uconfig)
        dlRuntime.main()
        window = DuelLinksGui(dlRuntime, uconfig.get('locations', 'assets'))
        window.show()

        def handler(signum, frame):
            if signum == signal.SIGINT:
                window.__quit__()
                logger.info("Exiting Yugioh-DuelLinks Bots")

        signal.signal(signal.SIGINT, handler)

        def inmain():
            return app.exec_()

        sys.exit(inmain())