tkinter - Direct entry in the SpinBox -


consider simple code:

from tkinter import * root = tk()  def update_label():     my_label.config(text = my_var.get())   my_label = label(root, text = "?") my_label.pack() my_var = intvar() spinbox(root, from_ = 1, = 10,  textvariable = my_var, command = update_label).pack() root.mainloop() 

the documentation @ new mexico tech states that:

the user can enter values directly, treating widget if entry.

however if enter value directly in spinbox above code, not trigger command callback.

further, can enter value in spinbox widget despite fact have restricted -from , _to values between 1 , 10.

my questions:

  1. can direct entry in spinbox triggers command callback ?

  2. can restrict value can entered directly within 1 , 10 ?

you can add trace my_var can called everytime value changes. little more information, see:

what arguments tkinter variable trace method callbacks?

you can data validation using validate , validatecommand attributes of spinbox. works same entry widget, covered here:

interactively validating entry widget content in tkinter


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -