Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.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/cmake/2.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_Tkinter - Fatal编程技术网

Python Tkinter文本小部件搜索方法

Python Tkinter文本小部件搜索方法,python,tkinter,Python,Tkinter,在哪里可以找到此方法的文档 我只找到了这个 搜索方法允许您搜索文本。您可以搜索精确匹配(默认),或者使用Tcl样式的正则表达式(在regexp选项设置为true的情况下调用) “Tcl风格的正则表达式”是什么意思 我还有一个关于我的代码的问题:为什么self.\u testo.tag\u add(“search”,pos,“%s+%sc”(pos,countVar.get())返回TypeError:“str”对象不可调用 提前谢谢 def _trova(self): t1 = tkin

在哪里可以找到此方法的文档

我只找到了这个 搜索方法允许您搜索文本。您可以搜索精确匹配(默认),或者使用Tcl样式的正则表达式(在regexp选项设置为true的情况下调用)

“Tcl风格的正则表达式”是什么意思

我还有一个关于我的代码的问题:为什么
self.\u testo.tag\u add(“search”,pos,“%s+%sc”(pos,countVar.get())
返回
TypeError:“str”对象不可调用
提前谢谢

def _trova(self):
    t1 = tkinter.Toplevel(self._finestra)
    def t():
        s = e.get()

        start = "1.0"
        while True:
            countVar = tkinter.StringVar()
            pos = self._testo.search(s, start, stopindex="end",count=countVar)
            if not pos:
                break
            self._testo.tag_config("search", background="yellow")
            self._testo.tag_add("search", pos, "%s + %sc" (pos, countVar.get()))
            start = pos + "+1c"

    e= tkinter.Entry(t1).grid(row=0, column=1)
    ok = tkinter.Button(t1, text="OK", command= t).grid(row=0, column=2)
在哪里可以找到此方法的文档

规范文档在这里的tcl/tk文档中:它假设您是用tcl而不是python编写的,但是将其转换为python相当简单。python文档很好地介绍了如何做到这一点。看

“Tcl风格的正则表达式”是什么意思

Tkinter是tcl解释器的薄包装。Tcl的正则表达式语法与Python的有细微的不同。所谓“tcl风格的正则表达式”,意味着它遵循tcl项目手册页中描述的正则表达式语法

我还有一个关于我的代码的问题:为什么是self._testo.tag_add(“search”,pos,“%s+%sc”(pos,countVar.get())返回TypeError:“str”对象不可调用

之所以会出现错误,是因为您试图将字符串当作函数来调用(实际上,您正在执行
“foo”(

"%s + %sc" (pos, countVar.get())
您似乎遗漏了
%s+%sc
之间的
%
(pos,countVar.get())

在哪里可以找到此方法的文档

规范文档在这里的tcl/tk文档中:它假定您是用tcl而不是python编写的,但是将其转换为python相当简单。python文档对如何实现这一点进行了很好的介绍。请参阅

“Tcl风格的正则表达式”是什么意思

Tkinter是tcl解释器的薄包装。tcl的正则表达式语法与Python的有细微的不同。通过“tcl风格的正则表达式”,这意味着它遵循tcl项目手册页中描述的正则表达式语法

我还有一个关于我的代码的问题:为什么是self._testo.tag_add(“search”,pos,“%s+%sc”(pos,countVar.get())返回TypeError:“str”对象不可调用

之所以会出现错误,是因为您试图将字符串当作函数来调用(实际上,您正在执行
“foo”(

"%s + %sc" (pos, countVar.get())
您似乎遗漏了
%s+%sc
之间的
%
(pos,countVar.get())