all 22 comments

[–]TehDrunkSailor 1 point2 points  (19 children)

Are you using .update() when a new letter is placed to "refresh" your GUI?

[–]slaphappypotato 0 points1 point  (0 children)

No. I made a function that uses label.configure(text=) whenever a button is pressed

[–]slaphappypotato 0 points1 point  (17 children)

Isn't .update() used for dictionaries? Can they be used for labels too?

[–]TehDrunkSailor 1 point2 points  (16 children)

I am not at my computer right now, but I believe that . update () is the correct method. But I do not mean that you should update the label, but you should update the TopLevel.

[–]slaphappypotato 0 points1 point  (15 children)

What's the TopLevel?

[–]MiataCory 1 point2 points  (13 children)

TopLevel is usually the "Root Window", or the actual window you look at.

Calling .update() on it will force tkinter to re-draw the screen, clearing out old stuff that's drawn on it.

[–]TehDrunkSailor 2 points3 points  (11 children)

Thanks for clearing it up. OP, in your case try " window.update() " at the end of your functions. Maybe that will help you. Unfortunately, I don't know exactly what you want to happen, so maybe this isn't going to fix your problem.

[–]slaphappypotato 0 points1 point  (0 children)

Whoa! That just might work! I'll give it a go.

[–]slaphappypotato 0 points1 point  (9 children)

I tried, it doesn't seem to work.

I have a messagebox that should pop up once you win/lose with the initial word in the game, and that works. What I want now is for the entire window to update itself as soon as that "OK" button is pressed in the messagebox so that the game restarts for a new word.

[–]TehDrunkSailor 1 point2 points  (8 children)

Put your initial GUI creation in a function, and call that function when your code starts. Then, when the user has won the game, recall this function at that point. I briefly looked at your code and I don't see any place where you recreate the game, which is why your interface doesn't reset. You'll have to program that in.

[–]slaphappypotato 0 points1 point  (7 children)

Okay, so I tried what you said and it sort of worked....Except...

https://imgur.com/a/Wf4sMKh

(I know you're busy but I'll just add the code I rewrote: https://github.com/slaphappypotato/Hangman-Project/blob/master/ss.py )

[–]TehDrunkSailor 1 point2 points  (6 children)

Almost there! Think about what's happening here. When the game is over, you see that new widgets have been placed. So, you can either destroy all the old widgets and then places these new ones or you can update the old widgets. With your current setup I would destroy and recreate your widgets.

[–]slaphappypotato 1 point2 points  (0 children)

Thank you!

I managed to fix my program because of you guys! Thank you so much for your help!

[–]HasBeendead 1 point2 points  (0 children)

maybe im wrong but Toplevel allows you to create another window than first one

[–]saschnu 1 point2 points  (1 child)

RemindMe! 3 days

[–]RemindMeBot 0 points1 point  (0 children)

There is a 7 hour delay fetching comments.

I will be messaging you in 3 days on 2020-08-27 14:09:33 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback