- I created a simple spin box. what I want is, as I increase or decrease the value in spin box, a new entry should be created or deleted respectively.
- I am not able to get the Int value from the spinbox.
- I tried, user_input = int(sb.get()), But this also didn't work.
- I am getting this error, 'str' object cannot be interpreted as an integer.
,,,
1st code:
from tkinter import *
root = Tk()
sb_var = IntVar()
sb = Spinbox(root, bg='gray', textvariable=sb_var)
sb.pack()
user_input = sb.get()
for x in range(user_input):
my_entry = Entry(root)
my_entry.pack()
root.mainloop()
,,,
2nd code:
from tkinter import *
root = Tk()
root.geometry("500x400")
def up_or_down(direction):
if direction == "up":
my_entry = Entry(root)
my_entry.pack()
if direction == "down": # I don't know how to code this condition
my_entry.destroy()
tcl_up_or_down = root.register(up_or_down)
sb = Spinbox(root, from_=0, to=100, bg='gray', command=(tcl_up_or_down, '%d'))
sb.pack()
root.mainloop()
'''