1
私はサークルを作成し、以下のコードに示すように、ボタンのクリックで色を反復持っていた場合:Tkinterで円の特定の色を検出する方法は?
color_iteration1 = itertools.cycle(('blue', 'green', 'orange', 'red', 'yellow'))
color_iteration2 = itertools.cycle(('blue', 'green', 'orange', 'red', 'yellow'))
color_iteration3 = itertools.cycle(('blue', 'green', 'orange', 'red', 'yellow'))
color_iteration4 = itertools.cycle(('blue', 'green', 'orange', 'red', 'yellow'))
def callback1():
mcircle1 = mycanvas.create_oval(10,620,86,675, outline='#000000',fill=next(color_iteration1))
def callback2():
mcircle2 = mycanvas.create_oval(100,620,176,675, outline='#000000',fill = next(color_iteration2))
def callback3():
mcircle3 = mycanvas.create_oval(190,620,266,675, outline='#000000',fill = next(color_iteration3))
def callback4():
mcircle4 = mycanvas.create_oval(280,620,356,675, outline='#000000',fill = next(color_iteration4))
B1 = Button(root,text='B1',command =callback1)
B2 = Button(root,text='B2',command =callback2)
B3 = Button(root,text='B3',command =callback3)
B4 = Button(root,text='B4',command =callback4)
私は円がそれだった、任意の時点でいたどんな色格納しますどのように反復リストに含まれています。たとえば、ボタンを2回押して緑色にすると、mcircleが緑色になり、それを変数として保存する方法を教えてください。
ああ、また円の各ピクセルを通過する方法があり、特定のRGB値を検出した場合は、特定の変数を任意の色にするフラグを送出します値はサークル内にありましたか?