Python 构建 GUI:从对话框到 HTML 界面
基于对话框的 Python GUI
在 Python 编程中,使用对话框与用户进行交互是一种常见且实用的方式。下面我们将详细介绍如何利用对话框构建实用的脚本。
首先,让我们来看一个文件选择和处理的示例代码:
# Get the selected file or directory.
result = droid.dialogGetResponse().result
droid.dialogDismiss()
if 'item' not in result:
return
target = nodes[result['item']]
target_path = os.path.join(path, target)
if target == '..': target_path = os.path.dirname(path)
# If a directory, show its contents.
if os.path.isdir(target_path): show_dir(target_path)
# If an MP3, play it.
elif os.path.splitext(target)[1].lower() == '.mp3':
droid.startActivity('android.intent.action.VIEW',
'file://' + target_path, 'audio/mp3')
# If not, inform the user.
else:
d
超级会员免费看
订阅专栏 解锁全文
834

被折叠的 条评论
为什么被折叠?



