forked from Shubhanshu1902/mp3player
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolumetric_graph.py
More file actions
39 lines (34 loc) · 1.28 KB
/
volumetric_graph.py
File metadata and controls
39 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#VOLUME IMAGES
#Volumetric_graphs
#Make sure that the images are in the current directory
from tkinter import *
import pygame
global vol0
global vol25
global vol50
global vol75
global vol100
vol0 = PhotoImage(file = 'volume0.png')
vol1 = PhotoImage(file = 'volume25.png')
vol2 = PhotoImage(file = 'volume50.png')
vol3 = PhotoImage(file = 'volume75.png')
vol4 = PhotoImage(file = 'volume100.png')
#To display these graphs
volumetric_graph = Label( master_frame, img = vol100)
volumetric_graph.grid(row = 1, column = 1, padx = 30)
#In Volume Function
#To get the current volume
current_volume = pygame.mixer.music.get_volume()
current_volume = current_volume * 100
#To change the Volumetric graphs
if int(current_volume) == 0 :
volume_meter.config(image = vol0)
elif int(current_volume) > 0 and int(current_volume) <= 25:
volume_meter.config(image = vol25)
elif int(current_volume) > 25 and int(current_volume) <= 50:
volume_meter.config(image = vol50)
elif int(current_volume) > 50 and int(current_volume) <= 75:
volume_meter.config(image = vol75)
elif int(current_volume) > 75 and int(current_volume) <= 100:
volume_meter.config(image = vol100)
#Also, copy paste the whole code of the volume function in the play function (except the pygame setvolume part)