如果在tkinter中循环 - 按下按钮

时间:2016-12-30 12:21:13

标签: if-statement button tkinter

当按下按钮进行打印时,如何让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部分的帮助......谢谢!

0 个答案:

没有答案