Hola! si, tienes razón Arnau.

Por ejemplo, para seleccionar un texto completo (seleccionar todo) hago lo
siguiente:

#Obtengo los iteradores del buffer
start, end = self.buffer.get_bounds()

#Se crean las marcas iniciales y se obtiene el texto del buffer
self.buffer.create_mark("Start",start,True)
self.buffer.create_mark("End",end,True)
text=self.buffer.get_text(start,end,True)
self.buffer.delete_selection(False,False)

#Se "sincronizan" las marcas anteriores con las designadas para seleccionar
texto
iter_start=self.buffer.get_iter_at_mark(self.buffer.get_mark("Start"))
iter_end=self.buffer.get_iter_at_mark(self.buffer.get_mark("End"))

#Se selecciona el texto contenido en las marcas
self.buffer.move_mark_by_name("insert",iter_start)
self.buffer.move_mark_by_name("selection_bound",iter_end)

Ahora bien, no sé cómo obtener los iteradores de texto de una selección que
se haga con el cursor. Supongamos que tengo el texto: "Hola mundo", y con el
cursor selecciono "Hola" para cambiar su tipografía, por ejemplo. No sé cómo
obtener "Hola" para realizar las operaciones que quiera...

Gracias de antemano por sus sugerencias :)
_______________________________________________
Python-es mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a