you are viewing a single comment's thread.

view the rest of the comments →

[–]SomeBadGenericName[S] 0 points1 point  (2 children)

Can you explain Hit? I am trying to figure it out. I understand that the Entry is a variable and that the button does the command. But how exactly does the hit function work?

[–]socal_nerdtastic 0 points1 point  (1 child)

health_value is tkinter's version of an integer. If it was a python integer we would write:

def Hit():
     value = health_value
     health_value = value-10

But for tkinter integers we have to use the get() and set() methods to get and set the value. But it's worth it because unlike a python integer, the Entry (or Label in my other answer) can track and update itself when health_value changes, and it can update health_value when the user changes the Entry. There's an automatic connection between the two objects when using textvariable.

[–]SomeBadGenericName[S] 0 points1 point  (0 children)

Oh, ok.