??時間過得真快,昨年520寫了一個表白代碼 點擊此處 哈哈哈 ,現在看來還蠻好看的!哈哈哈,我專業幫人追女朋友,心想兩玩得超好的同學,都是我幫忙追的哈哈哈,要是有粉絲需要我幫忙出謀劃策,盡管私聊我哈哈哈,在逛Youtube的時候偶爾看到了相關的表白視頻,于是自己也動手敲了哈哈!
先看效果!

# coding=utf-8
import tkinter as tk
from PIL import ImageTk
from tkinter import messagebox
def accept():
accept_root = tk.Toplevel(root)
accept_root.title("哈哈好開心")
accept_root.geometry("300x100")
l4 = tk.Label(accept_root, text="小仙女,咱們談戀愛吧!", font=("微軟雅黑", 20),fg="red",bg="pink")
l4.pack()
button3 = tk.Button(accept_root, text="好的", font=("微軟雅黑", 15),bg="pink",command=root.destroy)
button3.pack()
def not_accept():
not_accept_root = tk.Toplevel(root)
not_accept_root.title("嗚嗚好難受")
not_accept_root.geometry("300x100")
l4 = tk.Label(not_accept_root, text="給我一次機會嘛嚶嚶嚶", font=("微軟雅黑", 20))
l4.pack()
button3 = tk.Button(not_accept_root, text="好的", font=("微軟雅黑", 15),bg="pink",command=not_accept_root.destroy)
button3.pack()
#要是點擊不接受的x按鈕,就繼續呼叫此函式
not_accept_root.protocol("WM_DELETE_WINDOW", not_accept)
def not_closing():
messagebox.showerror(title="難受啊~",message="我保證聽你話,再考慮考慮嘛嗚嗚嗚QAQ~")
root = tk.Tk()
root.title("小姐姐,我喜歡你好久了熬!")
root.geometry("366x420+300+300")
l1 = tk.Label(root, text="hello,小姐姐,我想對你表白", font=("微軟雅黑", 16), fg="red")
# E S W N 東南西北
l1.grid(row=0, column=0, sticky=tk.W) # l1.grid()也是可以的,默認行和列為0,表示第一行第一列
l2 = tk.Label(root, text="自從第一次見你我就喜歡上了你!", font=("微軟雅黑", 18))
l2.grid(row=1, column=0) # 第二行第一列
# 上傳圖片
bgimg = ImageTk.PhotoImage(file='lovebaby.png')
l3 = tk.Label(root, image=bgimg)
l3.grid(row=2, columnspan=2)
root.protocol("WM_DELETE_WINDOW",not_closing)
button1 = tk.Button(root, text="接受", width=9, height=2, font=("微軟雅黑", 16), bg="pink", command=accept)
button1.grid(row=3, column=0, sticky=tk.W)
button2 = tk.Button(root, text="不接受", width=5,command=not_accept)
button2.grid(row=3, column=0, sticky=tk.E)
root.mainloop()
要圖片的話到這里來拿 點擊此處,還有我昨年發的表白代碼哈哈哈!
https://blog.csdn.net/hanhanwanghaha歡迎關注這個超級無敵可愛的人鴨,有什么問題留言私信皆可,看見必回!
創作不易,如有轉載,請注明出處
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/258428.html
標籤:python
