首页 最新 热门 推荐

  • 首页
  • 最新
  • 热门
  • 推荐

Python满屏表白代码

  • 25-02-22 06:00
  • 2472
  • 9590
blog.csdn.net

系列文章 

序号文章目录直达链接
1浪漫520表白代码http://iyenn.com/rec/1677773.html
2满屏表白代码http://iyenn.com/rec/1676512.html
3跳动的爱心http://iyenn.com/rec/1677774.html
4漂浮爱心http://iyenn.com/rec/1677775.html
5爱心光波http://iyenn.com/rec/1677776.html
6流星雨http://iyenn.com/rec/1677777.html
7满天星http://iyenn.com/rec/1677778.html
8烟花秀http://iyenn.com/rec/1677779.html
9圣诞树http://iyenn.com/rec/1677780.html
10雪花代码http://iyenn.com/rec/1677781.html
11模拟星空http://iyenn.com/rec/1677782.html
12生日蛋糕http://iyenn.com/rec/1677783.html
13樱花树http://iyenn.com/rec/1677784.html
14五彩气球http://iyenn.com/rec/1677785.html
15七彩花朵http://iyenn.com/rec/1677786.html
16恶搞代码http://iyenn.com/rec/1677787.html

目录

系列文章 

前言

爱心界面 

无限弹窗 


前言

人生苦短,我用Python!又是新的一周啦,本期博主给大家带来了一个全新的作品:满屏表白代码,无限弹窗版!快快收藏起来送给她吧~

爱心界面

程序设计

  1. def Heart():
  2.     root=tk.Tk()
  3.     screenwidth=root.winfo_screenwidth()
  4.     screenheight=root.winfo_screenheight()
  5.     width=600
  6.     height=400
  7.     x=(screenwidth-width)//2
  8.     y=(screenheight-height)//2
  9.     root.title("❤")
  10.     root.geometry("%dx%d+%d+%d"%(screenwidth,screenheight,0,0))
  11.     tk.Label(root,text='❤',fg='pink',bg='white',font=("Comic Sans MS",500),width=300,height=20).pack()
  12.     root.mainloop()    

程序分析

这是一个使用Python的Tkinter库创建窗口的程序,该程序会在屏幕中央显示一个红色的心形图案。程序首先导入了Tkinter库,并定义了一个名为Heart的函数。在函数中,程序定义了一个Tk窗口对象,并获取了当前屏幕的宽度和高度。接着程序定义了窗口的宽度和高度,并计算了窗口在屏幕中的位置。程序设置了窗口的标题为"❤",并且使用geometry方法将窗口的大小和位置设置为占据整个屏幕。程序使用一个Label标签对象将一个大号的红色心形文本添加到窗口中,并使其在屏幕中央居中。最后,程序进入Tkinter的事件循环中,以响应用户的输入和操作。

无限弹窗 

def Love1():
    root=tk.Tk()
    width=200
    height=50
    screenwidth=root.winfo_screenwidth()
    screenheight=root.winfo_screenheight()
    x=ra.randint(0,screenwidth/2)
    y=ra.randint(0,screenheight/2)
    root.title("❤")
    root.geometry("%dx%d+%d+%d"%(width,height,x,y))
    tk.Label(root,text='I LOVE YOU!',fg='white',bg='pink',font=("Comic Sans MS",15),width=30,height=5).pack()
    root.mainloop()
def Love2():
    root=tk.Tk()
    width=200
    height=50
    screenwidth=root.winfo_screenwidth()
    screenheight=root.winfo_screenheight()
    screenheight-=2*width
    x=ra.randint(screenwidth/2,screenwidth)
    y=ra.randint(0,screenheight/2)
    root.title("❤")
    root.geometry("%dx%d+%d+%d"%(width,height,x,y))
    tk.Label(root,text='I LOVE YOU!',fg='white',bg='pink',font=("Comic Sans MS",15),width=30,height=5).pack()
    root.mainloop()
def Love3():
    root=tk.Tk()
    width=200
    height=50
    screenwidth=root.winfo_screenwidth()
    screenheight=root.winfo_screenheight()
    screenheight-=width
    x=ra.randint(screenwidth/2,screenwidth)
    y=ra.randint(screenheight/2,screenheight)
    root.title("❤")
    root.geometry("%dx%d+%d+%d"%(width,height,x,y))
    tk.Label(root,text='I LOVE YOU!',fg='white',bg='pink',font=("Comic Sans MS",15),width=30,height=5).pack()
    root.mainloop()
def Love4():
    root=tk.Tk()
    width=200
    height=50
    screenwidth=root.winfo_screenwidth()
    screenheight=root.winfo_screenheight()
    screenheight-=2*width
    x=ra.randint(0,screenwidth/2)
    y=ra.randint(screenheight/2,screenheight)
    root.title("❤")
    root.geometry("%dx%d+%d+%d"%(width,height,x,y))
    tk.Label(root,text='I LOVE YOU!',fg='white',bg='pink',font=("Comic Sans MS",15),width=30,height=5).pack()
    root.mainloop()

(完整程序文末公众免费领取哦) 

文章知识点与官方知识档案匹配,可进一步学习相关知识
Python入门技能树首页概览335305 人正在系统学习中
Want595
微信公众号
获取源码丨商务合作丨交流讨论
注:本文转载自blog.csdn.net的Want595的文章"https://want595.blog.csdn.net/article/details/129794518"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接
复制链接
相关推荐
发表评论
登录后才能发表评论和回复 注册

/ 登录

评论记录:

未查询到任何数据!
回复评论:

分类栏目

后端 (14832) 前端 (14280) 移动开发 (3760) 编程语言 (3851) Java (3904) Python (3298) 人工智能 (10119) AIGC (2810) 大数据 (3499) 数据库 (3945) 数据结构与算法 (3757) 音视频 (2669) 云原生 (3145) 云平台 (2965) 前沿技术 (2993) 开源 (2160) 小程序 (2860) 运维 (2533) 服务器 (2698) 操作系统 (2325) 硬件开发 (2492) 嵌入式 (2955) 微软技术 (2769) 软件工程 (2056) 测试 (2865) 网络空间安全 (2948) 网络与通信 (2797) 用户体验设计 (2592) 学习和成长 (2593) 搜索 (2744) 开发工具 (7108) 游戏 (2829) HarmonyOS (2935) 区块链 (2782) 数学 (3112) 3C硬件 (2759) 资讯 (2909) Android (4709) iOS (1850) 代码人生 (3043) 阅读 (2841)

热门文章

101
推荐
关于我们 隐私政策 免责声明 联系我们
Copyright © 2020-2025 蚁人论坛 (iYenn.com) All Rights Reserved.
Scroll to Top