I am trying to take input from the user using tkinter. It asks for a number. I then want to take that number and create the amount of excel cells. I have my "excelcells" function working on its own but when im trying to take variable x as a number and convert it into a list i get conversion errors that i cant get past.
from tkinter import *
window = Tk()
Label(window, text='Number of Cells').grid(row=0)
e1 = Entry(window)
e1.grid(row=0, column=1)
get = e1.get()
numfinal = int(get)
x = []
for i in range(0,int(numfinal)):
x.append(i)
def excelcells(x):
height = 1
for i in range(height):
for j, val in enumerate(x):
b = Entry(window)
b.insert(0, val)
b.grid(row=i, column=j)
window.mainloop()
Button(window, text='Create', command=excelcells(x)).grid()
window.mainloop()
This is the error i get "could not convert string to float: 'get'"
How can i pass the x list to my "excelcells" function when the create button is clicked? and convert the input given to the entry window from a string to an int?
part2:
How do i convert get variable from a string to an int?
current error: invalid literal for int() with base 10: ''
float('get')?Or do you meanfloat(get)?command=excelcells(x)should becommand=lambda: excelcells(x).