Python Forum
.get() not retrieving value?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.get() not retrieving value?
#3
Doing my best to reconstruct your code I came up with this:
import tkinter as tk
import tkinter.ttk as ttk


def store_selected_value(event=None):
    grad_sel = gradient_dropdown.get()
    global stored_value
    stored_value= grad_sel
    print(f"Gradient: '{stored_value}'")


root = tk.Tk()
stored_value = None
column_frame = tk.Frame(root)
column_frame.pack(padx=50, pady=50)

gradient_value = ["0%","10%","15%","20%"]
gradient_dropdown = ttk.Combobox(column_frame, values=gradient_value, state="readonly")
gradient_dropdown.pack(pady=5)
gradient_dropdown.bind("<<ComboboxSelected>>", store_selected_value)

root.mainloop()
As I select the gradient values one at a time it prints:
Output:
Gradient: '0%' Gradient: '10%' Gradient: '15%' Gradient: '20%'
The problem must be somewhere else in your code.
Reply


Messages In This Thread
.get() not retrieving value? - by Sedos101 - Aug-25-2023, 06:02 AM
RE: .get() not retrieving value? - by menator01 - Aug-25-2023, 08:25 AM
RE: .get() not retrieving value? - by deanhystad - Aug-25-2023, 11:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  KeyError while retrieving ESPN data john317ab 2 856 Nov-29-2023, 09:07 PM
Last Post: john317ab
  [Solved] Retrieving a pdf from sqlite3 BigMan 4 2,381 Mar-12-2022, 01:56 PM
Last Post: deanhystad
  Retrieving a column from a data set using a function Bayle 6 2,403 Oct-06-2021, 08:52 PM
Last Post: Bayle
  Retrieving Cookies whois1230 2 2,222 Nov-21-2020, 12:01 PM
Last Post: snippsat
  Problem: Retrieving Form data PythonDev 3 3,131 Oct-16-2020, 02:09 AM
Last Post: PythonDev
  Retrieving dictionary keys within with another dictionay bazcurtis 8 2,889 Oct-29-2019, 10:06 PM
Last Post: bazcurtis
  Retrieving items from JSON bazcurtis 12 5,107 Oct-27-2019, 05:18 PM
Last Post: bazcurtis
  Trouble retrieving dictionary from mysql.connector cursor swechsler 2 3,097 Sep-17-2019, 05:21 PM
Last Post: swechsler
  retrieving pvalue from statsmodels results Staph 4 3,072 Jul-18-2019, 03:27 PM
Last Post: Gribouillis
  PRAW and PyQt: Immense slowdown when retrieving Reddit posts and adding them to GUI codebro 2 3,252 Dec-30-2018, 01:19 AM
Last Post: codebro

Forum Jump:

User Panel Messages

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