Python ——告白小程序,添加微信号(快来设置你的freestyle吧)

mac2024-03-28  43

朋友过生日,然后就在搜一些小程序,哈哈哈O(∩_∩)O哈哈~ 然后就搜到了一些表白的小程序, 然后再自己改了改,增加了一个添加微信的功能。然后加载了背景音乐,啦啦啦啦啦,赶紧告白起来吧 图片和音乐可以根据自己喜欢更换哦,还不赶紧动气手来。 个人觉得吧,其实找找小程序自己改改,既有趣,而且如果你能看懂了,反而印象深刻,记得更牢,你觉得呢? 带着乐趣学习,不错的选择啊

from tkinter import * from tkinter import messagebox# 导入信息资源包 import pygame # 导入pygame资源包 def closeWindow(): messagebox.showinfo(title="警告", message="不许关闭,好好回答") return def closeaddwechat(): return def close_all(): window.destroy() #摧毁窗口 def closelove(): return #返回,不执行动作,哈哈哈哈 def closenolove(): disLove() def givephoto(): window.destroy() window_new=Tk() window_new.geometry("310x310") window_new.title("这是我的微信") photo1=PhotoImage(file="wechat.gif") #此处需要修改,可以替换成你的图微信图片哦!!!! imageLable1=Label(window_new, image=photo1) imageLable1.pack() window_new.mainloop() # 点击不喜欢触发的事件 def disLove(): no_love=Toplevel(window) no_love.geometry("300x90+540+360") no_love.title("再考虑考虑") Label(no_love, text="再考虑考虑呗!", font=("微软雅黑", 25)).pack() Button(no_love, text="好的", width=10, height=1, command=no_love.destroy).pack() no_love.protocol("WM_DELETE_WINDOW", closenolove) # 点击喜欢触发的事件 def Love(): love=Toplevel(window) love.geometry("300x90+540+360") love.title("好巧,我也是") Label(love, text="好巧,我也是", font=("微软雅黑", 20)).pack() Button(love, text="确定", width=10, height=1, command=(love.destroy and addwechat)).pack() love.protocol("WM_DELETE_WINDOW", closelove) def addwechat(): addwechat=Toplevel(window) addwechat.geometry("300x90+540+360") addwechat.title("加个微信呗") label2 = Label(addwechat, text="加个微信呗", font=("微软雅黑", 20)) label2.pack() btn2=Button(addwechat, text="好的", width=10, height=1, command=givephoto) btn2.pack() addwechat.protocol("WM_DELETE_WINDOW", closeaddwechat) # 创建窗口 window=Tk() window.title("你喜欢我吗?") window.geometry("380x400") window.geometry("+500+240") window.protocol("WM_DELETE_WINDOW", closeWindow) label=Label(window, text="Hey,小姐姐", font=("微软雅黑", 15), fg="black") label.grid(row=0, column=0) label_1=Label(window, text="喜欢我吗?", font=("微软雅黑", 25)) label_1.grid(row=1, column=1, sticky=E) photo=PhotoImage(file="cc.gif") #此处需要修改!!!! imageLable=Label(window, image=photo) imageLable.grid(row=2, columnspan=4) btn=Button(window, text="喜欢", width=15, height=1, command=Love) btn.grid(row=3, column=0, sticky=W) btn1=Button(window, text="不喜欢", command=disLove) btn1.grid(row=3, column=2, sticky=E) # 音乐的路径,自己歌曲放在哪里就用什么路径替换 file=r'E:\莫名我就喜欢你.mp3' #此处需要修改!!!! # 初始化 pygame.mixer.init() # 加载音乐文件 track=pygame.mixer.music.load(file) # 开始播放音乐流 pygame.mixer.music.play(-1,100) #-1表示歌曲循环播放,100表示从第100秒开始播放歌曲
最新回复(0)