【Python抽奖系统】好消息:史上最强商场抽奖活动来啦,超优惠,攻略快拿好啦~(超牛)

导语

嘿!下午好,木子来上新啦~

期待今天的内容嘛?挠头.jpg 日常等更新的小可爱们我来了。看看给大家带来了什么好东西👇

💦💦💦💦💦💦💦💦💦💦💦💦我是华丽的分隔符💦💦💦💦💦💦💦💦💦💦💦💦💦

今天早上出门了一趟,话说长沙的天气用一个字形容就是:”热“、二个字形容:”真热“、三个字

形容:”热死人“,据说这几天的温度快达到40°了。大家记得做好防晒哦~

所有文章完整的素材+源码都在👇👇

粉丝白嫖源码福利,请移步至CSDN社区或文末公众hao即可免费。

一出门就感受到了太阳的拥抱,泪流满面的做完事情之后跑到商场喝了杯茶颜,然后逛着街吹

着免费的空调,巴适的很啊!逛商场的时候看到了转盘抽奖活动,简直不要太适合我这种想买

买买(白嫖)的人。嘿嘿,嘛~说了这么多的(废话)话,揭开谜底吧!我想你们等不及了👇

今天的主题就是给大家制作一款商场抽奖小系统,保证你喜欢😋,学了不后悔系列~

正文

一、运行环境

小编使用的环境:Python3、Pycharm社区版、Tkinter、PIL模块部分自带就不一一 展示啦。

 模块安装:pip install -i https://pypi.douban.com/simple/+模块名

二、素材(图片等)

界面图片的话可以自己准备,这里不展示,想换什么背景可以自己随便找一张图就可哈。

但是要注意背景的大小尺寸问题哈。

三、代码展示

基本上每行代码都有注释的,这款代码写的挺简单的,有点儿小基础的可以看的懂哈!

如没基础小白的话可以找我先拿一些简单的视频,教你从0开始学习吧!

import time
import threading
from PIL import Image
import tkinter as tk  # 导入 tk库 模块
import random         # 导入 随机库 模块

root = tk.Tk()      #初始化Tk() 建立一个窗口
root.title('简易商场抽奖系统-顾木子吖') # 设置标题
root.minsize(1000, 700)

photo = tk.PhotoImage(file="ETA.png")  # file:图片路径
imgLabel = tk.Label(root, image=photo)  # 把图片整合到标签类中
imgLabel.pack(side=tk.RIGHT)  # 右对齐

label1 = tk.Label(root, text='谢谢惠顾', bg='yellow', font=('Arial', 50))
label1.place(x=0, y=600, width=390, height=250)

label2 = tk.Label(root, text='1000优惠券', bg='yellow', font=('Arial', 50))
label2.place(x=0, y=10, width=390, height=250)

label3 = tk.Label(root, text='谢谢惠顾', bg='yellow', font=('Arial', 50))
label3.place(x=390, y=10, width=390, height=250)

label4 = tk.Label(root, text='苹果手机', bg='yellow', font=('Arial', 50))
label4.place(x=780, y=10, width=390, height=250)

label5 = tk.Label(root, text='再来一次', bg='yellow', font=('Arial', 50))
label5.place(x=1170, y=10, width=390, height=250)

label6 = tk.Label(root, text='谢谢惠顾', bg='yellow', font=('Arial', 50))
label6.place(x=1560, y=10, width=390, height=250)

label7 = tk.Label(root, text='5000优惠券', bg='yellow', font=('Arial', 50))
label7.place(x=1560, y=600, width=390, height=250)

label8 = tk.Label(root, text='谢谢惠顾', bg='yellow', font=('Arial', 50))
label8.place(x=1170, y=600, width=390, height=250)

label9 = tk.Label(root, text='一台小汽车', bg='yellow', font=('Arial', 50))
label9.place(x=780, y=600, width=390, height=250)

label10 = tk.Label(root, text='再来一次', bg='yellow', font=('Arial', 50))
label10.place(x=390, y=600, width=390, height=250)

label11 = tk.Label(root, text='顾木子吖', bg='white', font=('Arial', 20))
label11.place(x=1250, y=900, width=700, height=100)

# 将所有抽奖选项添加到列表
things = [label1, label2, label3, label4, label5, label6, label7, label8, label9, label10]
# 获取列表的最大索引值
maxvalue = len(things) - 1

# 设置起始值为随机整数
starts = random.randint(0, 6)
# 是否停止标志
notround = False

# 定义滚动函数
def round():
    t = threading.Thread(target=startup) #启动start
    t.start()

# 定义开始函数
def startup():
    global starts
    global notround
    while True:
        # 检测停止按钮是否被按下
        if notround == True:
            notround = False
            return starts
        # 程序延时
        time.sleep(0.017)

        # 在所有抽奖选项中循环滚动
        for i in things:
            i['bg'] = 'lightSkyBlue' #开始时 底色变成天蓝
        things[starts]['bg'] = 'red' #滚动框为 红色
        starts += 1
        if starts > maxvalue:
            starts = 0
# 定义停止函数
def stops():
    global notround # notround 为全局变量
    global starts

    notround = True  #停止标志位
    if starts == 1:  # 如果抽中“简易四轴”就跳转为“谢谢惠顾”【奸商^_^】
        starts = 2

# 设置启动按键      背景文本为“RUN”  底色为“天蓝”    字体“Arial” 字体大小“50”   回调函数command 为【滚动】
btn1 = tk.Button(root, text='RUN', bg='lightSkyBlue', font=('Arial', 50), command=round)
#设置按键坐标
btn1.place(x=800, y=850, width=200, height=200)
# 设置停止按键      背景文本为“RUN”  底色为“红色”    字体“Arial” 字体大小“50”   回调函数command 为【停止】
btn2 = tk.Button(root, text='STOP', bg='red', font=('Arial', 50), command=stops)
#设置按键坐标
btn2.place(x=1000, y=850, width=200, height=200)

​四、效果展示

1)界面效果  

这个程序界面比较大,截图之后科能看的不是很清楚,大家可以自己运行看的清楚些。

2)RUN运行

鼠标点击RUN运行按住STOP停止,随机抽奖的哈。我运气还是不错的小汽车能带回家,哈哈

这里没有视频展示,都是随便截图看下效果的哈,没有那么好~

运行起来是一直再轮流随机闪动的哈。嘛老规矩👇

总结

这商场优惠真不错,是叭~哈哈哈(仅供娱乐)这要是真的不得了~

好啦好啦!小伙伴儿们,代码给你们准备好了自己拿的哈😇

🎯完整的免费源码领取处:找我吖!文末公众hao可自行领取,滴滴我也可!

🔨推荐往期文章——

项目1.0  漫天飞雪小程序

Python小程序:你看?这千年难遇的雪景——简直“美到犯规”【满屏雪花飞舞】

项目4.9   闹钟

【Python代码合集】高能预警,四个起床闹钟铃声,再也不敢赖床啦~(起床困难户专用)

项目4.7 电影订票选座系统

【Python订票系统】这才是看电影选座的正确方法,原来我们都上当了~(选座位、一键购票)

项目1.3  视频播放器

用了都说好的Python专属无广告视频播放器,良心到想为它疯狂打call

🎄文章汇总——

汇总合集  Python—2022 |已有文章汇总 | 持续更新,直接看这篇就够了

(更多内容+源码都在✨文章汇总哦!!欢迎阅读喜欢的文章🎉~)

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

顾木子吖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值