Aug-25-2023, 08:25 AM
Here is an example using a callback function
import tkinter as tk from tkinter import ttk # Function to print value. Using combo.get() to get the value def callback(event): label['text'] = f'Selected: {combo.get()}' root = tk.Tk() root.geometry('400x200+300+300') # Label to display text label = tk.Label(root, anchor='w') label.pack(fill='x',padx=10) # Some values to populate the combobox values = [(f'Value {i}') for i in range(11)] # Define the combobox combo = ttk.Combobox(root, state='readonly') combo['values'] = values combo.current(0) combo.pack(pady=5) # Bind the combobox and set the function callback combo.bind('<<ComboboxSelected>>', callback) # Print starting value for label label['text'] = callback(event=None) root.mainloop()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags