我使用for循环创建了一个按钮网格(目的是更加高效),但是我想说一下,例如,如果选择第二行上的任何按钮,它将具有不同的效果命令确定是否选择了第一行上的按钮。
TypeError: __call__() takes from 1 to 2 positional arguments but 3 were given.
这是创建按钮的地方,如果这可以帮助任何人识别如何获得我的帮助。
更好的选择是打印所选按钮的编号,但是由于按钮的文本在循环中从未保持不变,因此我不确定这是否可行。
答案 0 :(得分:0)
这应该有效:
def makeCalendar(blank):
curMonth = int(dropMonths.get())
for i in buttons:
if i.thing:
i.thing.destroy()
for i in newFrame.slaves():
i.destroy()
rows = [Frame(newFrame) for i in range(5)]
[i.pack() for i in rows]
curDay = 1
for i in range(35):
if len(rows[0].slaves()) == 7:
rows.pop(0)
temp_button = ButtonsWrap(rows[0], curMonth, curDay, text='', height=1,
width=2)
temp_button.button.pack(side='left')
if curDay <= months[curMonth]:
temp_button.button.configure(text=curDay, command=lambda TMP=i: bid(TMP))
curDay += 1
buttons.append(temp_button)
def bid(i):
print(i)
您的代码很难阅读,但这与您的问题无关。