(journalism) lede
Hey. Good afternoon! Good afternoon, Muzi's here with the new stuff.
Looking forward to today's content? Scratching my head.jpg For those of you who wait for updates on a daily basis I'm here. Let's see what we have in store for you.
π¦π¦π¦π¦π¦π¦π¦π¦π¦π¦π¦π¦ I'm the gorgeous separator π¦π¦π¦π¦π¦π¦π¦π¦π¦π¦π¦π¦π¦
I went out this morning, said the weather in Changsha with one word to describe: "hot", two words to describe: "really hot", three words to describe: "hot death", it is said that these days It is said that the temperature of these days will reach 40 Β°. Remember to protect yourself from the sun!
As soon as I left the house, I felt the sun's embrace and ran to the mall for a cup of chayan after tearfully doing my business, then strolled around and blew the free air-conditioning, bah humbug! I saw the carousel raffle at the mall, which is perfect for people like me who want to buy (white johns). Hey, hey, well ~ said so much (nonsense) words, reveal the mystery! I think you guys can't wait!
Today's topic is to create a small system of shopping mall raffle for you, you are guaranteed to like it and learn it without regret series~
I. Operating environment
I use the environment: Python3, Pycharm Community Edition, Tkinter, PIL module part of the self-contained will not show one by one.
Module installation: pip install -i /simple/+module name
II. Material (pictures, etc.)
Interface pictures, you can prepare your own, not shown here, you want to change what background can be their own randomly find a picture can be ha.
But be careful about the size and dimensions of the background haha.
III. Code display
Basically every line of code has comments, this code is written quite simple, a little basic can read and understand ha!
If you don't have a basic white person, you can find me to take some simple videos first, teach you to learn it from 0!
import time import threading from PIL import Image import tkinter as tk # Import tk library modules import random # Import Random Library Module root = () # Initialize Tk() to create a window ('Simple Shopping Mall Sweepstakes System - Gu Muzi Acres') # Setting the title (1000, 700) photo = (file="") # file: path to the image imgLabel = (root, image=photo) # Integrate images into the tag class (side=) # Right-aligned label1 = (root, text='Thank you for your patronage', bg='yellow', font=('Arial', 50)) (x=0, y=600, width=390, height=250) label2 = (root, text='1000 Coupon', bg='yellow', font=('Arial', 50)) (x=0, y=10, width=390, height=250) label3 = (root, text='Thank you for your patronage', bg='yellow', font=('Arial', 50)) (x=390, y=10, width=390, height=250) label4 = (root, text='Apple phone', bg='yellow', font=('Arial', 50)) (x=780, y=10, width=390, height=250) label5 = (root, text='One more time', bg='yellow', font=('Arial', 50)) (x=1170, y=10, width=390, height=250) label6 = (root, text='Thank you for your patronage', bg='yellow', font=('Arial', 50)) (x=1560, y=10, width=390, height=250) label7 = (root, text='5000 coupons', bg='yellow', font=('Arial', 50)) (x=1560, y=600, width=390, height=250) label8 = (root, text='Thank you for your patronage', bg='yellow', font=('Arial', 50)) (x=1170, y=600, width=390, height=250) label9 = (root, text="A small car., bg='yellow', font=('Arial', 50)) (x=780, y=600, width=390, height=250) label10 = (root, text='One more time', bg='yellow', font=('Arial', 50)) (x=390, y=600, width=390, height=250) label11 = (root, text='Gu Muzi Acres', bg='white', font=('Arial', 20)) (x=1250, y=900, width=700, height=100) # Add all lottery options to the list things = [label1, label2, label3, label4, label5, label6, label7, label8, label9, label10] # Get the maximum index value of the list maxvalue = len(things) - 1 # Set the starting value to a random integer starts = (0, 6) # Is it a stop sign notround = False # Define the scroll function def round(): t = (target=startup) #Start start () # Define the start function def startup(): global starts global notround while True: # Detect if the stop button is pressed if notround == True: notround = False return starts # Program delay (0.017) # Cycle through all sweepstakes options for i in things: i['bg'] = 'lightSkyBlue' # When it starts, the background color changes to sky blue # things[starts]['bg'] = 'red' # Scroll box is red starts += 1 if starts > maxvalue: starts = 0 # Define the stop function def stops(): global notround # notround is a global variable global starts notround = True # Stop flag bit if starts == 1: # If you win "simple quad", it's "thanks for your business" # starts = 2 # Set the start button Background text to "RUN" Background color to "sky blue" Font "Arial" Font size "50 " The callback function command is "scroll". btn1 = (root, text='RUN', bg='lightSkyBlue', font=('Arial', 50), command=round) #Set key coordinates (x=800, y=850, width=200, height=200) # Set the stop button Background text to "RUN" Background color is "Red" Font "Arial" Font size "50 " The callback function command is "stop". btn2 = (root, text='STOP', bg='red', font=('Arial', 50), command=stops) #Set key coordinates (x=1000, y=850, width=200, height=200)
IV. Effectiveness demonstration
1) Interface effect
This program interface is relatively large, after the screenshot Konen can see is not very clear, you can run their own to see more clearly.
2) RUN Run
Mouse click RUN to run and hold STOP to stop, random draw haha. I'm still lucky to have a small car to take home, haha!
There's no video to show here, it's all just random screenshots to see the effect haha, it's not that good~
Running it is always flashing randomly again in turn haha.
The above is based on Python to realize the mall lottery small system in detail, more information about Python lottery system please pay attention to my other related articles!