# Randomly display 5 cards
# Cards stored in Google Drive under Resources
from tkinter import *
import random
win = Tk()
win.geometry("800x600")
def pick():
txt.delete(1.0, END)
txt.insert(END, ' PICKING 5 CARDS AT RANDOM\n\n')
Keys = list(d.keys())
random.shuffle(Keys)
Chosen = Keys[:5]
for i in range(5):
txt.insert(END, str(Chosen[i]) + '\t' + str(d[Chosen[i]]) + '\n')
stgImg = PhotoImage(file=str(Chosen[i]) + ".png")
eval(("lbl") + str(i+1)).configure(image=stgImg)
eval(("lbl") + str(i+1)).image = stgImg
d = {}
suites = ['Hearts', 'Spades', 'Diamonds', 'Clubs']
numbers = ['Ace'] + list(range(2, 11)) + ['Jack', 'Queen', 'King']
ctr = 1
for i in suites:
for j in numbers:
d[ctr] = str(j) + " of " + i
ctr += 1
btn = Button(win, text='Pick 5 Cards', font=('calibri', 15), fg='green', bg='black', command=pick)
btn.place(x=40, y=10)
txt = Text(win, width=35, height=7, font=('Verdana', 16))
txt.place(x=200, y=10)
lbl1 = Label(win); lbl1.place(x=130, y=400)
lbl2 = Label(win); lbl2.place(x=230, y=400)
lbl3 = Label(win); lbl3.place(x=330, y=400)
lbl4 = Label(win); lbl4.place(x=430, y=400)
lbl5 = Label(win); lbl5.place(x=530, y=400)
win.mainloop()
No comments:
Post a Comment