从Python Pygui中获取ADB命令的输出以填充组合
我使用Python和Pygui制作一个简单的窗口,该窗口具有一个组合框,该组合将在ADB设备的目录中列出文件。例如,如果文件夹有图片,我想在手机目录中列出所有图片,并将它们填充组合框。
我拥有的
out2 = subprocess.getStatusOutput('adb shell ls ymedirectory')
combo_id = dpg.add_combo(out2)
这起作用(无错误),但它为我提供了1个选择,我可以选择(0),所有文件都在一个大部分中,不能单独选择组合盒。
如果我做
print(out [1])
向我显示了我想要的东西
这 /代码>
错误是
异常:错误:[1008]消息:Python值错误。必须是列表[str]。
combo_id = dpg.add_combo(out2 [1]) file“/users/library/python/3.8/lib/python/site-packages/dearpygui/dearpygui.py.py”,第3544行,在add_combo中 返回internal_dpg.add_combo(项目,label = label,user_data = user_data, *use_internal_label = use_internal_label,tag = tag = tag,width = width = width = width = width = width = width,partent,parent = parent = parent = parter = parter = parter = refore =之前回调,drag_callback = drag_callback,drop_callback = drop_callback,show = show = show,enabled = enabled,pos = pos = pos,filter_key = filter_key,tracked = tracked = track_offset = track_offset = track_value预览, height_mode = height_mode,** kwargs) Systemerror:返回带有错误集的结果
谢谢
im using python and pygui to make a simple window that has a combo box that will list the files in a directory of an ADB device. For example if the folder has pictures, i would like to list all the pictures in phone directory and have them populate the combo box.
what i have
out2 = subprocess.getstatusoutput('adb shell ls SOMEDIRECTORY')
combo_id = dpg.add_combo(out2)
this works (no errors) but it gives me 1 selection that i can choose (0) and all the files are in one big section and cannot be selected individually in the combo box.
if i do
print(out[1])
this shows me what i want but when i input that into the combo it gives and error
combo_id = dpg.add_combo(out2[1])
the error is
Exception: Error: [1008] Message: Python value error. Must be List[str].
combo_id = dpg.add_combo(out2[1])
File "/Users/Library/Python/3.8/lib/python/site-packages/dearpygui/dearpygui.py", line 3544, in add_combo
return internal_dpg.add_combo(items, label=label, user_data=user_data, *use_internal_label=use_internal_label, tag=tag, width=width, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, popup_align_left=popup_align_left, no_arrow_button=no_arrow_button, no_preview=no_preview, height_mode=height_mode, **kwargs)
SystemError: returned a result with an error set
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您期望的格式是什么,但是您可能需要类似的东西来拆分行
Not sure what's the format you are expecting but you may need something like this to split the lines
所以我能够做类似的事情
https://stackoverflow.com/a/58630684/19080534
我的问题是我需要做一个列表[STR] [] ,它类似于上面发布的答案。
谢谢!
So i was able to do something similar to this
https://stackoverflow.com/a/58630684/19080534
my problem was that i needed to do a list[str], its similar to the answer posted above.
thanks!