Time flies really fast, last year 520 wrote a confession code click here ha ha ha, now it looks pretty good! Ha ha ha, I professional help people chase girlfriend, thought two super good students, I help chase ha ha ha, if there are fans need my help to give advice, feel free to talk about my private ha ha ha. When I was browsing Youtube, I saw the related confession video, so I started knocking on it myself!

Blog.csdn.net/hanhanwangh… Treasure Girl welcomes your attention! Welcome to pay attention to wechat public number: Treasure girl’s growth diary let this lovely treasure girl walk with you on the road of hard work! If reproduced, please indicate the source (if not indicated, the thief will investigate)

First look at the effect!

# coding=utf-8

import tkinter as tk
from PIL import ImageTk
from tkinter import messagebox


def accept(a):
    accept_root = tk.Toplevel(root)
    accept_root.title("Ha, ha, ha, ha!")
    accept_root.geometry("300x100")
    l4 = tk.Label(accept_root, text="Fairy, let's fall in love!", font=(Microsoft Yahei.20),fg="red",bg="pink")
    l4.pack()
    button3 = tk.Button(accept_root, text="Good", font=(Microsoft Yahei.15),bg="pink",command=root.destroy)
    button3.pack()

def not_accept():
    not_accept_root = tk.Toplevel(root)
    not_accept_root.title("Whoo-hoo, it hurts.")
    not_accept_root.geometry("300x100")
    l4 = tk.Label(not_accept_root, text="Give me a chance!", font=(Microsoft Yahei.20))
    l4.pack()
    button3 = tk.Button(not_accept_root, text="Good", font=(Microsoft Yahei.15),bg="pink",command=not_accept_root.destroy)
    button3.pack() # if the x button is not accepted, call this function not_accept_root.protocol("WM_DELETE_WINDOW", not_accept)

def not_closing():
    messagebox.showerror(title="Sad ~",message="I promise I'll listen to you. Think about it.)


root = tk.Tk()
root.title("Little sister, I like you for a long time!")
root.geometry("366x420+300+300")

l1 = tk.Label(root, text="Hello, little sister, I want to tell you.", font=(Microsoft Yahei.16), fg="red") S N N N N N N N Ngrid(row=0, column=0, sticky=tk.W)  # l1.grid() is also available, with default lines and columns0Is the first row, first column l2 = tk.Label(root, text="I've liked you since the first time I saw you!", font=(Microsoft Yahei.18))
l2.grid(row=1, column=0# upload image bgimg = ImageTkPhotoImage(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="Accept", width=9, height=2, font=(Microsoft Yahei.16), bg="pink", command=accept)
button1.grid(row=3, column=0, sticky=tk.W)

button2 = tk.Button(root, text="Not accepted.", width=5,command=not_accept)
button2.grid(row=3, column=0, sticky=tk.E)

root.mainloop(a)Copy the code

Click here for pictures and the code I sent last year hahaha!

Blog.csdn.net/hanhanwangh… Treasure Girl welcomes your attention! Welcome to pay attention to wechat public number: Treasure girl’s growth diary let this lovely treasure girl walk with you on the road of hard work! If reproduced, please indicate the source (if not indicated, the thief will investigate)