python
主页 > 脚本 > python >

Python减肥小工具轻松帮你瘦

2021-09-28 | 秩名 | 点击:

本文是基于Tkinter的界面化小减肥弹窗小程序!素材可以自由选择的哈。

设置界面的长宽、导入的图片素材:

 

IMGPATH = "002.gif"
WINWIDTH = 800
WINHEIGHT = 600
WINX = 400
WINY = 100
 
img_x = 180
img_y = 60

设置好相应的文字:

question = "立好的减肥Flag,哭着也要完成。"
yes = "就来嗳"
no = "继续躺尸"
title = "大妹子"

新建无法直接关闭的TK类:

class NewTk(tk.Tk):
    def destroy(self):
        # 点击界面右上角的关闭按钮时,会调用本函数,
 
        imgLabel = tk.Label(win, image=photo)
        imgLabel.place(x=img_x, y=img_y)
 
        quesft = tkFont.Font(family="微软雅黑", size=16, weight=tkFont.BOLD)
        q = tk.Label(win, text=question, font=quesft)
        q.place(x=img_x, y=question_y)
        # 按钮
        def clickyes():
            yes_reply = "老地方等你,不来死定了! "
            top_width = 200
            top_height = 50
 
            top = tk.Toplevel()
            # 设置弹出窗口位置和大小
            top_x = WINX + WINWIDTH // 2 - top_width // 2
        # 覆盖掉了父类的关闭方法,使得界面无法关闭
        pass

​效果如下:

最后只能点同意按钮【就来嗳】,答应之后就是弹出一个界面【老地方等你,不来你就死定了】!

如下图:

原文链接:https://blog.csdn.net/weixin_55822277/article/details/120506424
相关文章
最新更新