PyQt5快速上手基础篇8-菜单栏、工具栏和状态栏
发布日期:2021-05-15 00:02:32 浏览次数:21 分类:精选文章

本文共 4429 字,大约阅读时间需要 14 分钟。

##Qt���������������������������������������������������������������

���������Qt Designer��������������������������������������������������������������������������������������������� Womensual���������������������������������������������������������������������������������������������������������������������������������������

###1. ���berger������������

������������������������������������������������������������������������������������������������������������������������������������

  • ������������QMenu������������������������������QMenu������������������������������������������������QAction���������������QAction������������QMenu���������������triggered��������������������������������������������� Designer���������������������������������������QMenu���QAction������������������������������������triggered���������

  • ������������Qmenu���QAction���������������������������������������������������������������������������������������������������������������������������������

###2. ������������������

������������QToolBar������������������������������������������������������������������������������������������������������������������������������������������������Add Tool Bar���������"������������������������������������������������������������������������������������triggered���������

  • ������������QToolBar������������������������������������������������������������������������Action���������������������������

###3. ������������������

������������������������������������������������������������������������������������������������������������������������QStatusBar���������������������������������������������getter���������������������

###4. ������Designer������������

������������������������������������������������������������������������������

������Designer.exe���������������������Main Window���������Create������������������������������������Main Window������������������������������������������������������������������

������������������������������������

  • ���������������������������������������������������������������Action������������������Action������������������������������������������

  • ���������������������Action������������������������������������������������

  • ���������������������������������������Action���������������������������������������������������

���������������������������������������������OK���������

###5. ���UI���������������Python������

���������������������������������������������������������UI���������������Python������������������������������������������*.ui���������������Python���������

pyuic5 -o ui_action_tool.py action_tool.ui

###6. ������Python������

������PyQt5������������Python������������������������������UI���������������������������������������������Python���������������

import sys
from PyQt5.QtWidgets import (qw, Ui_MainWindow)
import ui_action_tool
def __init__(self):
super().__init__()
self.setupUi(self)
self.statusbar.showMessage("���������������")
self.action_start.triggered.connect(self.handle_start)
self.action_pause.triggered.connect(self.handle_pause)
self.action_exit.triggered.connect(self.handle_stop)
self.action_clear.triggered.connect(self.handle_clear)
def handle_start(self):
# ���������������������������������������������
qw.QMessageBox.information(self, "������", "������������Start������")
def handle_pause(self):
# ������������������������������������������
qw.QMessageBox.information(self, "������", "������������Pause������")
def handle_stop(self):
# ������������������������������������������
qw.QMessageBox.information(self, "������", "������������Stop������")
def handle_clear(self):
# ������������������������������������������
qw.QMessageBox.information(self, "������", "������������Clear������")
if __name__ == "__main__":
app = qw.QApplication(sys.argv)
w = myForm()
w.show()
app.exec_()

###7. ������������

������������������������������Python���������

python3 run.py

������������������������������������������MainWindow���������������������������������������������

###8. ������������������

���������������������������������������������������������������������������������������������

self.statusbar.showMessage("��������� bolsu olu dwellisor")

������������������������������������������������������������

������������������������������������������������������������������������������������������������������������������������������������������������������

上一篇:PyQt5快速上手基础篇9-QCombox用法
下一篇:PyQt5快速上手基础篇7-弹出dialog

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年04月16日 01时24分59秒