Skip to content

Why on click of button it doesn't change text and color? #1584

Answered by freakboy3742
ccinsz asked this question in Q&A
Discussion options

You must be logged in to vote

The explanation for this requires a little bit of understanding of how GUI apps work.

A GUI app is, at the code, essentially the following code:

while not exit:
    redraw()
    handle_events()

That is - it is in a constant loop redrawing, then handling events (things like mouse clicks, keyboard presses, etc). While the GUI is redrawing, it's not handling events; and when it's handling events, it's not redrawing.

Your start() method is an event handler; so when you invoke it, that code will be executed, one line after another. However - time.sleep() is a blocking method. While the code is sleeping in that call, the app isn't doing anything else - including redrawing itself. You've change…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ccinsz
Comment options

Answer selected by ccinsz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants