Python Forum
Variable ComboBox Named Values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable ComboBox Named Values
#1
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)
Reply


Messages In This Thread
Variable ComboBox Named Values - by MC2020 - Jan-09-2020, 11:20 PM
RE: Variable ComboBox Named Values - by joe_momma - Jan-10-2020, 12:31 AM
RE: Variable ComboBox Named Values - by MC2020 - Jan-10-2020, 02:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  store all variable values into list and insert to sql_summary table mg24 3 1,164 Sep-28-2022, 09:13 AM
Last Post: Larz60+
  Compare variable with values in a file paulo79 1 1,125 Apr-22-2022, 03:16 AM
Last Post: Pedroski55
  How to add for loop values in variable paulo79 1 1,459 Mar-09-2022, 07:20 PM
Last Post: deanhystad
  How to display combobox related values in labels Lalremruata 0 1,570 Jul-20-2021, 02:45 AM
Last Post: Lalremruata
  Print variable values from a list of variables xnightwingx 3 2,651 Sep-01-2020, 02:56 PM
Last Post: deanhystad
  Limiting valid values for a variable in a class WJSwan 5 3,666 Jul-06-2020, 07:17 AM
Last Post: Gribouillis
  How to pass multiple values from one sample to nc variable? Baloch 0 1,873 Jun-01-2020, 09:27 PM
Last Post: Baloch
  Spyder hides middle array values in variable explorer window davidqvist 0 2,396 Aug-03-2018, 11:04 AM
Last Post: davidqvist
  Dictionary named after variable value Alfred 1 3,064 Sep-02-2017, 01:24 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020