是否有一个 Python 库可以让您无需编写太多代码即可构建用户界面?

发布于 2024-07-15 07:03:02 字数 210 浏览 10 评论 0原文

几年来我一直在用 Python 编写编辑前端,我厌倦了每次都对窗口或对话框的每个 UI 细节进行微观管理。

是否有一种技术可以让我指定 GTK+ Glade 设计的接口与 SQLite 数据库的表和记录之间的关系来完成所有中间人的工作? 它应该让我免去手动编写事件处理程序、输入评估器和视图更新的工作。

所讨论的技术只是示例,但我想尽可能坚持使用 Python。

I am writing editing front ends in Python since several years now, and I am fed up with micromanaging every UI detail of a window or dialog every single time.

Is there a technology that allows me to, say, specify the relations between a GTK+ Glade-designed interface and the tables and records of an SQLite database to do all the middle man work? It should spare me the work of manually writing event handlers, input evaluators and view updates.

The technologies in question are just examples, but I want to stick with Python as far as possible.

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

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

发布评论

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

评论(8

天涯沦落人 2024-07-22 07:03:02

除了已经提到的之外,我还可以添加:

我从未使用过其中任何一个,所以没有推荐,但是,无论如何,我使用了至少 2 个直接在 pygtk 上构建的复杂程序,它们可以在 Windows 和 Linux 上运行。

我认为 Kiwi 是其中唯一一个支持数据库(通过与 SQLAlchemy、SQLObject 或 Storm 的接口)的框架,但如果您不能在任何其他框架中使用这些 ORM 之一,我会感到惊讶。

Besides the ones already mentioned I can add:

I've never used any of them so have no recommendations but, for what it's worth, I have used at least 2 complex programs built directly on pygtk that worked in both Windows and Linux.

I think Kiwi is the only one of these with baked in support for db (through interface with SQLAlchemy, SQLObject, or Storm) but I would be surprised if you couldn't use one of those ORM's inside any of the other frameworks.

浊酒尽余欢 2024-07-22 07:03:02

PyQt 及其模型可以为您自动执行其中一些任务(当然,例如使用数据库中的数据填充小部件并处理大多数小部件行为、缓冲等)。

如果您想要一种更加面向对象的方法来处理 SQL,您可以考虑面向 ORM 的解决方案(例如 SQLAlchemy)。

PyQt and its models can automate some of these tasks for you (to some amount off course, e.g. filling widgets with data from a database and handling most of the widgets behaviour, buffering etc.).

If you want a more object-oriented approach to handling SQL you could look into an ORM-oriented solution (for example SQLAlchemy).

意犹 2024-07-22 07:03:02

Dabo 是建立在 wxPython 之上的,所以你可能不喜欢它,但它的设计目的是让你可以轻松地绑定一个数据库的 GUI,所以我建议您检查一下(如果您还没有这样做的话)。 特别是,它具有将小部件与数据绑定以及处理 GUI 开发的许多常见情况的良好设施。

Dabo is built on top of wxPython, so you may not prefer it, but it's designed to make it easy to tie a GUI to a database, so I'd recommend you check it out if you haven't already. In particular, it's got good facilities for tying widgets to data, and handling a lot of the common cases of GUI development.

抚你发端 2024-07-22 07:03:02

wxGlade 可能会有所帮助,尽管我自己没有使用过它,所以我不是根据经验说话的。

Boa Constructor 显然有一个 wxPython GUI 构建器,而且还有 PythonCard,尽管这两个项目的开发似乎已经停滞。

wxGlade may help, although I haven't used it myself so I don't speak from experience.

Boa Constructor apparently has a wxPython GUI builder in it, and there is also PythonCard, though development on these two projects seems to have stalled.

失去的东西太少 2024-07-22 07:03:02

特征可能是您的一个不错的选择。
http://code.enthought.com/projects/traits/ docs/html/TUIUG/index.html

尽管将 UI 映射到对象很简单,但合并 SQLAlchemy 来实现持久性似乎并不太牵强。

Traits might be a good option for you.
http://code.enthought.com/projects/traits/docs/html/TUIUG/index.html

AS simple as it is to map a UI to an object, it doesn't seem too far fetched to incorporate SQLAlchemy for persistence.

隱形的亼 2024-07-22 07:03:02

有一本关于wxPython的好书,《wxPython in Action》,对于其他一些解决方案来说是不能说的。 不许敲别人的门。 我过去曾成功地使用 wxPython 进行过开发,它附带了一组很棒的演示应用程序,其中包含源代码,您可以从中随意借用。

我为 wxPython 应用程序找到的最好的 UI 设计器是商业设计器,Anthemion DialogBlocks。 它是由一位 wxPython 程序员编写的,物有所值。 其他 UI 设计解决方案包括 wxGlade(我发现它可用但功能不丰富)和 Boa Constructor(尚未使用过)。 Wing IDE 可能也有一个。 我相信 Stani 的 Python 编辑器捆绑了 wxGlade。 还有很多其他项目并没有真正发挥作用或者相当陈旧。

就 SQL 自动化而言,正如另一位回答者所说,我会研究 SQL alchemy,但是小型应用程序的学习曲线可能太多,您最好直接使用 odbc。 最好的 odbc api 是 Django 使用的 pyodbc。

自从我使用这些工具进行开发以来已经有一段时间了,因此每个工具可能都有更新的东西,但在我看来,当时这些工具绝对是最好的。

There is a good book on wxPython, "wxPython in Action", which can't be said for some of the other solutions. No knock on the others. I've had success developing with wxPython in the past and it comes with a great set of demo applications with source code from which you can borrow liberally.

The best UI designer I found for wxPython applications is a commercial one, Anthemion DialogBlocks. It's by one of the wxPython programmers and is worth the money. Other solutions for UI design include wxGlade (I found it usable but not featureful) and Boa Constructor (haven't used it). Wing IDE might also have one. Stani's Python Editor bundles wxGlade, I believe. There are a lot of other projects that don't really work or are fairly old.

As far as SQL automation goes, as another answerer says, I'd look at SQL alchemy, but the learning curve for a small application might be too much and you'd be better off just going straight to odbc. The best odbc api is the one used by Django, pyodbc.

It's been a while since I developed with these tools, so there may be something newer for each, but at the time these were definitely the best of breed in my opinion.

相思故 2024-07-22 07:03:02

我在 wxPython 方面取得了很多成功,但那是几年前的事了,可能会有更好的新解决方案......

I had lots of success with wxPython, but that was some years ago now and there may be better new solutions...

风吹过旳痕迹 2024-07-22 07:03:02

好吧,这是一个非常规的解决方案,但你自己编写一个代码生成器。 我已经使用 Mako 这样做了好几次。 因此,就我而言,我自动检查一个表包含哪些列和类型,并从中生成类。 它需要更多的前期工作,但完全符合您的要求,并且可以在后续项目中重复使用。

Ok this is an unconventional solution but write yourself a code generator. I have done this several times using Mako. So in my case I auto inspect a table which columns it contains and types and generate classes from that. It's more work upfront but does exactly what you want and is reusable in subsequent projects.

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