在Tkinter GUI中显示输出

时间:2019-03-15 21:23:21

标签: python user-interface tkinter

我正在尝试在Tkinter中将输出答案打印到我的GUI中,我似乎看不到这是怎么可能的!如果有人有任何提示,请告诉我。 我知道它与此类似,但我似乎无法破解!

DisplayFearFactor.configure( text = " computers FearFactor: " + str(computersCardFearFactor))
DisplayFearFactor.place(bordermode=OUTSIDE, height=60, width=200,x=100,y=100)

这是完整的代码部分:

def compareFearFactor():

    human = []
    computer = []

    if len(cards) > 0:
        human.append(cards.pop(0))
        computer.append(cards.pop(0))

   humanCard = human.pop(0) if human else None
   computersCard = computer.pop(0) if computer else None

   print("computers Fear Factor:", computersCard.FearFactor)
   Draw = (humanCard.FearFactor == computersCard.FearFactor)
   Win = (humanCard.FearFactor > computersCard.FearFactor)

  DisplayFearFactor.configure( text = " computers FearFactor: " + str(computersCardFearFactor))
  DisplayFearFactor.place(bordermode=OUTSIDE, height=60, width=200,x=100,y=100)

  computercardshow = ImageTk.PhotoImage(computersCard.image)
  Comp = Label(image = computercardshow)
  Comp.configure(image = computercardshow)
  Comp.place(x=800,y=50)
  Comp.image = computercardshow

  if  Draw:
      print("It's a tie!")
      human.append(humanCard)
      computer.append(computersCard)
  elif Win:
      print("You win this hand!")
      cards.append(humanCard)
      cards.append(computersCard)
      playerTurn = True


  else:
      print("You lose this hand!")
      computer.append(computersCard)
      computer.append(humanCard)
      playerTurn = False

0 个答案:

没有答案