Skip to content

Python code snippet – How to wait until pressing button in tkinter?

import tkinter as tk
root = tk.Tk()
var = tk.IntVar()
button = tk.Button(root, text="Click Me", command=lambda: var.set(1)), rely=.5, anchor="c")

print("done waiting.")
See also  How to know if the space button has been clicked in Python pygame?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.