我想播放一首歌,并同时创建一个控制歌曲的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,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__

帮助我解决错误...为什么我收到此错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)