本文整理汇总了Python中PyQt5.QtQuick.QQuickView.close方法的典型用法代码示例。如果您正苦于以下问题:Python QQuickView.close方法的具体用法?Python QQuickView.close怎么用?Python QQuickView.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtQuick.QQuickView
的用法示例。
在下文中一共展示了QQuickView.close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoginWin
# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import close [as 别名]
class LoginWin(QtCore.QObject):
def __init__(self, state, app):
QtCore.QObject.__init__(self)
self.state = state
self.app = app
# Create the QML user interface.
self.login_win = QQuickView()
self.login_win.setTitle(self.tr("Xiami Login"))
self.login_win.setSource(QUrl('login.qml'))
self.login_win.setResizeMode(QQuickView.SizeRootObjectToView)
self.login_win.show()
# Connect signals
self.root_obj = self.login_win.rootObject()
self.root_obj.loginClicked.connect(self.login_clicked)
self.root_obj.exitClicked.connect(self.exit_clicked)
def set_state(self, msg):
self.root_obj.setStatus(msg)
def exit_clicked(self):
sys.exit(0)
def login_clicked(self, username, password):
code = self.root_obj.getVerificationCode()
if code != "":
try:
login.login_with_code(self.state, self.key, code)
except Exception as e:
self.set_state(e.message)
self.root_obj.hideCode()
return
self.ok()
else:
try:
ret = login.login(self.state, username, password)
except Exception as e:
self.set_state(e.message)
return
if not ret[0]:
with open(login.img_path, 'wb') as imgf:
imgf.write(ret[2])
self.set_state(self.tr("Please enter verification code"))
self.root_obj.setVerificationImage("file://%s"
% login.img_path)
self.key = ret[1]
else:
self.ok()
def ok(self):
self.login_win.close()
self.app.auth_ok()