我一好友在朋友圈看到人家用代码花式秀恩爱,让我也做一个,我就用我学习半年python的功力,做了这一个东西。?
 
      
 
       窗口主页面(图一)
为了让我这个盆友有颜面,特意做了一个问答问他帅不帅,以我对他的了解,肯定选很帅,所以坑点就设计在这里了。?
     如果点还可以
    
证明他还有自知之明,我会温馨的提示他早点睡
 
          if num == 1:
        messagebox.showinfo('温馨提示', '早点睡', icon="question", type='okcancel')
m = tkinter.Radiobutton(frame1, text="还可以", variable=var, value=1, command=show)
m.pack()
     如果点很帅
    
我就要惩罚他了,用文字来骗他电脑中毒。
 
      ms = messagebox.showinfo('系统错误', '系统正在受到未知来源的病毒攻击!\n(ERROR_3X007)', icon="error", type='abortretryignore')
     点击终止
    
则会骗他电脑即将关机,给他先苦后甜。
 
       me = messagebox.showinfo('温馨提示', '电脑将自动关机', icon="question", type='ok')
    if me == 'ok':
        mh = messagebox.showinfo('温馨提示', '没那个技术,骗你的', icon="question", type='ok')
     点击重试
    
则会点一次后面的数字+1,让他享受数字增长的快乐
 
                  while i :
                # 遍历让数字累加
                mh = messagebox.showinfo('系统错误', '系统正在受到未知来源的病毒攻击+%d!\n(ERROR_3X007)'%i,
                                         icon="error", type='abortretryignore')
                i += 1
     点击忽略
    
这个就可以直接退掉,直接用return返回就行
     如果点击不敢苟同
    
则会进入下一个页面
def sure():
    frame1.pack_forget()
    frame2.pack()
wm = tkinter.Button(frame1, text="不敢苟同")
wm.pack()
wm.config(command=sure) 
       第二个页面
     如果点击
     
      X
     
     
      直接退出的话
     
    
则会弹出弹窗,不让他退出,只能夸我帅,才能退出。
 
      
     
      友情提示:本招只适合关系好,且不懂编程的人适用。
     
    
     源码
    
里面图标自行更换,用icon格式
import tkinter
from tkinter import messagebox
from tkinter.messagebox import showinfo, showerror, showwarning, askokcancel, askquestion, askyesno, askyesnocancel, askretrycancel
def slow():
    me = messagebox.showinfo('温馨提示', '电脑将自动关机', icon="question", type='ok')
    if me == 'ok':
        mh = messagebox.showinfo('温馨提示', '没那个技术,骗你的', icon="question", type='ok')
def show():
    # 获取var的值
    num = var.get()
    # 如果值为1,更改text值为
    if num == 1:
        label.config(text="谦虚")
        messagebox.showinfo('温馨提示', '早点睡', icon="question", type='okcancel')
    # 如果值为2,更改text值为
    else:
        label.config(text="自恋")
        ms = messagebox.showinfo('系统错误', '系统正在受到未知来源的病毒攻击!\n(ERROR_3X007)', icon="error", type='abortretryignore')
        if ms == 'abort':
            slow()
        elif ms == 'retry':
            i = 1
            while i :
                # 遍历让数字累加
                mh = messagebox.showinfo('系统错误', '系统正在受到未知来源的病毒攻击+%d!\n(ERROR_3X007)'%i,
                                         icon="error", type='abortretryignore')
                i += 1
                if mh == 'abort':
                    # 调用函数
                    slow()
                if mh == 'ignore':
                    return
        else:
            return
# 创建主窗口
root = tkinter.Tk()
# 整型对象
var = tkinter.IntVar()
# 设置默认选项为0
var.set(0)
root.title('调查表')
root.iconbitmap('甜甜私房猫图标cat1-ico_爱给网_aigei_com.ico')
# 第一章
frame1 = tkinter.Frame(root)
frame1.pack()
label = tkinter.Label(frame1, text="你认为你很帅吗", bg="lightyellow", width=30)
label.pack()
# 创建选项按钮,值为1,点击此按钮自动调用show函数
man = tkinter.Radiobutton(frame1, text="还可以", variable=var, value=1, command=show)
man.pack()
# 创建选项按钮,值为2
woman = tkinter.Radiobutton(frame1, text="很帅", variable=var, value=2, command=show)
woman.pack()
def sure():
    frame1.pack_forget()
    frame2.pack()
wm = tkinter.Button(frame1, text="不敢苟同")
wm.pack()
wm.config(command=sure)
def on_exit():
    mee = messagebox.showwarning(title='提示',message='此路不通')
    if mee == 'ok':
        ee = messagebox.showwarning(title='大喊', message='刘佳皓最帅')
root.protocol('WM_DELETE_WINDOW',on_exit)
# 第二章
frame2 = tkinter.Frame(root)
tkinter.Label(frame2,text='点击两下按钮退出',
              font=('黑体',10),
              justify=tkinter.LEFT,
              height=20,
              width=50,
              fg="red").pack()
tkinter.Button(frame2,text="刘佳皓最帅",command=root.quit).place(relx=0.4,rely=0.7)
root.mainloop()本片文章部分有借鉴之处,但找不到借鉴的文章了,感谢大神的文章的支持。
感谢大家的观看,如果觉得有意思的话请留下你的赞。?
 
版权声明:本文为weixin_70445937原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
