当按下按钮进行打印时,如何让tkinter进入if循环?我不希望打印命令出现在按钮功能中。
代码:
from tkinter import *
class Player:
N = 0
def __init__(self, name, points):
# instance variables goes here
self.name = name
self.score = points
# increment class variable
Player.N = Player.N+1
class G_501:
def __init__(self, players=[]):
self.NoPlayers = len(players)
print("Number of players",self.NoPlayers)
Spillere = []
Score = []
Runde = 0
for i in range(0, len(players)):
P = Player(players[i], 501)
print("Player", Player.N, P.name, "- Point:", P.score)
Spillere.append(P.name)
Score.append(P.score)
Score = list(map(int, Score))
root = Tk()
c = [False]
def half_bull(c, event=None):
c.append(True)
return c
b1 = Button(root, text="Half Bull", bg="green", fg="black", command=lambda c=c: half_bull(c))
b1.pack()
print(c)
if c[-1] == True:
print("Fedt")
root.mainloop()
S = G_501(["Chr"])
只需要tkinter
部分的帮助......谢谢!