首先看效果
代码如下:
from tkinter import *
import random
class DeckOfCardsGUI:
def __init__(self):
window = Tk()
window.title("Pick Four Cards Randomly")
self.imageList = []
for i in range(3, 55):
self.imageList.append(PhotoImage(file="image/"+str(i)+".png"))
frame = Frame(window)
frame.pack()
self.labelList = []
for i in range(5):
self.labelList.append(Label(frame, image=self.imageList[i]))
self.labelList[i].pack(side=LEFT)
Button(window, text="Shuffle", command=self.shuffle).pack()
window.mainloop()
def shuffle(self):
random.shuffle(self.labelList)
for i in range(4):
self.labelList[i]["image"] = self.imageList[i]
if __name__ == '__main__':
app = DeckOfCardsGUI()
扑克牌图片百度网盘链接如下:
链接:link.
提取码:1111
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)