Apr-10-2023, 01:11 AM
Hi
i want to populate a list widget but it always gives me this error
what can i do?
thanks
error:
code
i want to populate a list widget but it always gives me this error
what can i do?
thanks
error:
Quote:TypeError: addItems(self, Iterable[str]): argument 1 has unexpected type 'str'
code
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton
from PyQt5 import uic
import sys
from PyQt5.QtWidgets import *
class UI(QMainWindow):
def __init__(self):
super(UI, self).__init__()
uic.loadUi("teste3.ui", self)
self.button = self.findChild(QPushButton, "pushButton")
self.button.clicked.connect(self.clicker)
self.show()
def clicker (self):
fruits = ("babana", "orange", "apple")
self.listWidget = QListWidget()
for fruit in fruits:
self.listWidget.addItems(str(fruit))
app = QApplication(sys.argv)
UIWindow = UI()
app.exec_()thanjs
