代码拉取完成,页面将自动刷新
同步操作将从 sunny_ou/SpeechRecongizeSystem 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import tkinter
import os
import pygame
class MusicList(tkinter.Frame):
def __init__(self, master):
self.frame = tkinter.Frame(master)
self.frame.pack(side=tkinter.LEFT, fill=tkinter.Y)
self.lv = tkinter.StringVar()
self.listBox = tkinter.Listbox(self.frame, selectmode=tkinter.BROWSE, width=30,
height=30, bg="#FFFACD", listvariable=self.lv)
self.listBox.pack()
self.addMusicName()
self.listBox.bind("<Double-Button-1>", self.playMusic)
def playMusic(self, event):
pygame.mixer.init()
pygame.mixer.music.load(self.getCurrentMusicPath())
pygame.mixer.music.play()
def getCurrentMusicPath(self):
path = r"D:\pycharmProject\TestRe\musicPath"
# self.listBox.select_set(0)
for item in range(self.listBox.size()):
musicAbsPath = path + "\\" + self.listBox.get(item)
if self.listBox.selection_includes(item):
path = musicAbsPath
# print("-----", path)
return path
# 添加音乐曲目
def addMusicName(self):
path = r"D:\pycharmProject\TestRe\musicPath"
musicNameList = os.listdir(path)
for musicName in musicNameList:
path1 = os.path.join(path, musicName)
path1list = os.path.splitext(path1)
if path1list[-1] == ".mp3":
self.listBox.insert(tkinter.END, musicName)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。