当前位置:网站首页>Py程序员的七夕情人节
Py程序员的七夕情人节
2022-07-30 17:12:00 【程序员昊子】
目录
一年一度的七夕情人节是不是要给女朋友或者正在追求的妹子一点小惊喜呢,今天这篇博客就分享下代码Python代码!赶紧学会了,来制作属于我们Python程序员的浪漫吧!!!

一、表白弹窗:
效果介绍及效果图:
它只要被运行起来就只能先点“好的”,再点“点击摧毁”才可以退出。除了重启电脑和任务管理器强制关闭。

源代码:
from tkinter import *
# 创造一个窗口 类 模块
windows = Tk()
# 改变我们窗口的大小和位置1:宽 2:高 3x左右数值越大越往右动 4y上下数值越大越往下
windows.geometry("415x222+550+100")
# 改变我们窗口
windows.title("告白")
# 放入我们的文字 Label()文本标签text= 微软雅黑windows bg背景颜色
label = Label(windows,text="入目无他人,四下皆是你", font=("微软雅黑", 20), bg="red")
# 布局网格布局 行和列的 0行0列
label.grid()
# 0行0列
label1 = Label(windows,text="我喜欢你", font=("微软雅黑",20), bg="red")
label1.grid(row=1,column=1)
label2 = Label(windows,text="做我女朋友吧", font=("微软雅黑",20), bg="red")
label2.grid()
# 创造函数
def Love():
# 创造顶级弹窗
Love = Toplevel(windows)
# love是子窗口
Love.geometry("350x190+550+100")
# 文本标签
label = Label(Love,text="往后余生,万搬都是你",font=("微软雅黑",20),bg = 'red')
# 垂直布局 中间 函数的作用域
label.pack()
# 摧毁
BUT = Button(Love,text="点击摧毁",font=("微软雅黑",20),command=windows.destroy)
BUT.pack()
# 按钮command调用的意思
but = Button(windows,text="好的",width=8,height=2,command=Love)
but.grid(row=3,column=0,sticky=W)
but1=Button(windows,text="不行",width=8,height=2)
but1.grid(row=3,column=1,sticky=E)
# 实用协议
windows.protocol("WM_DELETE_WINDOW",windows)
# 显示窗口mainloop()显示的意思
windows.mainloop()
二、表白弹窗:
效果介绍及效果图:
此程序运行后会满屏随机地方显示,并且一直重复50次。

源代码:
import tkinter as tk #创建窗口
import random
import threading
import time
def boom():
window=tk.Tk()#建立窗口
width = window.winfo_screenwidth()#得到屏幕宽度
height = window.winfo_screenheight()#得到屏幕高度
a = random.randrange(0,width)
b = random.randrange(0,height)
window.title('你好')#窗口名字
window.geometry("200x50"+"+"+str(a)+"+"+str(b))#设置窗体大小
tk.Label(window,text='我喜欢你',bg='red',font=("宋体",20),width=20,height=4).pack()
window.mainloop()
boom()
threads=[]
for i in range(50):
t= threading.Thread(target=boom)#创建多线程
threads.append(t)#开始执行线程
time.sleep(0.1)
threads[i].start() #启动所有线程
---------------------------------------------------------------------------------------------------------------------------------
Python文件转换exe文件:
一、安装pyinstaller库(之前讲过安装库的三种方法,这里我用其中一种):
1.按Windows+r打开运行窗口
2.输入cmd回车,打开黑窗口。

3.输入"pip install pyinstaller" 回车

二、打开文件目录文件夹
1.在圈住地方输入文cmd,打开黑窗口,以便快速定位


三、输入指令转换
1.输入 pyinstaller -F _int_.py 后面_int_.py是我的py文件名称,看自己名字而定

三、成功
1.圈住的为转换成功的内容
2.打开其中的dist文件夹即可看到exe文件夹

你学会了吗?快拿去用吧

边栏推荐
- No qualifying bean of type问题解决
- bert-base调试心得
- How does the new retail saas applet explore the way to break the digital store?
- (17)[系统调用]追踪系统调用(0环)
- 数据库的三大范式
- C# 连接SQL Sever 数据库与数据查询实例 数据仓库
- 华为云数据治理生产线DataArts,让“数据‘慧’说话”
- FP6600QSO SOP-8 USB专用充电端口控制器 用于快充电协议和QC2.0/3.0
- Error EPERM operation not permitted, mkdir ‘Dsoftwarenodejsnode_cache_cacach两种解决办法
- 华为云数据治理生产线DataArts,让“数据'慧'说话”
猜你喜欢

论文阅读之《DeepIlluminance: Contextual IlluminanceEstimation via Deep Neural Networks》

JMeter Notes 3 | JMeter Installation and Environment Instructions

Express框架连接MySQL及ORM框架

onenote use

关于内和调试无法查看ntdll内存的问题

基于MATLAB的电力系统短路故障分析与仿真

论文阅读之《Quasi-Unsupervised Color Constancy 》

LeetCode167: Sum of two numbers in sorted array

真正懂经营管理的CIO具备哪些特质
![[Geek Challenge 2020] Roamphp1-Welcome](/img/3b/2fa91f7478b8abf6efe0feafd24e58.png)
[Geek Challenge 2020] Roamphp1-Welcome
随机推荐
Microsoft Office 2019 software download and installation detailed tutorial!
MySQL超详细安装教程 手把手教你安装MySQL到使用MySQL 最简单的MySQL安装方式,这种方式装,卸载也简单
592. Fraction Addition and Subtraction
SQLServer下载与安装
OpenCV形状检测
将 APACHE 日志解析到 SQL 数据库中
leetcode:1488. 避免洪水泛滥【二分 + 贪心】
华为无线设备配置Mesh业务
华为云数据治理生产线DataArts,让“数据'慧'说话”
Tensorflow模型量化(Quantization)原理及其实现方法
WeChat applet picker scroll selector use detailed explanation
报错500,“message“: “nested exception is org.apache.ibatis.binding.BindingException: 解决记录
torch.optim.Adam() function usage
gvim命令记录
592. Fraction Addition and Subtraction
【Cloud Store Announcement】Notice of Help Center Update on July 30
从零开始的Multi-armed Bandit
阿里巴巴中国站获得1688商品分类 API
huato hot update environment construction (DLL method hot update C# code)
Daily practice------Generate 13-digit bar, Ean-13 code rule: The thirteenth digit is the check code obtained by the calculation of the first twelve digits.