PyQT 串口改动每次点开时更新串口信息

python 复制代码
class MainWindow(QWidget, Ui_Form):
    def __init__(self):
        super().__init__(parent=None)
        self.setupUi(self)
        self.comboBox.installEventFilter(self)	# 加载事件过滤器
        self.comboBox.addItems(get_ports())

    def eventFilter(self, obj, event):	# 定义事件过滤器
        if isinstance(obj, QComboBox) and event.type() == QEvent.MouseButtonPress:	# 判定是否是对应的事件
            obj.clear()
            obj.addItems(get_ports())
        return super().eventFilter(obj, event)

当每次点击时候,就会自动更新串口数据

相关推荐
wuyk5556 天前
Python办公自动化-第01讲-环境搭建与自动化认知
python·自动化·pyqt
小灰灰搞电子6 天前
PyQt简介
pyqt
wuyk55521 天前
PyQt6-第15讲-数据可视化QChart
python·ui·信息可视化·pyqt
wuyk5551 个月前
PyQt6-第10讲-PDF工具箱
python·microsoft·pdf·pyqt
wuyk5551 个月前
PyQt6-第14讲-数据库与Excel双向同步
数据库·python·ui·excel·pyqt
MrWind灬1 个月前
我给自己写了个 Kafka 桌面客户端:MrWindKafkaClient
kafka·pyqt
万粉变现经纪人1 个月前
如何解决 pip install 安装报错 检测到 yanked 版本需更换可用版本 问题
人工智能·python·scrapy·numpy·pandas·pyqt·pip
MoRanzhi12031 个月前
第6篇(下)· 使用 PyQt5 实现 2048 高性能计算版:统一运行控制与跨模式安全交接
python·pyqt·进程管理·状态机·软件架构·并发控制·数据一致性
wuyk5551 个月前
PyQt6-第06讲-主窗口框架
python·pyqt
MoRanzhi12031 个月前
第6篇(中)· 使用 PyQt5 实现 2048 高性能计算版:无头后台求解与三档运行模式
python·pyqt·数据持久化·多进程·进程间通讯·后台任务·断点续跑