Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Created March 31, 2024 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vigilantPotato/1304d69b973dec7fa0187d4147b8a03e to your computer and use it in GitHub Desktop.
Save vigilantPotato/1304d69b973dec7fa0187d4147b8a03e to your computer and use it in GitHub Desktop.
How to use combobox-1
import ctypes
import tkinter
from tkinter import ttk
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
var = tkinter.StringVar(root) #variable
#label
l = tkinter.Label(
root,
bg = "cyan",
width = 15,
textvariable = var,
)
l.pack()
#combobox
item_list = ["Easy", "Normal", "Hard"]
combobox = ttk.Combobox(
root,
values = item_list, #set item_list
textvariable = var,
)
combobox.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment