Skip to content

Instantly share code, notes, and snippets.

@perseoq
Last active September 14, 2022 14:32
Show Gist options
  • Save perseoq/c357964b5b66083b627fbb314dc7b5a2 to your computer and use it in GitHub Desktop.
Save perseoq/c357964b5b66083b627fbb314dc7b5a2 to your computer and use it in GitHub Desktop.
Insert HTML tag in a selected text / tkinter (Text Widget) / [Replace text selected with new text]
def bold(self):
selexion = self.mensaje.get(SEL_FIRST, SEL_LAST) # get original string
rpl = " <p>" + selexion + "</p> " # costruct new string
self.mensaje.insert(INSERT,rpl) # insert new string
self.mensaje.delete(SEL_FIRST,SEL_LAST) # delete old string
return
@paulokanda
Copy link

How is it possible? Just what I needed!!! Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment