用户:
小喵来了查看:0 回复:1 评论:0 创建时间:2021-06-14T16:03:14
【作品展示】

【作品介绍】
10110110110 10101000110110100010011 001010101101
10000010111 101110101010
【作品源代码】
import random as r
import time as t
from tkinter import Tk, Button, DISABLED
def show_symbol(x, y):
global first
global previousX, previousY
buttons[x, y]['text'] = button_symbols[x, y]
buttons[x, y].update_idletasks()
if first:
previousX = x
previousY = y
frist = False
elif previousX != x or previousY != y:
if buttons[previousX, previousY]['text'] != button[x, y]['text']:
t.sleep(0.5)
buttons[previousX, previousY]['text'] = ''
buttons[x, y]['text'] = ''
else:
buttons[previousX, previousY]['command'] = DISABLED
buttons[x, y]['command'] = DISABLED
frist = True
root = Tk()
root.title('Matchmaker')
root.resizable(width=False, height=False)
buttons = {}
first = True
previousX = 0
previousY = 0
button_symbols = {}
symbols = [u'\u2702', u'\u2702', u'\u2705', u'\u2705', u'\u2708', u'\u2708',
u'\u2709', u'\u2709', u'\u270A', u'\u270A', u'\u270B', u'\u270B',
u'\u270C', u'\u270C', u'\u270F', u'\u270F', u'\u2712', u'\u2712',
u'\u2714', u'\u2714', u'\u2716', u'\u2716', u'\u2728', u'\u2728', ]
r.shuffle(symbols)
for x in range(6):
for y in range(4):
button = Button(command=lambda x=x, y=y: show_symbol(x, y), width=3, height=3)
button.grid(column=x, row=y)
buttons[x, y] = button
button_symbols[x, y] = symbols.pop()
root.mainloop()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn