用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - python代码库

python无法拒绝表白源码

2022-11-09 作者: Python自学举报

[python]代码库

# 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("360x160")
    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("360x160")
    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("380x450+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='img666.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()

[代码运行效果截图]


python无法拒绝表白源码


网友评论    (发表评论)

共2 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...