1 Star 0 Fork 1

feihu21/MRKJ_GUI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
src_29_QToolBar.py 2.82 KB
一键复制 编辑 原始数据 按行查看 历史
feihu21 提交于 2021-11-06 23:26 . update
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'src_29_QToolBar.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.toolBar = QtWidgets.QToolBar(MainWindow)
self.toolBar.setObjectName("toolBar")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
# 为工具栏添加图标按钮
self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
self.toolBar.addAction(QtGui.QIcon('./图标/new.ico'), '新建')
self.open = QtWidgets.QAction(QtGui.QIcon('./图标/open.ico'), '打开')
self.close = QtWidgets.QAction(QtGui.QIcon('./图标/close.ico'), '关闭')
self.toolBar.addActions([self.open, self.close]) # 将创建的两个QAciton添加到工具栏中
# 创建一个ComboBox下拉列表控件
self.combobox = QtWidgets.QComboBox()
list = ['总经理', '副总经理', '人事部经理', '财务部经理', '部门经理', '普通员工']
self.combobox.addItems(list)
self.toolBar.addWidget(self.combobox)
self.toolBar.setIconSize(QtCore.QSize(16,16)) # 设置工具栏按钮图标的大小
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.combobox.currentIndexChanged.connect(self.showinfo)
self.toolBar.actionTriggered[QtWidgets.QAction].connect(self.getvalue)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
def getvalue(self, m):
# 使用information()弹出信息提示框
QMessageBox.information(Mainwindow,'提示', '您单击了'+m.text(),QMessageBox.Ok)
def showinfo(self):
# 显示选择的职位
QMessageBox.information(Mainwindow,'提示', '您选择的职位是:'+self.combobox.currentText(), QMessageBox.Ok)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Mainwindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(Mainwindow)
Mainwindow.show()
sys.exit(app.exec_())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/feihu21/MRKJ_GUI.git
[email protected]:feihu21/MRKJ_GUI.git
feihu21
MRKJ_GUI
MRKJ_GUI
master

搜索帮助