I'm making a simple tkinter UI to get user input to run a script. I've made UIs like this before, but for some reason this time the grid() method creates overlapping widgets. I double-checked to ensure that each widget has a unique row and column within its parent frame. The two label frames I have don't show their label either.
root = tk.Tk()
# Frame for input options
inputFr = tk.Frame(root)
inputFr.grid(row=1,column=0)
# variable for excel book to import
xlBookVar = tk.StringVar()
# variables for spreadsheet columns
serialNumberColVar = tk.StringVar()
apNameColVar = tk.StringVar()
apControllerColVar = tk.StringVar()
switchNameColVar = tk.StringVar()
portNumberColVar = tk.StringVar()
displayStrColVar = tk.StringVar()
descriptionColVar = tk.StringVar()
# other variables
ignoredRowsVar = tk.IntVar()
tk.Label(inputFr,text="Excel Book Name: ").grid(row=1,column=0,sticky='W')
tk.Entry(inputFr,textvariable=xlBookVar).grid(row=1,column=1)
tk.Label(inputFr,text="ignored rows from top: ").grid(row=2,column=0,sticky='W')
tk.Entry(inputFr,textvariable=ignoredRowsVar).grid(row=2,column=1)
apNameFr = tk.LabelFrame(inputFr,text="AP Name").grid(row=3,column=0,columnspan=2)
tk.Label(apNameFr,text="Serial Number column: ").grid(row=1,column=0,sticky='WE')
tk.Entry(apNameFr,textvariable=serialNumberColVar).grid(row=1,column=1,sticky='WE')
tk.Label(apNameFr,text="AP name Column: ").grid(row=2,column=0,sticky='WE')
tk.Entry(apNameFr,textvariable=apNameColVar).grid(row=2,column=1,sticky='WE')
tk.Label(apNameFr,text="AP controller Column: ").grid(row=3,column=0,sticky='WE')
tk.Entry(apNameFr,textvariable=apControllerColVar).grid(row=3,column=1,sticky='WE')
portDesFr = tk.LabelFrame(inputFr,text="Port Description").grid(row=4,column=1,columnspan=2,sticky='NESW')
tk.Label(portDesFr,text="Switch Name column: ").grid(row=1,column=0,sticky='WE')
tk.Entry(portDesFr,textvariable=switchNameColVar).grid(row=1,column=1,sticky='WE')
tk.Label(portDesFr,text="Port number column: ").grid(row=2,column=0,sticky='WE')
tk.Entry(portDesFr,textvariable=portNumberColVar).grid(row=2,column=1,sticky='WE')
tk.Label(portDesFr,text="display String column: ").grid(row=3,column=0,sticky='WE')
tk.Entry(portDesFr,textvariable=displayStrColVar).grid(row=3,column=1,sticky='WE')
tk.Label(portDesFr,text="description String column: ").grid(row=4,column=0,sticky='WE')
tk.Entry(portDesFr,textvariable=descriptionColVar).grid(row=4,column=1,sticky='WE')
tk.Button(root,text="Run",command=Run).grid(row=2,column=0)
root.mainloop()
Here is the output:
Here is the structure that I'm trying to achieve:
- {Input Frame}
- Excel Book Name: __
- Ignored rows from top: __
- {apNameFr} ap name
- Serial Number column: __
- etc..
- {portDesFr} Port Description
- Switch Name column: __
- etc ..
- {button} Run