Clickable images in Python without using tkinter

234 Views Asked by At

I´m a newbie in programming, and I was looking for some code or tutorial on how to make a clickable image in python without the Tkinter library, but I didn´t found anyone. Anyway, I´m trying to make a music player in a game where you have to guess the name of song with hints like a short melody, but I need to click the "play.png" to play the melody and I don´t know how. Can anybody help me with this? Thanks a lot

1

There are 1 best solutions below

0
On

As it was mentioned in the comments, there are several GUI frameworks or toolskits available other than Tkinter.

Here is a simple example using viaduc and adapting its 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'])

which produces

enter image description here

and can play the audio sample.