我想知道如何一次在一个Text
小部件中获取所有标签。所以说这是我的内容:
("keyword", print) ("string", "Hello world!")
("keyword", print) ("string", "You are"), ("support", raw_input())
self.text.tag_config('keyword', foreground="orange")
self.text.tag_config('operator', foreground="blue")
self.text.tag_config('number', foreground="red")
self.text.tag_config('string', foreground="red")
self.text.tag_config('support', foreground="blue")
self.text.tag_config('comment', foreground="violet")
self.text.tag_config('error', background="red")
self.text.tag_config('warning', background="yellow")
现在,是否有任何函数/常量仅获取字符串中当前的标记?它会报告['keyword', 'string', 'support']
。
(注意:大多数我只是想知道这个是因为我很好奇。如果没有,这并不是世界末日。:P)
注意:第二个代码块是用Python编写的,我希望用Python给出答案。:)
.tag_names(index = None)
如果传递索引参数,则此方法将返回与该索引之后的字符关联的所有标签名称的序列。如果不传递任何参数,则将获得在文本小部件中定义的所有标签名称的序列。
.tag_ranges(tagName)
列出使用特定标签的索引。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句