olenka
olenka

Reputation: 33

Tkinker spinbox get

I'd like to print output value from spinbox, after clicking enter. I don't know why it is printing always value "from_" (so 1). What is the problem? Thank you.

import tkinter as tk
gui = tk.Tk()

gui.geometry("300x390")
gui.title("Test")

var = tk.IntVar()
tk.Spinbox(
    gui,
    textvariable=var,
    from_=1,
    to=10).pack()

a = var.get()

def print_test():
    print(a)


enter = tk.Button(gui, text="Enter", command=print_test).pack(pady=15)

gui.mainloop()

Upvotes: 2

Views: 35

Answers (0)

Related Questions