first commit
This commit is contained in:
commit
1d6b0b4b01
1 changed files with 56 additions and 0 deletions
56
main.py
Normal file
56
main.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
import tkinter as tk
|
||||
import tkinter.ttk as ttk
|
||||
import tkinter.messagebox as mb
|
||||
|
||||
|
||||
def quit_school():
|
||||
mb.showinfo("退学通知", "滴!你被退学了!")
|
||||
|
||||
|
||||
root = tk.Tk(className="你 要 挂 科 了")
|
||||
root.geometry("400x200")
|
||||
l = ttk.Label(root, text="可爱的小小小梦蕾要~挂~科~了~!", font=("微软雅黑", 14))
|
||||
l.place(x=30, y=30, width=340)
|
||||
|
||||
by = ttk.Button(root, text="是的", command=quit_school)
|
||||
by.place(x=160, y=140, width=100, height=40)
|
||||
bn = ttk.Button(root, text="不是")
|
||||
bn.place(x=280, y=140, width=100, height=40)
|
||||
|
||||
state = 0
|
||||
|
||||
|
||||
def exchange():
|
||||
if state == 0:
|
||||
by.place(x=280, y=140, width=100, height=40)
|
||||
bn.place(x=160, y=140, width=100, height=40)
|
||||
else:
|
||||
by.place(x=160, y=140, width=100, height=40)
|
||||
bn.place(x=280, y=140, width=100, height=40)
|
||||
|
||||
|
||||
def vertical_move():
|
||||
if state == 2:
|
||||
bn.place(x=280, y=100, width=100, height=40)
|
||||
else:
|
||||
bn.place(x=280, y=140, width=100, height=40)
|
||||
|
||||
|
||||
def on_hover(_):
|
||||
global state
|
||||
if state in [0, 1]:
|
||||
exchange()
|
||||
else:
|
||||
vertical_move()
|
||||
state = (state + 1) % 4
|
||||
|
||||
|
||||
def on_closing():
|
||||
mb.showinfo("提示", "关闭窗口也改变不了你挂科的事实!")
|
||||
root.destroy()
|
||||
|
||||
|
||||
bn.bind("<Enter>", on_hover)
|
||||
root.protocol("WM_DELETE_WINDOW", on_closing)
|
||||
|
||||
root.mainloop()
|
Loading…
Reference in a new issue