4
我有一個gtk.Textview
。我想以編程方式查找並選擇TextView
中的一些文本。 我有這個代碼,但它不能正常工作。在gtk.TextView中查找文本
search_str = self.text_to_find.get_text()
start_iter = textbuffer.get_start_iter()
match_start = textbuffer.get_start_iter()
match_end = textbuffer.get_end_iter()
found = start_iter.forward_search(search_str,0, None)
if found:
textbuffer.select_range(match_start,match_end)
如果找到了文本,那麼它選擇在TextView
的所有文字,但我需要它來選擇只找到的文本。
謝謝你的答覆,你真的幫了我! – 0xAX 2010-03-03 10:57:12