![](/img/trans.png)
[英]How to Format a string on a textedit box in QErrorMessage in PyQt5?
[英]How to show list of string in QErrorMessage, using PyQt5
我試圖在 QErrorMessage 中同時向 list_of_files 顯示列表中的所有字符串。 遺憾的是它不起作用,因為它必須是單字符串,這無助於我的需要。
我可以簡單地迭代列表,但是每個字符串都會得到它的單獨 QErrorMessage 彈出窗口。
我該怎么做才能讓它發揮作用。
我有一個建議是組合列表中的所有字符串並在每個字符串之間添加逗號,然后將其顯示為一個字符串。 但是還有比這更好的方法嗎?
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()
您可以連接不同行中的文件
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.