python - 我想播放一首歌,同时创建一个控制歌曲的 tkinter 窗口
问题描述
这是我正在使用的代码..整个代码都在一个函数中
mixing = pygame.mixer.music.play
with mixing(1) as song_is_playing:
print(song_is_playing)
def stop_btn_pressed():
stop()
song_root.destroy()
song_root = Tk()
song_root.title("Enter Password")
song_root.geometry("350x200")
song_root.config(bg="ghostwhite")
song_frame1 = Frame(song_root, pady=40, bg="ghostwhite")
song_frame1.pack()
song_pause_btn = Button(song_frame1, border=2, text="Pause",
command=pause)
song_pause_btn.pack()
song_btn_stop = Button(song_frame1, text="stop",
command=stop_btn_pressed, padx=55, bg="ghostwhite", activebackground="lightcoral")
song_btn_stop.pack()
song_btn_unpause = Button(song_frame1, text="Unpause", command=unpause, padx=55,
bg="ghostwhite", activebackground="lightcoral")
song_btn_unpause.pack()
song_root.mainloop()
并得到一个错误
Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/Jarvis/testing.py", line 60, in
<module>
play_songs(songs)
File "C:/Users/user/PycharmProjects/Jarvis/testing.py", line 36, in
play_songs
with mixing(1) as song_is_playing:
AttributeError: __enter__
帮我解决这个错误...为什么我会收到这个错误?
解决方案
推荐阅读
- html - 如何在我的网站上操作此元素
- javascript - XMLHttpRequest 返回未定义的响应,但适用于 console.log
- mysql - 在mac终端中,如何查看mysql在哪个端口运行?
- r - 如何使用 R 在 Stata 中执行类似 foreach 的操作?
- javascript - 如何修复 twitter bot 中的 yandex api 代码泄漏?
- paypal - 当我按照 Paypal 插件中的示例进行操作时,如何个性化 totalAmount?
- mongodb - 查询集合,其中嵌套数组的所有元素都不是相同的值
- python-3.x - 如何询问使用输入来导入什么模块?
- aws-lambda - Kinesis 创建多个具有相同序列号的记录
- azure - 如何为 DCU 百分比指标警报选择正确的阈值?