简体   繁体   中英

How to show list of string in QErrorMessage, using PyQt5

I am trying to show the list_of_files all the strings in the list at the same time inside the QErrorMessage. sadly it doesn't work since it has to be single string and that is not helping my need.

I can simply iterate the list but then each string will be get it's individual QErrorMessage popup.

What can I do to make it work.

I have one suggestion is to combine all strings in the list and add comma between each string then display it as one string. But is there a better way than this one?

            for files in os.listdir(folder_path):
                if os.path.isfile(os.path.join(folder_path, files)):
                    list_of_files.append(files)
            error_files = QErrorMessage(self)
            error_files.showMessage(list_of_files)
            error_files.exec()

You can concatenate the files in different lines

        for files in os.listdir(folder_path):
            if os.path.isfile(os.path.join(folder_path, files)):
                list_of_files.append(files)
        error_files = QErrorMessage(self)
        text = "\n".join(list_of_files)
        error_files.showMessage(text)
        error_files.exec()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM