0

I am trying to print the output answer to my GUI in Tkinter and I can not seem to see how it is possible! If anyone has any tips please let me know. I know its somewhere along the lines of this but I cannot seem to crack it!

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

here is the full section of code:

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
ApexSnake
  • 37
  • 1
  • 7
  • `def compareFearFactor():` has nothing within the function? I suspect an indentation error – Reedinationer Mar 15 '19 at 21:26
  • apologies that was my fault from copying it over from python, indentation if fine. – ApexSnake Mar 15 '19 at 21:30
  • Since I (nor anyone else on here) can copy/paste it and run it ourselves since it is not a MCVE as described here https://stackoverflow.com/help/mcve I will provide a speculative answer. Yes, you should be able to just configure the text, but I personally would do `DisplayFearFactor.configure( text = " computers FearFactor: {}".format(computersCardFearFactor))`. Since this is in a function you should not have to place it every time with `DisplayFearFactor.place(bordermode=OUTSIDE, height=60, width=200,x=100,y=100)` but only once when your GUI initializes – Reedinationer Mar 15 '19 at 21:34
  • See the `errorwindow3k` module in [this answer](https://stackoverflow.com/questions/48977473/display-the-output-of-the-program-on-gui-with-tkinter/49016673#49016673) of mine. It will redirect printed output to a (tkinter-based) window. – martineau Mar 15 '19 at 22:22

0 Answers0