在Tkinter GUI中显示输出

2024-07-04 06:04:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在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

Tags: imageifconfigurepopcomputercardsprinthuman

热门问题