mardi 5 janvier 2021

Phython: Reading from a spin box numbers and do following command of one

Good Morning/Evenig, I wants to read a number from a spinbox, and if it is 2, it should print something. But my code does not work out. I've tried it with a slider instead of a spinbox and it worked out. But for me, it is really important to use a spinbox, so I hove anybody has an idea.

from tkinter import *
    def a():
      if spin.get()==2:
        print("Hello World")
root = Tk()
root.geometry('300x100')
spin =Spinbox(root, from_=0, to=10,command=a)
button = Button(root, text='Enter')
button.pack(side=RIGHT)
spin.pack(side=RIGHT)
root.mainloop()

Aucun commentaire:

Enregistrer un commentaire