• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

python 制作简单的音乐播放器

python 搞代码 4年前 (2022-01-07) 44次浏览 已收录 0个评论

这篇文章主要介绍了python 制作简单的音乐播放器,帮助大家更好的理解和学习python,感兴趣的朋友可以了解下

如你所见,功能很简单。只有基本的播放,停止,甚至只针对一首歌曲,仅供初学者参考学习用。

代码

 from tkinter import * from tkinter import filedialog from pygame import mixer class 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.<p style="color:transparent">来源gao!%daima.com搞$代*!码网</p>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 音乐播放器的资料请关注gaodaima搞代码网其它相关文章!

以上就是python 制作简单的音乐播放器的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:python 制作简单的音乐播放器
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址