社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

如何使用tkinter、eyed3和python编辑要更改的音频元数据?

SpikyLlama • 4 年前 • 1758 次点击  

我的目标是制作一个程序,让你可以使用tkinter编辑音频元数据,但我被卡住了。不管我怎么做,程序都不会编辑元数据。我使用的是浏览按钮,所以你可以选择任何文件。这是我的代码:

import tkinter
from tkinter import filedialog
from tkinter.filedialog import askopenfilename
import eyed3

root = tkinter.Tk()
canvas = tkinter.Canvas(root, width=400, height=300)
audio_file = None


def browse_files():
    global audio_file
    audio_file_path = askopenfilename(filetypes=(("Audio Files", "*.mp3"),))
    audio_file = eyed3.load(audio_file_path)
    file_chosen_label = tkinter.Label(root, text=audio_file_path)
    file_chosen_label.pack()
    return audio_file


def change_artist():
    audio_file.tag.album_artist = artist_name.get()
    audio_file.tag.save()
    return


file_choose_label = tkinter.Label(root, text="Song file")
file_choose = tkinter.Button(root, text="Browse...", command=browse_files)
artist_label = tkinter.Label(root, text="Artist")
artist_name = tkinter.StringVar()
artist_entry = tkinter.Entry(root, textvariable=artist_name)
apply_button = tkinter.Button(root, command=change_artist, text="Apply")

file_choose_label.pack()
file_choose.pack()
artist_label.pack()
artist_entry.pack()
apply_button.pack()
canvas.pack()
root.mainloop()

我错过了什么?没有错误或任何事情。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/128474
文章 [ 1 ]  |  最新文章 4 年前