打包个七夕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 发给女神看吧

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

相关推荐
知行合一。。。5 小时前
Python--04--数据容器(总结)
开发语言·python
架构师老Y5 小时前
008、容器化部署:Docker与Python应用打包
python·容器·架构
lifewange5 小时前
pytest-类中测试方法、多文件批量执行
开发语言·python·pytest
pluvium276 小时前
记对 xonsh shell 的使用, 脚本编写, 迁移及调优
linux·python·shell·xonsh
2401_827499996 小时前
python项目实战09-AI智能伴侣(ai_partner_5-6)
开发语言·python
PD我是你的真爱粉6 小时前
MCP 协议详解:从架构、工作流到 Python 技术栈落地
开发语言·python·架构
ZhengEnCi6 小时前
P2G-Python字符串方法完全指南-split、join、strip、replace的Python编程利器
python
是小蟹呀^6 小时前
【总结】LangChain中工具的使用
python·langchain·agent·tool
宝贝儿好7 小时前
【LLM】第二章:文本表示:词袋模型、小案例:基于文本的推荐系统(酒店推荐)
人工智能·python·深度学习·神经网络·自然语言处理·机器人·语音识别
王夏奇7 小时前
pythonUI界面弹窗设置的几种办法
python·ui