Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Last active May 29, 2024 21:27
Show Gist options
  • Save vigilantPotato/ecf97f1fe3e1b9e9deb2f6050e7e7198 to your computer and use it in GitHub Desktop.
Save vigilantPotato/ecf97f1fe3e1b9e9deb2f6050e7e7198 to your computer and use it in GitHub Desktop.
How to use spinbox-2
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