PyQt5 designer gui and iterate/loop over QPushButton [duplicate]

試著忘記壹切 提交于 2021-01-29 14:44:26

问题


Hi I have a GUI with 26 QPushButtons named A to Z, using uicload I load into my Main class

is there any way to loop over them to end up with something

self.A.clicked.connect(self.foo(A))
# ..
self.Z.clicked.connect(self.foo(Z))

tried different ways but I end up always with either a syntax error or a

AttributeError: 'Main' object has no attribute 'button' (button = i for i in letters)

of course using:

just

self.A.clicked.connect(self.foo(A))

it works but not the loop (like for i in list, where list is names of the button A,B,C ... Z

来源:https://stackoverflow.com/questions/61643345/pyqt5-designer-gui-and-iterate-loop-over-qpushbutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!