Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/11/2009, 13:50
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 2 meses
Puntos: 1360
Respuesta: Editor HTML con Tkinter

bueno el metodo get de la clase Text solo te regresa un string, para obtener las propiedades puedes usar lo siguiente:
Código python:
Ver original
  1. from Tkinter import *
  2. win=Tk()
  3. def fuenteroja():
  4.     c.tag_config ("a",foreground="red")
  5.     c.insert(INSERT,(c.get(SEL_FIRST,SEL_LAST)),"a")
  6.     c.delete(SEL_FIRST,SEL_LAST)
  7.  
  8. def geHTML():
  9.     print c.get(0.0,END)
  10.     if "a" in c.tag_names():
  11.         print c.tag_cget("a", "foreground")
  12. a=Button(win,text="Cambiar la fuente a color rojo",command=fuenteroja)
  13. b=Button(win,text="Generar el codigo HTML",command=geHTML)
  14. c=Text()
  15. a.pack()
  16. b.pack()
  17. c.pack()
  18. win.mainloop()