本文整理汇总了Python中sip.setdestroyonexit方法的典型用法代码示例。如果您正苦于以下问题:Python sip.setdestroyonexit方法的具体用法?Python sip.setdestroyonexit怎么用?Python sip.setdestroyonexit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sip
的用法示例。
在下文中一共展示了sip.setdestroyonexit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fix_pyinstaller_sip_api
# 需要导入模块: import sip [as 别名]
# 或者: from sip import setdestroyonexit [as 别名]
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
示例2: gui
# 需要导入模块: import sip [as 别名]
# 或者: from sip import setdestroyonexit [as 别名]
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())