In this article, we share examples of python to achieve the specific code of the carousel effect, for your reference, the details are as follows
# Sweepstakes Object-oriented version import tkinter import time import threading class choujiang: # Initialize the magic method def __init__(self): # Prepare the interface = () ('lowB version of the carousel') (300, 300) # Declare a variable for whether to press start = False = False # Methods for calling the settings screen () () #Interface Layout Methods def setwindow(self): # Start stop button self.btn_start = (, text = 'start/stop',command = ) self.btn_start.place(x=90, y=125, width=50, height=50) self.btn1 = (, text='Zhao', bg='red') self.(x=20, y=20, width=50, height=50) self.btn2 = (, text='Money', bg='white') self.(x=90, y=20, width=50, height=50) self.btn3 = (, text='Sun', bg='white') self.(x=160, y=20, width=50, height=50) self.btn4 = (, text='Lee', bg='white') self.(x=230, y=20, width=50, height=50) self.btn5 = (, text='Chow', bg='white') self.(x=230, y=90, width=50, height=50) self.btn6 = (, text='Wu', bg='white') self.(x=230, y=160, width=50, height=50) self.btn7 = (, text='Zheng', bg='white') self.(x=230, y=230, width=50, height=50) self.btn8 = (, text='King', bg='white') self.(x=160, y=230, width=50, height=50) self.btn9 = (, text='Feng', bg='white') self.(x=90, y=230, width=50, height=50) self.btn10 = (, text='Chen', bg='white') self.(x=20, y=230, width=50, height=50) self.btn11 = (, text='Chu', bg='white') self.(x=20, y=160, width=50, height=50) self.btn12 = (, text='Wei', bg='white') self.(x=20, y=90, width=50, height=50) # Form a list of all options = [self.btn1,self.btn2,self.btn3,self.btn4,self.btn5,self.btn6,self.btn7,self.btn8,self.btn9,self.btn10,self.btn11,self.btn12] def rounds(self): # Determine whether to start the loop if == True: return # Initialize count variables i = 0 # Dead end loops while True: if == True: = False return # Delayed operation (0.1) # Turn all component backgrounds white for x in : x['bg'] = 'white' # Change the color of the component corresponding to the current value [i]['bg'] = 'red' # Variable +1 i += 1 # If i is greater than the maximum index go straight to zero if i >= len(): i = 0 # Functions to create a new thread def newtask(self): if == False: # Create threads t = (target = ) # Start a thread running () # Set the loop start flag = True elif == True: = False = True c = choujiang()
I'll share it with you again!A python simulation of a roulette wheel lottery game
version of the test Chinese variable name
from random import random #Prize distribution jxfb, this spin reads bclpds, winning zjqk, this battle bczk. def lpd(jxfb): bclpds = random() for k, v in (): if v[0]<=bclpds<v[1]: return k jxfb = {'First Prize':(0, 0.08), 'Second Prize':(0.08, 0.3), 'Third Prize':(0.3, 1.0)} zjqk = dict() # Simulate playing 10,000 times and counting the winnings for i in range(10000): bczk = lpd(jxfb) zjqk[bczk] = (bczk, 0) + 1 for item in (): print(item)
This is the whole content of this article.