本文整理匯總了Python中PyQt5.QtWidgets.qApp.quit方法的典型用法代碼示例。如果您正苦於以下問題:Python qApp.quit方法的具體用法?Python qApp.quit怎麽用?Python qApp.quit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.qApp
的用法示例。
在下文中一共展示了qApp.quit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: new_session_dialog
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def new_session_dialog(self):
"""Show the layout-selection dialog"""
try:
# Prompt the user for a new layout
dialog = LayoutSelect()
if dialog.exec_() != QDialog.Accepted:
if self._layout is None:
# If the user close the dialog, and no layout exists
# the application is closed
self.finalize()
qApp.quit()
exit()
else:
return
# If a valid file is selected load it, otherwise load the layout
if exists(dialog.filepath):
self._load_from_file(dialog.filepath)
else:
self._new_session(dialog.selected())
except Exception as e:
elogging.exception('Startup error', e)
qApp.quit()
exit(-1)
示例2: initMenuBar
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def initMenuBar(self):
'''
初始化菜單欄
'''
menubar = self.menuBar()
#self.actionExit.triggered.connect(qApp.quit) # 按下菜單欄的Exit按鈕會退出程序
#self.actionExit.setStatusTip("退出程序") # 左下角狀態提示
#self.actionExit.setShortcut('Ctrl+Q') # 添加快捷鍵
exitAct = QAction(QIcon('exit.png'), 'Exit', self)
exitAct.setShortcut('Ctrl+Q')
exitAct.triggered.connect(qApp.quit)
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(exitAct)
fileMenu = menubar.addMenu('&Help')
示例3: initUI
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def initUI(self):
exitAct = QAction(QIcon('exit.png'), '&Exit', self)
exitAct.setShortcut('Ctrl+Q')
exitAct.setStatusTip('Exit application')
exitAct.triggered.connect(qApp.quit)
self.statusBar()
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(exitAct)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Simple menu')
self.show()
示例4: ButtonAct
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def ButtonAct(self):
global ulist
sender = self.sender()
ulist += sender.text()
if sender.text() == '=':
value = eval(ulist.replace('=',''))
if value:
self.Line.setText(str(value))
ulist = str(value)
elif sender.text() == 'close':
qApp.quit()
elif sender.text() == 'cls':
ulist = ''
elif sender.text() == 'bck':
ulist = ulist[:-4]
elif sender.text() == 'plus':
ulist = ulist[:-4]
self.Text.setText(ulist)
# execute our application
示例5: initToolBar
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def initToolBar(self):
'''
初始化工具欄
創建一個QAction實例exitAct,然後添加到designer已經創建的默認的工具欄toolBar裏麵
'''
exitAct = QAction(QIcon('exit.png'), 'Exit', self)
exitAct.setShortcut('Ctrl+Q')
exitAct.triggered.connect(qApp.quit)
self.toolBar.addAction(exitAct)
示例6: contextMenuEvent
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def contextMenuEvent(self, event):
cmenu = QMenu(self)
newAct = cmenu.addAction("New")
opnAct = cmenu.addAction("Open")
quitAct = cmenu.addAction("Quit")
action = cmenu.exec_(self.mapToGlobal(event.pos()))
if action == quitAct:
qApp.quit()
示例7: initUI
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def initUI(self):
exitAct = QAction(QIcon('exit24.png'), 'Exit', self)
exitAct.setShortcut('Ctrl+Q')
exitAct.triggered.connect(qApp.quit)
self.toolbar = self.addToolBar('Exit')
self.toolbar.addAction(exitAct)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Toolbar')
self.show()
示例8: quitApp
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def quitApp(self):
# 退出程序
self.w.show() # w.hide() #設置退出時是否顯示主窗口
re = QMessageBox.question(self.w, "提示", "確認退出?", QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if re == QMessageBox.Yes:
self.tp.setVisible(False) # 隱藏托盤控件
qApp.quit() # 退出程序
self.w.v2rayL.disconnect()
示例9: checkPLAYMODE
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def checkPLAYMODE(self):
while self.btnset.PLAYMODE == Constants.playmode_pause:
loop = QEventLoop()
QTimer.singleShot(10, loop.quit)
loop.exec_()
示例10: menubtn0_clicked
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def menubtn0_clicked(self):
print("clicked pb_1")
qApp.quit()
sys.exit(0)
示例11: pb_1_clicked
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def pb_1_clicked(self):
print("clicked pb_1")
qApp.quit()
sys.exit(0)
示例12: show
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def show(param, msg="done", time=300):
loop = QEventLoop()
QTimer.singleShot(time, loop.quit)
loop.exec_()
graphics.update(param)
graphics.setVisible(True)
示例13: closeEvent
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def closeEvent(self, event):
'''
Shows a message box to confirm the wondow closing
'''
reply = QMessageBox.question(self, 'Message',
"Are you sure to quit?", QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
示例14: initUi
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def initUi(self):
# 提示數值範圍
self.label.setText('數值的範圍是:{}-{}'.format(self.left, self.right))
# 按下按鈕一,運行 self.guess 函數
self.pushButton.clicked.connect(self.guess)
# 按下按鈕二,運行 quit 函數
self.pushButton_2.clicked.connect(qApp.quit)
# 按下按鈕三,運行 self.reset 函數
self.pushButton_3.clicked.connect(self.reset)
示例15: keyPressEvent
# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import quit [as 別名]
def keyPressEvent(self, e):
# 設置快捷鍵
if e.key() == Qt.Key_Return:
self.guess()
elif e.key() == Qt.Key_Escape:
qApp.quit()
elif e.key() == Qt.Key_R:
self.reset()