Last active
May 29, 2024 21:27
-
-
Save vigilantPotato/ecf97f1fe3e1b9e9deb2f6050e7e7198 to your computer and use it in GitHub Desktop.
How to use spinbox-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 show_current_value(): | |
label["text"] = spinbox.get() | |
def when_entry_key_pressed(event): | |
show_current_value() | |
if __name__ == "__main__": | |
ctypes.windll.shcore.SetProcessDpiAwareness(1) | |
root = tkinter.Tk() | |
#label | |
label = tkinter.Label( | |
root, | |
width=15, | |
bg="lightblue", | |
) | |
label.pack() | |
#spinbox | |
spinbox = tkinter.Spinbox( | |
root, | |
values=["Easy", "Normal", "Hard"], | |
command=show_current_value, | |
width=15, | |
) | |
spinbox.bind("<Return>", when_entry_key_pressed) | |
spinbox.pack() | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment