打包个七夕exe玩玩

前段时间七夕 当别的哥们都在酒店不要不要的时候

身为程序员的我 还在单位群收到收到

正好后来看到大佬些的这个

https://www.52pojie.cn/thread-1823963-1-1.html

这个贱 我必须要犯,可是我也不能直接给他装个python吧 多麻烦 就这几个弹窗 好low 加上bgm 再打包成exe

python 复制代码
import tkinter as tk
import random
import threading
import time
import pygame
# 音乐的路径
file=r'C:\Users\farben\Downloads\aa.flac'
# 初始化
pygame.mixer.init()
# 加载音乐文件
track = pygame.mixer.music.load(file)
# 开始播放音乐流
pygame.mixer.music.play()
 
def dow():
    window = tk.Tk()
    width=window.winfo_screenwidth()
    height=window.winfo_screenheight()
    a=random.randrange(0,width)
    b=random.randrange(0,height)
    window.title('520快乐')
    window.geometry("200x50"+"+"+str(a)+"+"+str(b))
    tk.Label(window,
        text='亲爱的嫁给我吧!',    # 标签的文字
        bg='Red',     # 背景颜色
        font=('楷体', 15),
         fg="green",         # 字体和字体大小
        width=15, height=2  # 标签长宽
        ).pack()    # 固定窗口位置
    window.mainloop()
   
threads = []
for i in range(100):#需要的弹框数量
    t = threading.Thread(target=dow)
    threads.append(t)
    time.sleep(0.1)
    threads[i].start()

好的 让我们开始打包

安装Pyinstaller

首先我们要先安装Pyinstaller,直接在cmd使用pip命令

shell 复制代码
pip install pyinstaller 

然后去你存放这个文件的目录里执行下面这行命令 qixi.ico是我从网上随便找的个图片 自行修改是打包成exe之后的一个logo

shell 复制代码
Pyinstaller -F -w -i qixi.ico word.py

执行完毕会发现当前目录多了几个文件夹,打开其中名为dist的文件夹 里面就是exe 发给女神看吧

女神没电脑?,算了 那她配不上你

相关推荐
我想进大厂3 小时前
Python---数据容器(Set 集合)
开发语言·python
chenchihwen4 小时前
AI代码开发宝库系列:LangChain 工具链:从LCEL到实际应用
人工智能·python·langchain·rag
TwoAnts&DingJoy4 小时前
数据分析-数据沙箱
人工智能·python·安全·数据分析·数据沙箱
wu_jing_sheng04 小时前
销售数据分析
开发语言·python
风向玩家4 小时前
不放回抽样_生成不重样菜单
python
程序员小远4 小时前
Postman接口测试: Postman环境变量&全局变量设置,多接口顺序执行详解
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
程序员三藏4 小时前
Postman定义公共函数
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
小麦果汁吨吨吨5 小时前
Python:word(doc、docx)批量转pdf
python
深蓝电商API5 小时前
异步爬虫的终极形态:aiohttp + asyncio 实现万级并发实践
爬虫·python·aiohttp
用户8356290780515 小时前
Python创建PDF文档:解锁高效PDF创建的能力
后端·python