使用 python 在窗口中显示格式化文本

发布于 2024-08-25 04:32:34 字数 123 浏览 3 评论 0原文

我用 wxpython 编写了一个程序,它向用户显示问题,并显示一个带有答案的单选框。问题和答案应该位于数据库中,并且是使用一些数学(括号、平方根等)格式化的文本。您能否建议我应该为这样的文本使用什么小部件以及数据库是什么? 谢谢。

I make a program in wxpython which displays questions to the user and a radiobox with answers. Questions and answers should be in a database and is formatted text using some mathematics (paranthesis, root squares etc). Could you propose me what widget I should use for such a text and what could be the database?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小镇女孩 2024-09-01 04:32:34

对于数据库,您可以使用任何基于 sql 的数据库,例如 mysql 或 sqllite,但如果您没有太多数据,为什么不将其存储在文本文件中或作为 python 模块本身。

显示数学符号部分很棘手,您需要一个可以显示 MathML(http://en.wikipedia .org/wiki/MathML),我不认为任何 wxPython 小部件可以做到这一点,某些浏览器显示 MathML,因此您可以将浏览器嵌入到 wxpython 中,但这也很棘手。

另一种选择是使用 mathplotlib 绘制数学符号,例如参见 http://matplotlib。 sourceforge.net/users/mathtext.html#mathtext-tutorial

但 IMO 最简单/最好的方法是将 mathml xml 转换为图像文件并将其显示在应用程序内的图像控件中。
例如,您可以使用 http://sourceforge.net/projects/svgmath/ 将 mathml 转换为 svg ,使用 http://librsvg.sourceforge.net/ 将 svg 转换为 png,

或者您也可以尝试 http://sourceforge.net/projects/jeuclid/

您必须进行试验,看看什么是最简单的你,但我不认为有任何简单的方法。

For database you can use any sql based DB e.g. mysql or sqllite but if you do not have much data why not just store it in text files or as python module itself.

Displaying math symbols part is tricky, you will need a control which can display MathML(http://en.wikipedia.org/wiki/MathML) , I don't think any wxPython widget can do that, some browsers display MathML, so you may embed browser inside wxpython but that is also tricky.

Another alternative is to use mathplotlib to draw math symbols e.g. see http://matplotlib.sourceforge.net/users/mathtext.html#mathtext-tutorial

but IMO simplest/best way would be to just convert mathml xml to a image file and display it in a image control inside your app.
e.g. you can use http://sourceforge.net/projects/svgmath/ to convert mathml to svg, convert svg to png using http://librsvg.sourceforge.net/

or you can also try http://sourceforge.net/projects/jeuclid/

You will have to experiment to see what is easiest for you but i don't think there is any easy way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文