Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tkinter lottery app

#coding=utf-8import sysif sys.version_info [0] == 2: import tkinter from tkinter import *else: import tkinter as tkinter from tkinter import *import randomis_run=falsedef lottery_whirl (data, i, number): global is_run if i == 0: j=0 else: j=i%8 data [j-1] ["bg"]="#cccccc" data [j] ["bg"]="#00cd00" wait=[a for a in range (100, 300, 10)] + [b for b in range (300, 600, 300 //(number-28))] +  [c for c in range (600, 1200, 120)] + [d for d in range (1200, 1800, 200)] if i<number: window.after (wait [i], lottery_whirl, data, i + 1, number) else: is_run=falsedef lottery_start (data): global is_run if is_run: return is_run=true for x in range (len (data)-1): data [x] ["bg"]="#cccccc" number=random.randint (30, 53) lottery_whirl (data, 0, number)def create_label (name, x, y): label=label (window, text=name, width=13, height=3, bg="#cccccc", font="Songti -18 bold") label.place (anchor=nw, x=x, y=y) return labelif __name__ == "__main__": window=tkinter.tk () window.geometry ("500x290 + 250 + 150") window.title ("Roulette Lottery") bg_label=label (window, width=80, height=24, bg="#ecf5ff") bg_label.place (anchor=nw, x=0, y=0) label1=create_label ("Wind Qingyang", 20, 20) label2=create_label ("Beggar", 180, 20) label3=create_label ("No Cliff", 340, 20) label4=create_label ("Western Poison", 20, 110) label5=create_label ("Dongxie", 340, 110) label6=create_label ("Sweeper", 20, 200) label7=create_label ("South Emperor", 180, 200) label8=create_label ("Zhang Sanfeng", 340, 200) data=[label1, label2, label3, label5, label8, label7, label6, label4] button_core=button (window, text="Start", command=lambda:lottery_start (data), width=130, height=53, bg="#00cd00",  font="Songti -18 bold", bitmap="gray50", compound=tkinter.center) button_core.place (anchor=nw, x=180, y=110) window.mainloop ()
Comment

PREVIOUS NEXT
Code Example
Python :: Seaborn boxplots shifted incorrectly along x-axis 
Python :: vvm 2020 exam date 
Python :: print greeting in python explication 
Python :: how to place an id to every element in list in python 
Python :: python numpy read from stdin 
Python :: plt.plot(x, softmax(scores).T, linewidth=2) 
Python :: how to analyze data from dataframe in python 
Python :: how to check if an array is empty in python 
Python :: promedio en pandas 
Python :: Improve the Request Use Proxies 
Python :: To install the C++ and Python Messaging APIs: 
Python :: Python Iterating Through a Tuple 
Python :: fancy index 
Python :: pd drop a range of dates 
Python :: django q and f 
Python :: lists example in python 
Python :: can you use pop on a string 
Python :: queue data structure in python 
Python :: ridge regression alpha values with cross validation score plot 
Python :: myPYmenu 
Python :: decorrelation of data using PCA 
Python :: how to truncate a float in jinja template 
Python :: simulieren mit python 
Python :: mystring = "hello" myfloat=float 10 myint=20 
Python :: egt id of current object django 
Python :: Create list element using algebraic operation 
Python :: python csv string to array 
Python :: fichier python pour brython 
Python :: method for format age in python 
Python :: python input byte array 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =