Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
参见Python tkinter的(索引)方法_Python_User Interface_Tkinter - Fatal编程技术网

参见Python tkinter的(索引)方法

参见Python tkinter的(索引)方法,python,user-interface,tkinter,Python,User Interface,Tkinter,根据see(索引)方法“根据指定索引处的文本是否可见,它以真(或假)形式返回布尔值” 以下是代码:--- from tkinter import * root = Tk() txt = Text(root, spacing3 = 100, width = 50) txt.insert('1.0',"My name is Abhishek Bhardwaj") txt.pack() yes_no = txt.see('1.3') # Here the cheracter a

根据see(索引)方法“根据指定索引处的文本是否可见,它以真(或假)形式返回布尔值”

以下是代码:---

from tkinter import *
root = Tk()
txt = Text(root, spacing3 = 100, width = 50)
txt.insert('1.0',"My name is Abhishek Bhardwaj")
txt.pack()


yes_no = txt.see('1.3') # Here the cheracter at third index of the first line is visible but still it returns value in NONE
print(yes_no)

root.mainloop()

请帮助我了解此方法的实际工作原理

您对
参见
方法的描述是错误的。它不会返回一个布尔值来表示索引是否可见。相反,它通过滚动确保索引可见

这是
方法的关键,请参见
方法:

调整窗口中的视图,使索引给定的字符完全可见。如果索引已经可见,则该命令不执行任何操作。如果索引距离视图较短,则该命令将调整视图,使索引在窗口边缘可见。如果索引远离视图,则命令会将索引集中在窗口中

至于它是如何工作的,我不确定这有什么关系。tkinter是在tk库的实现中构建的。

请参见(索引)
使指定位置可见。您提到的功能可以改用
dlineinfo(index)