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

Python Tkinter - Chapter 10 text control (text) text position index

編輯:Python

10.2 The location index of the text control
Text control can edit multi line and multi column text , How to locate the position is an important problem . In a text control , Use a variety of methods to locate the position .

10.2.1 Location index
(1)’ That's ok . Column ’(‘line.column’)
That is, the method of specifying rows and columns . And the plane coordinates in mathematics are the same principle .(x,y) Represents a coordinate point ,( That's ok , Column ) Represents a location . such as ’1.0’ Before the first character of the first line ,’3.4’ Indicates the position before the fifth character of the third line . Be careful , The starting line is 1, instead of 0. Use character strings in programs to represent .

(2)’ That's ok .end’(‘line.end’)
use ’end’ End of line . It can avoid the trouble of calculating characters , Go directly to the end of a line . such as ’8.end’

(3)tk.INSERT
Insert the position of the cursor

(4)tk.CURRENT
Represents the position of the character closest to the mouse pointer . Be careful , This is different from inserting . The insertion position is the position of the insertion cursor . The current representation is the character position closest to the mouse pointer . If you press the mouse button , that “ At present ” The position of the is fixed , Even moving the mouse will not change , Until you release the mouse button , Will update .

(5)tk.END
After the last character of the text control . This index is for the entire text control , Instead of the current line .

(6)tk.SEL_FIRST
If an area of the current text is selected ,tk.SEL_FRIST Indicates the front position of the first character in the selected area .

(7)tk.SEL_LAST
tk.SEL_LAST Indicates the position after the last character in the selected area .

(8)’ Identification name ’(‘markname’)
The specific method of use is to define an identifier . Then use this identifier as an index .

(9)‘tag.first’
Definition tag To identify an area .tag.frist Is the starting position of this area .

(10)‘tag.last’
tag Represents the last position of the area

(11)‘@x,y’
Closest coordinate (x,y) The location of .

(12)+n chars
Move forward n Characters . such as ,’2.3+5 chars’ perhaps ’2.3+5c’ It means the second line , The first 8 Character position (3+5=8)

(13)-n chars
Move backward n Characters

(14)+n lines
Move forward n That's ok

(15)-n lines
Move backward n That's ok

(16)linestart
Move to beginning of line

(17)lineend
Move to end of line

(18)wordstart
Move to the first character of the word .

10.2.2 mark
mark hold ’ That's ok . Column ’ Defined as an identifier . It's equivalent to an alias .mark The name of can be any string , But it cannot contain spaces and ’.’. Concrete mark See 10.3 It's about mark Methods .

10.2.3 tags
tags Is to identify a specific area . The same area can have different tag name . With tag You can set the font 、 Color 、 Size and so on . And mark The difference lies in :mark It marks a point , and tag It identifies an area . of tag For the specific usage of..., please refer to 10.3 It's about tag Methods .


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