Created
August 12, 2017 20:15
-
-
Save Sulkar/53cb894491de570cc849895de41937a9 to your computer and use it in GitHub Desktop.
[python] non-blocking Tkinter thats uses .update_idletasks()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# non blocking Tkinter code -> uses of .update_idletasks() | |
# | |
import time | |
from tkinter import * | |
# Function: with timeout | |
def mySleep(): | |
text.insert(INSERT, "start sleep\n") | |
root.update_idletasks() # updates the Tkinter form | |
time.sleep(2) | |
text.insert(INSERT, "end sleep\n") | |
root = Tk() | |
# Button | |
b1 = Button(root, text = "call mySleep", command = mySleep) | |
b1.grid(row=0,column=0) | |
# Textfield | |
text = Text(root, width=20) | |
text.grid(row=5,column=1) | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment