Variable ComboBox Named Values - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Variable ComboBox Named Values (/thread-23644.html) |
Variable ComboBox Named Values - MC2020 - Jan-09-2020 Hello All I feel like I'm missing something dumb here. I have code below to pick from a drop down list (combobox). There is some naming problem with my code. My expectation would be the combobox options would be "Trump", "Obama", and "Bush". Instead I get "dict_keys(['Trump'," , "'Obama'," , and "'Bush'])" Does anyone know adjustment I can make to get the values I am looking for? presidents = {'Trump' : {2020,2019,2018,2017} , 'Obama' : {2016,2015,2014,2013,2012,2011,2010,2009} , 'Bush' : {2008,2007,2006,2005,2004,2003,2002,2001}} import tkinter as tk from tkinter import ttk app = tk.Tk() app.title('President') app.geometry('500x300') def function(): print(combobox.get()) label = tk.Label(app, text = "Who is your favorite president?") label.grid(column=0, row=0) combovalues = presidents.keys() combobox = ttk.Combobox(app, values=combovalues) combobox.grid(column=5, row=0) resultButton = tk.Button(app, text = 'Confirm', command=function) resultButton.place(x=15,y=45) RE: Variable ComboBox Named Values - joe_momma - Jan-10-2020 it's got to be a list combovalues = list(presidents.keys()) RE: Variable ComboBox Named Values - MC2020 - Jan-10-2020 Thank you! |