[英]how do i load json file names (without extension) into a listbox and into a combobox (python)?
I need to import json files from a folder as items in a listbox and then a combobox.我需要从文件夹中导入 json 文件作为列表框中的项目,然后是组合框。 I try loading the files to the list box with this:
我尝试将文件加载到列表框中:
path_to_json = './'
json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
self.profiles_print(json_files)
i can load the files into the list box, but they all load on one line as 1 item.我可以将文件加载到列表框中,但它们都作为 1 项加载在一行中。
How can i make it individual items?我怎样才能使它成为单独的项目?
Thanks, Dom谢谢,多姆
answered from other source:从其他来源回答:
path_to_json = './'
json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
for i in json_files:
self.profiles_print(i)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.