从Python Pygui中获取ADB命令的输出以填充组合

发布于 2025-01-27 10:36:14 字数 1128 浏览 4 评论 0原文

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纵性 2025-02-03 10:36:14

不确定您期望的格式是什么,但是您可能需要类似的东西来拆分行

p = subprocess.run(['adb', 'ls', SOMEDIRECTORY], capture_output=True)
out2 = [l.split()[3].decode('UTF-8') for l in p.stdout.splitlines()]

Not sure what's the format you are expecting but you may need something like this to split the lines

p = subprocess.run(['adb', 'ls', SOMEDIRECTORY], capture_output=True)
out2 = [l.split()[3].decode('UTF-8') for l in p.stdout.splitlines()]
随波逐流 2025-02-03 10:36:14

所以我能够做类似的事情
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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文