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

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

相关推荐
梨落秋霜9 分钟前
Python入门篇【基础语法】
开发语言·python
ada7_36 分钟前
LeetCode(python)——543.二叉树的直径
数据结构·python·算法·leetcode·职场和发展
小白学大数据42 分钟前
Python 多线程爬取社交媒体品牌反馈数据
开发语言·python·媒体
HAPPY酷1 小时前
压缩文件格式实战速查表 (纯文本版)
python
祝余Eleanor1 小时前
Day 31 类的定义和方法
开发语言·人工智能·python·机器学习
背心2块钱包邮1 小时前
第6节——微积分基本定理(Fundamental Theorem of Calculus,FTC)
人工智能·python·机器学习·matplotlib
larance1 小时前
修改jupyterlab 默认路径
python
别叫我->学废了->lol在线等2 小时前
python单例模式下线程安全优化
python·安全·单例模式
西江649762 小时前
【个人博客系统—测试报告】
python·功能测试·jmeter·pycharm·postman
CHANG_THE_WORLD2 小时前
C++ vs Python 参数传递方式对比
java·c++·python