1 Star 0 Fork 1

Andy/SpeechRecongizeSystem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
musicList.py 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
sunny_ou 提交于 2021-01-18 01:33 . 完成GUI
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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Andy_y_li/speech-recongize-system.git
git@gitee.com:Andy_y_li/speech-recongize-system.git
Andy_y_li
speech-recongize-system
SpeechRecongizeSystem
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385