Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Created March 31, 2024 22:16
Show Gist options
  • Save vigilantPotato/d9015ec501fcba2077b6c5aa2acc8236 to your computer and use it in GitHub Desktop.
Save vigilantPotato/d9015ec501fcba2077b6c5aa2acc8236 to your computer and use it in GitHub Desktop.
How to use combobox-2
import ctypes
import tkinter
from tkinter import ttk
def get_selected():
b["text"] = combobox.get()
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
#button
b = tkinter.Button(
root,
text = "selected",
width = 15,
bg = "lightblue",
command = get_selected,
)
b.pack()
#combobox
item_list = ["Easy", "Normal", "Hard"]
combobox = ttk.Combobox(
root,
values = item_list, #set initial value
)
combobox.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment