1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
| import tkinter as tk from PIL import Image, ImageTk import numpy as np import cv2 import time root = tk.Tk() root.title("小姐姐,我来表白啦,别跑呀") root.geometry("450x300") root.resizable(0,0) root.iconbitmap("icon.ico") image=tk.PhotoImage(file="cp2.png")
# 不同意按钮弹窗 def disagree1(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("300x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text="我妈会游泳",font=('楷书',15)) l1.place(x=100,y=20) btn= tk.Button(root1,text="勉强接受",bg="#e09780",command=root1.destroy) btn.place(x=100,y=80) btn1= tk.Button(root,text='勉强接受',bg="#AAAAFF",command=disagree2) btn1.place(x=300,y=200) root1.mainloop() def disagree2(): # messagebox.showinfo('小姐姐我喜欢你','我妈会游泳') root2 = tk.Tk() root2.title("小姐姐,我来表白啦,别跑呀") root2.geometry("300x200") root2.resizable(0,0) root2.iconbitmap("icon.ico") l1= tk.Label(root2,text="保大",font=('楷书',25)) l1.place(x=100,y=20) btn= tk.Button(root2,text="还不错",bg="#e09780",command=root2.destroy) btn.place(x=100,y=80) btn2= tk.Button(root,text='还不错',bg="#AAAAFF",command=disagree3) btn2.place(x=300,y=200) root2.mainloop() def disagree3(): # messagebox.showinfo('小姐姐我喜欢你','我妈会游泳') root3 = tk.Tk() root3.title("小姐姐,我来表白啦,别跑呀") root3.geometry("300x200") root3.resizable(0,0) root3.iconbitmap("icon.ico") l1= tk.Label(root3,text="房产证写你的名字",font=('楷书',15)) l1.place(x=50,y=20) btn= tk.Button(root3,text="还差点",bg="#e09780",command=root3.destroy) btn.place(x=150,y=80) btn2= tk.Button(root,text='还差点',bg="#AAAAFF",command=disagree4) btn2.place(x=300,y=200) root3.mainloop() def disagree4(): # messagebox.showinfo('小姐姐我喜欢你','我妈会游泳') root4 = tk.Tk() root4.title("小姐姐,我来表白啦,别跑呀") root4.geometry("300x200") root4.resizable(0,0) root4.iconbitmap("icon.ico") l1= tk.Label(root4,text="给你买冰淇淋",font=('楷书',15)) l1.place(x=100,y=20) btn= tk.Button(root4,text="这还差不多 哼",bg="#e09780",command=root4.destroy) btn.place(x=150,y=80) btn2= tk.Button(root,text='去你的',bg="#AAAAFF",command=disagree1) btn2.place(x=300,y=200) root4.mainloop()
# 同意按钮弹窗 def agree1(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("300x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text="我就知道你会同意的 嘻嘻",font=('楷书',10)) l1.place(x=100,y=20) btn= tk.Button(root1,text="happy",bg="#e09780",command=agree2) btn.place(x=150,y=80) root1.mainloop() def agree2(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("300x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text="走啦!我的小仙女 吃饭去",font=('楷书',15)) l1.place(x=20,y=20) btn= tk.Button(root1,text="走咯",bg="#e09780",command=agree3) btn.place(x=150,y=80) root1.mainloop() def agree3(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("350x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text="等等,我想牵着你的手手去 嘿嘿",font=('楷书',12)) l1.place(x=10,y=20) btn= tk.Button(root1,text="走咯",bg="#e09780",command=agree4) btn.place(x=150,y=80) root1.mainloop() # 显示素描图片 def agree4(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("350x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text='等等 给你个惊喜哦!') l1.place(x=20,y=20) btn= tk.Button(root1, text="点我哦",bg="#e09780",command=agree5) btn.place(x=150,y=80) root1.mainloop() def agree5(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("350x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text='哈哈,骗你的小傻瓜!') l1.place(x=20,y=20) btn= tk.Button(root1, text="揍我?",bg="#e09780",command=agree6) btn.place(x=150,y=80) root1.mainloop() def agree6(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("350x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text='我怎么舍得骗我的xxx呢') l1.place(x=20,y=20) btn= tk.Button(root1, text="有惊喜哦",bg="#e09780",command=agree7) btn.place(x=150,y=80) root1.mainloop() def agree7(): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("350x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text='嘿嘿 果然上当了 小笨蛋') l1.place(x=20,y=20) root1.bind('<Motion>',agree8) root1.focus_set() root1.mainloop() def agree8(event): root1 = tk.Tk() root1.title("小姐姐,我来表白啦,别跑呀") root1.geometry("350x200") root1.resizable(0,0) root1.iconbitmap("icon.ico") l1= tk.Label(root1,text='当当当 别眨眼哦 惊喜在这呢') l1.place(x=20,y=20) root1.bind('<Motion>',agree9) root1.focus_set() root1.mainloop() # 显示图片窗口 def agree9(event): img = cv2.imread('cp1.png') print(img) cv2.imshow('image',img) cv2.waitKey(5000) cv2.destroyAllWindows() # 这里是一个图片格式转换操作,如果使用PIL里面的方法显示图片的画有可能会出现格式错误打不开图片 # from PIL import Image # img = Image.open("cp1.png") # im= img.convert("RGB") # im.save("D:\\File\\All\\python\\love\\image.jpg") # 让窗口不能关闭函数 def callback(event): # 查看触发事件的按钮 s=event.keysym if s == "Escape": root.destroy() text3= tk.Label(root,text="小姐姐我观察你好久了") text3.place(x=30,y=10) text4= tk.Label(root,text="做我女朋友好不好?",font=('宋体',20)) text4.place(x=60,y=80)
btn1= tk.Button(root,text='我同意',bg="#AAAAFF",command=agree1) btn1.place(x=100,y=200) btn1= tk.Button(root,text='去你的',bg="#AAAAFF",command=disagree1) btn1.place(x=300,y=200)
img= tk.Label(root, image=image) img.place(x=300,y=40)
# 让x不能关闭窗口只能点escape才能关闭窗口 root.protocol("WM_DELETE_WINDOW", callback) root.bind('<Key>',callback) root.focus_set()
root.mainloop()
|