-3

I have a variable named playerGold and it starts with a value of 0. (playerGold=0). I have this variable displayed on a label on my tkinter GUI (playerGoldLabel).

I want to make it so when I click a button it adds on 13 to the playerGold variable and updates the tkinter label.

I have tried playerGold + 13 and using playerGoldLabel.config(text=playerGold) to try and update it but it doesn't seem to work. Any help would be appreciated.

Alfe
  • 56,346
  • 20
  • 107
  • 159
  • This question appears to be off-topic because it is about a lack of basic understanding of what value assignation is – joaquin May 28 '14 at 11:18
  • Apologies for the close/reopen (which I think reset the close votes...). My mouse was a few seconds ahead of my brain. – Veedrac Jun 06 '14 at 11:41

2 Answers2

1

playerGold + 13 does not change anything. If you want to modify a variable, you will need to use playerGold = playerGold + 13, or shorter playerGold += 13.

mrks
  • 8,033
  • 1
  • 33
  • 62
  • Please only answer if your answer is a good answer. Otherwise stick to comments to find out whether you understood the question correctly. _This_ answer here just marks the question as answered but probably does not solve the tkinter issues OP has. – Alfe May 28 '14 at 09:47
  • Thank you for the quick and simple answer! This solved my little problem. – user3654976 May 28 '14 at 09:47
  • @ user3654976 : please accept mdsl answer, as it solves the problem. – Louis May 28 '14 at 09:51
0
myVar = myVar + 13

It's so simple I don't know if i really get your problem

  • 1
    Yeah, and that's why this should have been a comment, not an answer :-( By giving fast (and perhaps useless) answers you take the focus from this question as it appears to be answered. Many readers will not read this question anymore. – Alfe May 28 '14 at 09:43
  • In this case it was actually simple but i get this for the next time – Pierre Turpin May 28 '14 at 09:49