0
工作,我試圖創建一個使用Tkinter的模塊中的環結合。事件和綁定在Tkinter的不循環
from tkinter import *
class Gui(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def Arrays(self,rankings):
self.panels = {}
self.helpLf = LabelFrame(self, text="Array Layout:")
self.helpLf.grid(row=10, column=9, columnspan=5, rowspan=8)
for rows in range(10):
for cols in range(10):
x = str(rows)+"_"+str(cols)
self.row = Frame(self.helpLf)
self.bat = Button(self.helpLf,text=" ", bg = "white")
self.bat.grid(row=10+rows, column=cols)
self.panels[x] = self.bat
self.panels[x].bind('<Button-1>', self.make_lambda())
self.panels[x].bind('<Double-1>', self.color_change1)
def color_change(self, event):
"""Changes the button's color"""
self.bat.configure(bg = "green")
def color_change1(self, event):
self.bat.configure(bg = "red")
這裏有10X10 = 100個按鈕。該活頁夾僅適用於最後一個按鈕。有誰知道我該如何應用所有按鈕的活頁夾?
真棒上。有效。 –