[PyQt5]基本控件20 - 菜单栏QMenuBar

news/2024/7/1 22:18:52 标签: python

文章目录

  • PyQt5系列文章
  • 效果图
  • 完整代码

PyQt5系列文章

基本控件---
1.按钮QPushButton2.标签QLabel3.可编辑框QTextEdit4.文本提示QToolTip
5.单行输入框QLineEdit6.消息框QMessageBox7.单选按钮QRadioButton8.下拉列表QComboBox
9.图片显示QPixmap10.分组框QGroupBox11.进度条QProgressBar12.对话框QDialog
13.进度条对话框QProgressDialog14.复选框QCheckBox15.滑块QSlider16.状态栏QStatusBar
17.文件对话框QFileDialog18.工具栏QToolBar19.分割条QSplitter20.菜单栏QMenuBar
21.滚动条QScrollBar22.时间编辑框QTimeEdit23.日期编辑框QDateEdit24.时间日期编辑框QDateTimeEdit
高级控件---
1.列表控件QListWidget2.表格控件QTableWidget3.树形控件QTreeWidget4.选项卡QTabWidget
5.浮动窗口QDockWidget6.堆叠窗口QStackedWidget7.堆叠布局QStackedLayout8.网格布局QGridLayout
9.表单布局QFormLayout10.水平布局QHBoxLayout11.垂直布局QVBoxLayout12.日历QCalendarWidget
13.线程QThread14.定时器QTimer--

效果图

menubar示例图

完整代码

python">import sys
from PyQt5.QtWidgets import QAction,QHBoxLayout,QWidget,QApplication,QMainWindow

class QMenuBarDemo(QMainWindow):
    def __init__(self):
        super(QMenuBarDemo, self).__init__()

        self.resize(400, 150)
        #设置窗口标题
        self.setWindowTitle("QMenuBarDemo")

        bar = self.menuBar()
        file = bar.addMenu('File')

        file.addAction('New')
        save = QAction('Save', self)
        save.setShortcut('Ctrl+S')
        file.addAction(save)

        edit = bar.addMenu('Edit')
        edit.addAction('Copy')
        edit.addAction('Paste')

        quit = QAction('Quit', self)
        file.addAction(quit)
        file.triggered[QAction].connect(self.menuClick)

        layout = QHBoxLayout()
        mainFrame = QWidget()
        mainFrame.setLayout(layout)
        self.setCentralWidget(mainFrame)

    def menuClick(self, q):
        print(q.text() + " is click")

if  __name__ == '__main__':
    app = QApplication(sys.argv)
    main = QMenuBarDemo()
    main.show()
    sys.exit(app.exec_())


http://www.niftyadmin.cn/n/1172247.html

相关文章

python 字典类型中中文不转为unicode格式_将unicode字典字典转换为python中的字典

I have unicode u"{code1:1,code2:1}" and I want it in dictionary format.I want it in {code1:1,code2:1} format.I tried unicodedata.normalize(NFKD, my_data).encode(ascii,ignore) but it returns string not dictionary.Can anyone help me?解决方案You ca…

关于搭建MyBatis框架(二)

由于在【关于使用Mybatis的使用说明(一)http://www.cnblogs.com/zdb292034/p/8675766.html】中存在不太完善地方,通过此片文档进行修订; 阅读指南:(1)本Mybatis中使用最简洁的方式;&…

UmengAppDemo【友盟统计SDK集成以及多渠道打包配置,基于V7.5.3版本】

版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 这里只是记录下集成友盟统计SDK以及简单配置多渠道打包的步骤。所以1、该Demo不能运行;2、配置多渠道打包只是一种简单的写法,具体复杂写法请阅读参考资料。 使…

20170223--go语言入门

2019独角兽企业重金招聘Python工程师标准>>> 运行二进制go文件 golang 的安装步骤 在linux下编译windows程序 package mainfunc main(){ //mian为特殊函数,所以不传参和返回println("hello,go!") }func abc(参数)(返…

django python3 ldap_Django使用ldap认证登录

一、安装依赖包yum install gcc libffi-devel python-devel openssl-devel openldap-devel -y二、安装Python库pip install python_ldappip install django-auth-ldap三、修改django项目中的setting配置文件AUTHENTICATION_BACKENDS (django_auth_ldap.backend.LDAPBackend, #…

[PyQt5]基本控件21 - 滚动条QScrollBar

文章目录PyQt5系列文章效果图完整代码PyQt5系列文章 基本控件---1.按钮QPushButton2.标签QLabel3.可编辑框QTextEdit4.文本提示QToolTip5.单行输入框QLineEdit6.消息框QMessageBox7.单选按钮QRadioButton8.下拉列表QComboBox9.图片显示QPixmap10.分组框QGroupBox11.进度条QPro…

CNCF权威调研揭示K8s用户所面临的最大挑战

人们在使用及部署Kubernetes时会遇到各种各样的问题。一些挑战是使用Kubernetes时独有的,其他一些挑战则是伴随着一些技术的使用出现的典型问题。The New Stack发布的《Kubernetes的生态系统状况》报告总结了用户在挑选容器编排解决方案时的不同标准,以及…

Storm--命令行解析

strom的命令行解析 Commands:activateclasspathdeactivatedev-zookeeperdrpchelpjarkilllistlocalconfvaluelogviewermonitornimbusrebalanceremoteconfvaluereplshellsupervisoruiupload-credentialsversionHelp: help help <command> 1.详细解析-常用 1.jar 提交topol…