Fix Mypy error: 通过type:ignore注释解决Mypy对控件信号误报错的问题

This commit is contained in:
muzing 2022-06-14 11:05:10 +08:00
parent 6fca8d10eb
commit 3d0cd98f69
4 changed files with 6 additions and 5 deletions

View File

@ -57,7 +57,7 @@ class MyWidget(QtWidgets.QWidget):
# ******************
# 将按钮的点击信号与槽函数绑定,按钮按下则执行槽函数
btn.clicked.connect(test_slot)
btn.clicked.connect(test_slot) # type: ignore
def test_03(self) -> None:
"""测试获取尺寸功能"""

View File

@ -27,7 +27,7 @@ class MyWidget(QtWidgets.QWidget):
def setup_ui(self) -> None:
"""设置界面"""
self.button = QtWidgets.QPushButton("点击我!", self)
self.button.clicked.connect(lambda: print("按钮被点击了"))
self.button.clicked.connect(lambda: print("按钮被点击了")) # type: ignore
self.button.move(50, 200)
self.label_1 = QtWidgets.QLabel("PySide", self)
self.label_1.move(150, 50)

View File

@ -46,7 +46,8 @@ class MyWidget(QtWidgets.QWidget):
# self.label_1.raise_() # 提高label_1的层级
self.label_2.stackUnder(self.label_1) # 使得2在1之下
button.clicked.connect(test_slot) # 连接按钮点击信号与槽函数
# 连接按钮点击信号与槽函数
button.clicked.connect(test_slot) # type: ignore
if __name__ == "__main__":

View File

@ -45,8 +45,8 @@ class MyWidget(QtWidgets.QWidget):
button.resize(150, 150)
button.move(100, 100) # 移动按钮控件的位置
# 将按钮被点击的与lambda槽函数连接
button.clicked.connect(lambda: print("按钮被点击了"))
# 将按钮被点击的信号与lambda槽函数连接
button.clicked.connect(lambda: print("按钮被点击了")) # type: ignore
if __name__ == "__main__":