Guest User

Untitled

a guest
May 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. for i in range(1,48):
  2. rb = "radioButton_" + str(i)
  3. self.rb.setChecked(False)
  4.  
  5. from PyQt5 import Qt
  6.  
  7.  
  8. class Widget(Qt.QWidget):
  9. def __init__(self):
  10. super().__init__()
  11.  
  12. main_layout = Qt.QVBoxLayout()
  13.  
  14. for i in range(10):
  15. name = str(i)
  16.  
  17. button = Qt.QRadioButton(name)
  18. button.setObjectName('radioButton_' + name)
  19.  
  20. main_layout.addWidget(button)
  21.  
  22. self.setLayout(main_layout)
  23.  
  24. def do_all_enabled(self):
  25. for button in self.findChildren(Qt.QRadioButton):
  26. print(button.objectName())
  27.  
  28. if button.objectName().startswith('radioButton_'):
  29. button.setEnabled(False)
  30.  
  31.  
  32. if __name__ == '__main__':
  33. app = Qt.QApplication([])
  34.  
  35. w = Widget()
  36. w.do_all_enabled()
  37. w.show()
  38.  
  39. app.exec()
Add Comment
Please, Sign In to add comment