程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python Tkinter -- Chapter 13 value adjustment control (spinbox) method

編輯:Python

13.2 Method

Method describe bbox(index) Returns the rectangular boundary of the specified character config(**options) To configure Spinbox Properties of . See Spinbox Attribute specification .delete(first, last=None) Delete the selected text . The beginning is first,last If there is no definition , Only the current character is deleted .get() Get the content of the current control . The return value is a string icursor(index) Move the insertion cursor to the specified position .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
None: be not in spinbox Within the scope of .index(index) get index The position of the specified number type .insert(index, string) stay index Insert character at position .insert(INSERT,string) Insert a character at the position of the insertion cursor insert(END,string) Add text invoke(element) call Spinbox The button . Only when “buttonup”,”buttondown”selection_adjust(index) Adjust selection to index Location . If index Has been chosen , No action .selection_clear() Clear selection selection_element(element=None) Choose one element, If this parameter is not set , Returns the currently selected element.
element finger : up arrow 、 Down arrow 、 Input box

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.


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved