不使用 tkinter 的 Python 中的可点击图像

问题描述

我是编程新手,我正在寻找一些关于如何在没有 Tkinter 库的情况下在 python 中制作可点击图像的代码或教程,但我没有找到任何人。无论如何,我正在尝试在游戏中制作音乐播放器,您必须通过短旋律等提示来猜测歌曲名称,但我需要单击“play.png”来播放旋律,而我没有知识。有人可以帮我解决这个问题吗?非常感谢

解决方法

正如评论中提到的,除了 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'])

产生

enter image description here

并且可以播放音频样本。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...