本文整理匯總了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())