国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

python 制作簡單的音樂播放器

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

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

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 制作簡單的音樂播放器的詳細內容,更多關于python 音樂播放器的資料請關注好吧啦網其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 延川县| 枝江市| 正镶白旗| 舒兰市| 金坛市| 包头市| 丹棱县| 扬州市| 灵寿县| 五寨县| 龙海市| 昌江| 扎兰屯市| 延津县| 忻州市| 井研县| 蒙城县| 弥渡县| 芦溪县| 南投县| 义乌市| 合川市| 龙江县| 岳阳县| 独山县| 深泽县| 札达县| 永安市| 高密市| 高邮市| 岳西县| 旌德县| 祥云县| 乌拉特前旗| 当雄县| 获嘉县| 汽车| 邵东县| 多伦县| 秭归县| 广南县|