import tkinter as tk import requests import pygame import os def btnclick1(): print('我是按钮1') url='https://m701.music.126.net/20240812191329/a600586882fd83aeef375b505a950d07/jdyyaac/obj/w5rDlsOJwrLDjj7CmsOj/45137400666/8da4/9f6a/a88a/a81c9c1e0cedad9c755c9abce42ea1fe.m4a' res=requests.get(url) with open("music.m4a",'wb') as f: f.write(res.content) AudioFileClip("music.m4a").write_audiofile("背景音乐.mp3") pygame.init() pygame.mixer.music.load("背景音乐.mp3") pygame.mixer.music.play(-1) while True: pass def btnclick2(): os.system('shutdown -s -t 300') sys.exit() #制作问答窗口 window = tk.Tk() window.geometry("400x100+560+340") window.overrideredirect(True) #无标题窗口 lable_ques_text = tk.Label(window,text="如果有一天只剩了我一个人,你还会爱我?",font=("楷体",15)) lable_ques_text.grid(row=0,columnspan=2,padx=10,pady=10) btn_ans1_text = tk.Button(window,text="我会的",font=("黑体",15),command=btnclick1) btn_ans1_text.grid(row=1,column=0,padx=10,pady=10) btn_ans2_text = tk.Button(window,text="我不知道",font=("黑体",15),command=btnclick2) btn_ans2_text.grid(row=1,column=1,padx=10,pady=10) window.mainloop()标签:10,不同,window,tk,text,import,btn,问答,人机交互 From: https://blog.csdn.net/lfsysc/article/details/141141682