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

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

相关推荐
徐先生 @_@|||15 分钟前
(Wheel 格式) Python 的标准分发格式的生成规则规范
开发语言·python
JoannaJuanCV26 分钟前
自动驾驶—CARLA仿真(22)manual_control_steeringwheel demo
人工智能·自动驾驶·pygame·carla
Mqh18076227 分钟前
day45 简单CNN
python
学习者0071 小时前
python 下载离线库方法
python
声声codeGrandMaster1 小时前
AI之模型提升
人工智能·pytorch·python·算法·ai
魔镜前的帅比1 小时前
多 Agent 架构:Coordinator + Worker 模式
python·ai
路长冬2 小时前
python基本语法
python
superman超哥2 小时前
仓颉语言中错误恢复策略的深度剖析与工程实践
c语言·开发语言·c++·python·仓颉
海上飞猪2 小时前
【Python基础】python判空
python
梦幻精灵_cq2 小时前
Linux.date格式化标识“制作”极简台历 vs Python.datetime.strftime格式化“精美”日历牌(时间工具依情境选择也是一种“智慧)
linux·python