菁英科技(卓目鸟学苑)- 专注软件测试菁英教育
标题:
吕煜海2021/1/27
[打印本页]
作者:
亲爱的葡萄
时间:
2021-1-27 19:56
标题:
吕煜海2021/1/27
from
PyQt5.QtWidgets
import
QApplication,QMainWindow,qApp,QAction
from
PyQt5.QtGui
import
QIcon
import
sys
class
Example
(
QMainWindow
):
def
__init__
(
self
):
super
().
__init__
()
self
.initUI()
def
initUI
(
self
):
exitAction = QAction(QIcon(
'python\day09\exit3.png'
),
'退出'
,
self
)
exitAction.setShortcut(
'Ctrl+Q'
)
exitAction.triggered.connect(qApp.quit)
# 创建工具栏
toolBar =
self
.addToolBar(
'工具栏'
)
toolBar.addAction(exitAction)
self
.setGeometry(
300
,
300
,
300
,
200
)
self
.setWindowTitle(
'工具栏'
)
self
.show()
if
__name__
==
"__main__"
:
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
from
PyQt5.QtWidgets
import
QApplication,QMainWindow,qApp,QAction
from
PyQt5.QtGui
import
QIcon
import
sys
class
Example
(
QMainWindow
):
def
__init__
(
self
):
super
().
__init__
()
self
.initUI()
def
initUI
(
self
):
# 创建一个菜单条目
exitAction = QAction(QIcon(
'python\day09\exit3.png'
),
'退出'
,
self
)
# 添加快捷键
exitAction.setShortcut(
'Ctrl+Q'
)
# 添加一个提示
exitAction.setStatusTip(
'退出程序!'
)
# 给菜单条目添加动作
exitAction.triggered.connect(qApp.quit)
# 创建一个菜单栏
menuBar =
self
.menuBar()
# 添加一个File菜单
fileMenu = menuBar.addMenu(
'File'
)
# 添加菜单条目
fileMenu.addAction(exitAction)
editMenu = menuBar.addMenu(
'Edit'
)
editMenu.addAction(exitAction)
self
.setGeometry(
300
,
300
,
300
,
200
)
self
.setWindowTitle(
'程序菜单'
)
self
.show()
if
__name__
==
"__main__"
:
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
from
PyQt5.QtWidgets
import
QApplication,QMainWindow
import
sys,time
class
Example
(
QMainWindow
):
def
__init__
(
self
):
super
().
__init__
()
self
.initUI()
def
initUI
(
self
):
# 创建状态栏
status =
self
.statusBar()
# 在状态栏显示信息
status.showMessage(
'准备好了!'
)
self
.setGeometry(
300
,
300
,
300
,
200
)
self
.setWindowTitle(
'状态栏'
)
self
.show()
if
__name__
==
"__main__"
:
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
欢迎光临 菁英科技(卓目鸟学苑)- 专注软件测试菁英教育 (http://www.zmnxy.com/)
Powered by Discuz! X3.4