简体   繁体   English

使用Python的CSS轻量级渲染器HTML

[英]Light-weight renderer HTML with CSS in Python

Sorry, perhaps I haven't described the problem well first time. 对不起,也许我没有第一次描述这个问题。 All your answers are interesting, but most of them are almost full-featured web browsers, my task is much simpler. 你的所有答案都很有趣,但大多数都是功能齐全的网页浏览器,我的任务更简单。

I'm planning to write a GUI application using one of the available on linux GUI frameworks (I haven't yet chosen one). 我打算使用Linux GUI框架之一编写一个GUI应用程序(我还没有选择一个)。 I shall use html in my application to render into one of my application frames text with some attributes — different fonts etc, which are stored in CSS. 我将在我的应用程序中使用html渲染到我的应用程序框架文本中的一些属性 - 不同的字体等,它们存储在CSS中。

The HTML shall be generated by my application, so the only task is to render a HTML / CSS string. HTML应由我的应用程序生成,因此唯一的任务是呈现HTML / CSS字符串。 Is there any widget which can do only that render and nothing more — no history, no bookmarks, no URL-loading etc? 是否有任何窗口小部件只能进行渲染,仅此而已 - 没有历史记录,没有书签,没有URL加载等? If there isn't I shall use one of those you advised — it's ok — but I'm just interested if there is just an html-renderer without any extra features. 如果没有,我会使用你建议的那个 - 这没关系 - 但我只是感兴趣,如果只有一个没有任何额外功能的html渲染器。

You should use a UI framework: 您应该使用UI框架:

An other option is to open the OS default web browser through something like this: 另一种选择是通过以下方式打开操作系统默认Web浏览器:

import webbrowser
url = 'http://www.python.org'

# Open URL in a new tab, if a browser window is already open.
webbrowser.open_new_tab(url + '/doc')

# Open URL in new window, raising the window if possible.
webbrowser.open_new(url)

You can find more info about the webbrowser module here . 您可以在此处找到有关webbrowser模块的更多信息。 I think that the simplest way would be to use the os browser if you are looking for something very light-weight since it does not depend on a framework and it would work in all platforms. 我认为最简单的方法是使用os浏览器,如果你正在寻找一些非常轻量级的东西,因为它不依赖于框架,它可以在所有平台上运行。 Using Tk may be an other option that is light and will not require to install a 3rd party framework. 使用Tk可能是一个轻量级的其他选项,不需要安装第三方框架。

Flying Saucer Project -- an XHTML renderer. Flying Saucer Project - 一个XHTML渲染器。

No, it's not Python. 不,这不是Python。 It's -- however -- trivially called from Python. 然而,它 - 从Python中简单地调用。

Maybe HulaHop could be interesting for you (can also be combined with Pyjamas ). 也许HulaHop对你很有趣(也可以与睡衣结合)。 The Mozilla Prism Project might also be relevant. Mozilla 棱镜项目也可能具有相关性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM