13.2 Method
13.2.1 bbox(index)
The return includes index Rectangle of the specified character . Return value bit (x,y,w,h) Four tuples of .
import tkinter as tk
root=tk.Tk()
root.geometry('300x240')
tk.Label(root).pack()
b1=tk.Spinbox(root,from_=110,to=115,width=4)
b1.pack()
print(b1.bbox(2))
root.mainloop()
**13.2.2 config(options)
modify Spinbox Configuration parameters for .
13.2.3 delete(first,last=None)
Delete the contents of the input control . See 6.2.2.
13.2.4 get()
Get the content in the input box . See 6.2.3.
13.2.5 icursor(index)
Move the input cursor to the specified position . See 6.2.4.
13.2.6 identify(x, y)
Confirm the coordinate point of the input screen , Whether in Spinbox Within the scope of .
(x,y): Screen coordinate point
Return value : character string
“buttonup”: up arrow
“buttondown”: Down arrow
“entry”: Input box
import tkinter as tk
root=tk.Tk()
root.geometry('300x240')
b1=tk.Spinbox(root,from_=110,to=115,width=14)
b1.pack()
def pos(event):
print(b1.identify(event.x,event.y))
b1.bind('<Button-1>',pos)
root.mainloop()
13.2.7 index(i)
Return location information of numeric type . See 6.2.5.
13.2.8 insert(index, string)
Insert the string at the specified position . See 6.2.6.
13.2.9 invoke(element)
call Spinbox Up arrow button or down arrow button . in other words , Every call invoke(‘buttonup’) perhaps invoke(‘buttondown’) It is equivalent to pressing the up arrow button or down arrow button once , The value in the input box will also change accordingly .
import tkinter as tk
root=tk.Tk()
root.geometry('300x240')
b1=tk.Spinbox(root,from_=10,to=40)
b1.pack()
def invoke():
b1.invoke('buttonup')
b2=tk.Button(root,text='Invoke',command=invoke)
b2.pack()
root.mainloop()
13.2.10 selection_adjust()
Adjust the selection area in the input box . See 6.2.8.
13.2.11 selection_clear()
Clear selection . See 6.2.9.
13.2.12 selection_element(element=None)
Select the specified element . Elements are :’buttonup’,’buttondown’ as well as ’none’. If there is no input element, Then return the currently selected element . However, the implementation of this method has bug, If you do not enter any parameters , Returns the TclError.