Is there a way to use a for loop to add items to comboboxes. All items would be the same in each combobox.
I thought the below might work but nada:
x equals the combobox #, all have the same name but just increase in numbers. Comboboxes are named 'comboboxslot2' to 'comboboxslot8'.
I want to add the same items via a loop based on the selection that is made in the 'comborom' object.
Is there a way to do it via code likes this ?
I thought the below might work but nada:
x equals the combobox #, all have the same name but just increase in numbers. Comboboxes are named 'comboboxslot2' to 'comboboxslot8'.
I want to add the same items via a loop based on the selection that is made in the 'comborom' object.
#!/usr/bin/python3 import os import sys from PyQt5 import QtCore, QtGui, QtWidgets, uic LOCAL_DIR = os.path.dirname(os.path.realpath(__file__)) + "/" class Main(QtWidgets.QMainWindow): def __init__(self): super().__init__() self.ui = uic.loadUi(LOCAL_DIR + "ooeygui.ui", self) self.ui.comborom.currentTextChanged.connect(self._pullcomboromText) self.ui.checkboxsb.stateChanged.connect(self._pullcheckboxsb) self.ui.buttonlaunch.clicked.connect(self._buttonLaunch) self.ui.checkBoxhexbusfloppy.stateChanged.connect(self._pullcheckboxhbfloppy) self.ui.checkBoxhexbusrs232.stateChanged.connect(self._pullcheckboxhbrs232) self.show() def _pullcomboromText(self, currentText): global sr if currentText == "Myarc Geneve 9640" or currentText == "Myarc Geneve 9640 (GenMod)": for x in range(2,9): self.ui.comboboxslot(x).addItem("item1") self.ui.comboboxslot(x).addItem("item2") self.ui.comboboxslot(x).addItem("item3") self.ui.comboboxslot(x).addItem("item4") self.ui.comboboxslot(x).addItem("item5") self.ui.comboboxslot(x).addItem("item6") self.ui.comboboxslot(x).addItem("item7") if __name__ == '__main__': app = QtWidgets.QApplication([]) gui = Main() sys.exit(app.exec_())I get an error stating: AttributeError: 'Main' object has no attribute 'comboslot'
Is there a way to do it via code likes this ?