I've been trying some GUI programming and needed help with the below code.
I am trying to run a button functioning which needs to return a list and i need to use that in a Combobox
. But the list is not getting used in Combobox
.
import tkinter as tk
from functools import partial
from tkinter import ttk
f=[]
def getlist(a):
li=[]
f=[]
if a==2:
li=[1,2,3,4,5,6]
for i in li:
f.append(li.get())
else:
return False
root=tk.Tk()
root.title('Hello')
root.geometry('250x250')
ttk.Label(root, text = "Press the button",font = ("Times New Roman", 10)).grid(column = 0,row = 1, padx = 10, pady = 25)
tk.Button(root,text='Press',command=getlist(8)).grid(row=2,column=0)
a = tk.StringVar()
namechoosen = ttk.Combobox(root, width = 27, textvariable = a)
namechoosen['values'] = f
namechoosen.grid(column=0,row=3)
namechoosen.current()
window.mainloop()