Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Created May 14, 2024 21:00
Show Gist options
  • Save vigilantPotato/ec2f36b3efcb5947d71359ec85bb62bd to your computer and use it in GitHub Desktop.
Save vigilantPotato/ec2f36b3efcb5947d71359ec85bb62bd to your computer and use it in GitHub Desktop.
How to use comobox-3
import ctypes
import tkinter
from tkinter import ttk
def get_selected(event):
l["text"] = combobox.get()
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
#label
l = tkinter.Label(
root,
text = "selected",
width = 15,
bg = "lightblue",
)
l.pack()
#combobox
item_list = ["Easy", "Normal", "Hard"]
combobox = ttk.Combobox(
root,
values = item_list, #set initial value
)
combobox.bind("<<ComboboxSelected>>", get_selected)
combobox.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment