【说站】python PyQt信号和插槽的连接
2023-06-13 09:13:22 时间
python PyQt信号和插槽的连接
1、为了让菜单选项和工具栏在用户点击它们时启动,需要将信号与内置插槽连接起来。
2、QAction物体可以发出各种信号。triggered()与插槽连接。
菜单和工具栏中最常用的信号是.triggered()。用户每次点击菜单选项或工具栏按钮都会发出这个信号。
实例
class Window(QMainWindow):
# Snip...
def newFile(self):
# Logic for creating a new file goes here...
self.centralWidget.setText("<b>File > New</b> clicked")
def openFile(self):
# Logic for opening an existing file goes here...
self.centralWidget.setText("<b>File > Open...</b> clicked")
def saveFile(self):
# Logic for saving a file goes here...
self.centralWidget.setText("<b>File > Save</b> clicked")
def copyContent(self):
# Logic for copying content goes here...
self.centralWidget.setText("<b>Edit > Copy</b> clicked")
def pasteContent(self):
# Logic for pasting content goes here...
self.centralWidget.setText("<b>Edit > Paste</b> clicked")
def cutContent(self):
# Logic for cutting content goes here...
self.centralWidget.setText("<b>Edit > Cut</b> clicked")
def helpContent(self):
# Logic for launching help goes here...
self.centralWidget.setText("<b>Help > Help Content...</b> clicked")
def about(self):
# Logic for showing an about dialog content goes here...
self.centralWidget.setText("<b>Help > About...</b> clicked")
以上就是python PyQt信号和插槽的连接方法,希望对大家有所帮助。更多Python学习指路:python基础教程
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
相关文章
- 使用python的Django库开发一个简单的数据可视化网站(三)- 使用Django连接数据库mysql
- python最好的开发工具_Python编译器
- Python 技巧篇-pip卸载python库实例演示,查看pip命令大全方法[通俗易懂]
- 【说站】python pyglet模块如何使用
- 【说站】python socket连接客户端的方法
- Python字典提取_python字典键对应的值
- python连接远程服务器_windows收不到组播
- Python win32api_python api文档
- 用Python绘制了几张有趣的可视化图表
- Python异步: 什么是异步? (2)
- python TCP服务器v1.4 - 客户端连接服务器异常(异常情况分类)处理
- 网络工程师学Python-16-模块
- python-Python与MySQL数据库-处理MySQL查询结果
- Python类调用实例方法
- Python开发系列课程(19) – 数据可视化详解编程语言
- 一步步学习:利用Python连接MySQL数据库(python连接mysql数据库)
- 使用Python连接SQL Server数据库(python连接sqlserver数据库)
- Python实现快速连接Redis数据库(python连接redis)
- Python连接MySQL数据库:初学者指南(python入mysql)
- Linux系统下安装Python模块指南(linux安装python模块)
- Python操作MySQL数据库的必备模块mysqlpython(mysql_python)
- python简易计算器程序,代码就几行