Created
March 31, 2024 22:16
-
-
Save vigilantPotato/d9015ec501fcba2077b6c5aa2acc8236 to your computer and use it in GitHub Desktop.
How to use combobox-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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