我需要此代码的帮助:
from tkinter import *
#import rhinoscriptsytnax as rs
import time
from random import shuffle
from pygame.locals import*
import pygame, sys, random
import pygame.locals as GAME_GLOBALS
import pygame.event as GAME_EVENTS
import pygame.time as GAME_TIME
##################################
所以大多数代码我都使用tkinter来创建形状
root=Tk()
canvas=Canvas(width=600,height=600) #to design the window
canvas.pack()
color=["yellow","lawn green","blue","red","red","yellow","lawn green","blue"]
lisst=color[:]
shuffle(lisst) #to change the list each time
具有游戏颜色的主椭圆
canvas.create_oval(260,400,360,500,fill=lisst[4]) #x axis,y axis, color
canvas.create_oval(380,120,480,220,fill=lisst[5])
canvas.create_oval(100,230,200,330,fill=lisst[1])
canvas.create_oval(420,230,520,330,fill=lisst[7])
canvas.create_oval(260,80,360,180,fill=lisst[2])
canvas.create_oval(140,120,240,220,fill=lisst[6])
canvas.create_oval(140,350,240,450,fill=lisst[3])
canvas.create_oval(380,350,480,450,fill=lisst[0])
#we make it black to start the game
#color1 = rs.CreateColor(128, 128, 128,1)
#to cover the main circle
我把另一个椭圆形覆盖了第一个
ovalA= canvas.create_oval(260,400,360,500,fill="black") #x axis,y axis, color
canvas.tag_bind(ovalA, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalA, fill=''))
ovalB=canvas.create_oval(380,120,480,220,fill="black")
canvas.tag_bind(ovalB, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalB, fill=''))
ovalC=canvas.create_oval(100,230,200,330,fill="black")
canvas.tag_bind(ovalC, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalC, fill=''))
ovalD=canvas.create_oval(420,230,520,330,fill="black")
canvas.tag_bind(ovalD, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalD, fill=''))
ovalE=canvas.create_oval(260,80,360,180,fill="black")
canvas.tag_bind(ovalE, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalE, fill=''))
ovalF=canvas.create_oval(140,120,240,220,fill="black")
canvas.tag_bind(ovalF, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalF, fill=''))
ovalG=canvas.create_oval(140,350,240,450,fill="black")
canvas.tag_bind(ovalG, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalG, fill=''))
ovalH=canvas.create_oval(380,350,480,450,fill="black")
canvas.tag_bind(ovalH, '<Button-1>', lambda event, canvas=canvas:
canvas.itemconfig(ovalH, fill=''))
#button-1 it's the left click in the mouse
#we used to
def _on_press(self, event):
self.configure(relief="sunken"
def _on_release(self, event):
self.configure(relief="raised")
if self.command is not None:
self.command()
root.mainloop()
现在我如何使python知道两个椭圆形中的红色是否匹配并且 不同的颜色不匹配(关键是我从 随机)
from random import shuffle
所以我需要让python知道我用shuffle的椭圆形断奶的颜色