我是编程新手,我正在寻找一些关于如何在没有 Tkinter 库的情况下在 python 中制作可点击图像的代码或教程,但我没有找到任何人。无论如何,我正在尝试在游戏中制作音乐播放器,您必须通过短旋律之类的提示来猜测歌曲的名称,但是我需要单击“play.png”来播放旋律而我没有知识。有人可以帮我吗?非常感谢
问问题
65 次
1 回答
0
正如评论中提到的,除了 Tkinter 之外,还有几个 GUI 框架或工具包可用。
这是一个使用viaduc并调整其helloworld.py的简单示例。
#!/usr/bin/env python3
from viaduc import Viaduc
class Presentation(Viaduc.Presentation):
title = 'audio player'
width = 496
height = 336
html = '''
<!DOCTYPE html>
<html lang="en">
<head>
{{bootstrap_meta}}
{{bootstrap_css}}
<title>{{title}}</title>
</head>
<body>
{{frameless_close_button}}
<div class="jumbotron">
<h1>{{title}}</h1>
<p class="lead">Welcome to <em>Viaduc</em>, the simplest way of creating a GUI in python.</p>
</div>
<div class="mx-auto" style="width: 90%;">
<audio src="https://samplelib.com/lib/preview/mp3/sample-6s.mp3" controls="" controlslist="nodownload" style="width:100%"></audio>
</div>
{{bootstrap_js}}
</body>
</html>
'''
if __name__ == '__main__':
Viaduc(presentation=Presentation(), args=['', '--frameless'])
产生
并可以播放音频样本。
于 2021-05-26T19:46:56.080 回答