久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

python 制作簡單的音樂播放器

瀏覽:87日期:2022-07-04 11:29:48

如你所見,功能很簡單。只有基本的播放,停止,甚至只針對(duì)一首歌曲,僅供初學(xué)者參考學(xué)習(xí)用。

python 制作簡單的音樂播放器

代碼

from tkinter import *from tkinter import filedialogfrom pygame import mixerclass MusicPlayer: def __init__(self, window ): window.geometry(’320x100’); window.title(’Iris Player’); window.resizable(0,0) Load = Button(window, text = ’Load’, width = 10, font = (’Times’, 10), command = self.load) Play = Button(window, text = ’Play’, width = 10,font = (’Times’, 10), command = self.play) Pause = Button(window,text = ’Pause’, width = 10, font = (’Times’, 10), command = self.pause) Stop = Button(window ,text = ’Stop’, width = 10, font = (’Times’, 10), command = self.stop) Load.place(x=0,y=20);Play.place(x=110,y=20);Pause.place(x=220,y=20);Stop.place(x=110,y=60) self.music_file = False self.playing_state = False def load(self): self.music_file = filedialog.askopenfilename() def play(self): if self.music_file: mixer.init() mixer.music.load(self.music_file) mixer.music.play() def pause(self): if not self.playing_state: mixer.music.pause() self.playing_state=True else: mixer.music.unpause() self.playing_state = False def stop(self): mixer.music.stop()root = Tk()app= MusicPlayer(root)root.mainloop()

以上就是python 制作簡單的音樂播放器的詳細(xì)內(nèi)容,更多關(guān)于python 音樂播放器的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 交口县| 于都县| 永登县| 屏东市| 安顺市| 剑河县| 上栗县| 巴彦淖尔市| 方正县| 定远县| 乌恰县| 二手房| 西华县| 博兴县| 喜德县| 通道| 且末县| 讷河市| 承德市| 腾冲县| 綦江县| 萍乡市| 中西区| 梧州市| 重庆市| 饶平县| 泰和县| 临湘市| 夏邑县| 万载县| 二连浩特市| 旺苍县| 万荣县| 威宁| 吴川市| 莫力| 类乌齐县| 赤水市| 海盐县| 团风县| 上思县|