How to show markdown format text in tkinter?

大憨熊 提交于 2021-02-07 12:59:13

问题


In python-3.x with tkinter GUI, I developed a program with a regular simple window.

I want to show a markdown format string saved in a string called markdownText on program window:

markdownText='_italic_ or **bold**'

desired output is:

italic or bold

Is there any solution?


回答1:


I was just searching for a similar solution, and it does indeed not seem like there is a default module/class/library for the combination of Python, TkInter and markdown. However a continued search revealed the following options:

  • Python-Markdown – This a module capable of parsing markdown into the following output formats: Python-Markdown can output documents in HTML4, XHTML and HTML5.
  • TkInter displaying html – As the linked answer indicates, Tkhtml can display html "pretty well", and it has a python wrapper

In other words, if you are willing to use an intermediate step of converting into html that might be a viable route for you to display markdown strings within a tkinter GUI.



来源:https://stackoverflow.com/questions/35733300/how-to-show-markdown-format-text-in-tkinter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!