Tkinter: a basic input window

This little script makes you get the user input.

import tkinter as tk

def check(event):
    global url
    user_input = entry.get()
    label['text'] = user_input
    button = tk.Button(root, text="Chiudi", command=root.destroy)
    button.pack()
    # root.destroy()

# Input from user
root = tk.Tk()
root.title("Insert Something here")
# v = tk.StringVar()
label = tk.Label(root, text="Insert ..... and the press Return")
label['font'] = "Arial 20"
label.pack()
entry = tk.Entry(root)
entry.pack(fill=tk.BOTH, expand=1)
entry.bind("<Return>", check)
entry.focus()
root.mainloop()

 

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.