在 Linux 中使用 Python 创建 GUI

发布于 2024-08-03 23:22:33 字数 264 浏览 6 评论 0原文

快问。

我正在使用 Linux,我想尝试用 Python 制作 GUI。我听说过 Qt、GTK+ 和 PyGTK 之类的东西,但我不知道它们到底是什么以及它们之间的区别是什么。

它们与 GNOME、KDE、XFCE 等不同 DE 的工作方式有什么区别吗?是否有任何 IDE 允许您像 Microsoft Visual Studio 一样创建 GUI(适用于 C#、C、Visual Basic 等)?

或者我应该使用Python以外的另一种语言来制作GUI应用程序?

Quick question.

I'm using Linux and I want to try making a GUI with Python. I've heard about something like Qt, GTK+ and PyGTK but I don't know what they are exactly and what the difference between them is.

Is there any difference on how they work with different DEs like GNOME, KDE, XFCE etc.? Is there any IDE that allows you to create GUI like Microsoft Visual Studio does (for C#, C, Visual Basic etc.)?

Or should I maybe use another language other than Python to make GUI applications?

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

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

发布评论

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

评论(5

浪推晚风 2024-08-10 23:22:33

您的第一步应该是 http://wiki.python.org/moin/GuiProgramming

一些工具- 套件在一种环境中比在另一种环境中集成得更好。例如 PyQt、PyKDE(以及全新的 PySide)在 KDE 环境中运行得更好,而 GTK版本(包括 WX 小部件)将更好地融入 GNOME/XFCE 桌面。

您应该看看您想要定位的环境。您可以选择基本的便携式 GUI 工具包,也可以与 Tour DE 进行更深入的集成,例如使用集成密码管理器和配置文件解析器,它们集成在 KDE 或 GNOME 等特定 DE 中。

您还应该考虑您的选择所指示的依赖性,以及基本 DE 的默认情况。例如,KDE 3.X 分支中的 PyKDE 具有一组重要的依赖项,而在 4.X 分支中,plasma 绑定使 Python GUI 编程依赖项不再成为问题。

有多种 IDE 工具,其完整性和成熟度水平各不相同。最好的办法是多尝试一种矿石,看看哪种最适合您的需求。

Your first step should be http://wiki.python.org/moin/GuiProgramming

Some tool-kits integrate better in one environment over the other. For example PyQt, PyKDE (and the brand new PySide) will play nicer in a KDE environment, while the GTK versions (including the WX-widgets) will blend better into a GNOME/XFCE desktops.

You should look at the environment you want to target. You can go for basic portable GUI kit, or you can to a deeper integration with tour DE, like use of integrated password manager, and configuration file parsers, that are integrated in a specific DE like KDE or GNOME.

You should also consider the dependency that your selection dictates, and what is come by default with a basic DE. For example, PyKDE in the KDE 3.X branch had a non trivial set of dependencies, while at the 4.X branch the plasma binding made the Python GUI programming dependency less of an issue.

There are several IDE tools, in different levels of completeness and maturity. The best thing is to try one ore more, and see what best fit your needs.

七七 2024-08-10 23:22:33

我会避免使用另一种语言来为 Python 制作 GUI。

我很幸运地使用了 wxwidgets,它是 WX(一个跨平台开发系统)的 python 绑定。它非常容易学习并且非常强大。 wxwidgets 的问题是它不是默认安装的,因此您的用户需要在他们希望运行您的应用程序的每个平台上安装它。有关详细信息,请访问 http://wxwidgets.org/

如果您希望人们能够在不安装任何其他东西的情况下使用您的程序,请使用 Tkinter,Python 附带的 GUI 系统。

我会避免 GTK 或 KDE 的 Python 绑定,除非您已经了解这些系统。它们也需要下载,而且它们的采用率似乎没有 wxwidgets 那么多。

I would avoid using another language to make a GUI for Python.

I've had every good luck with wxwidgets, which is the python binding for WX, a cross-platform development system. It's pretty easy to learn and quite powerful. The problem with wxwidgets is that it is not installed by default, so your users will need to install it on every platform that they wish to run your application. Find more information about it at http://wxwidgets.org/.

If you want people to be able to use your program without installing anything else, use Tkinter, the GUI system that comes with Python.

I would avoid the Python bindings for GTK or KDE unless you already know those systems. They also need to be downloaded, and they do not seem to have as much adoption as wxwidgets.

枯叶蝶 2024-08-10 23:22:33

每个桌面环境都使用特定的工具包来构建其组件。例如,KDE 使用 Qt,GNOME 使用 Gtk。

您对工具包的使用取决于您所针对的桌面环境类型,如果您想要针对广泛的桌面,那么请使用适用于许多桌面环境的工具包,例如适用于多种桌面环境的 Wx 小部件Linux、Mac 操作系统和 Windows。对于构建简单的 GUI 应用程序,Tkinter 就可以了。

Each desktop environment uses a specific toolkit to build it's components. For example, KDE uses Qt and GNOME uses Gtk.

Your use of a toolkit will be dependent upon what type of desktop environment you're targeting at, and if you want to target a wide range of desktops then use a toolkit which will work on many desktop environments, like Wx widgets which will work on Linux, Mac OS and Windows. For building simple GUI applications, Tkinter will do.

楠木可依 2024-08-10 23:22:33

使用glade UI设计器和pyGtk绑定...这是我第一次使用Python,并且有< a href="http://www.google.com/search?q=python+glade+pygtk&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US: unofficial&client=firefox-a" rel="nofollow noreferrer">大量博客文章和教程可帮助您入门

Use the glade UI designer and pyGtk bindings... that was my first ever experience with python and there are lots of blog posts and tutorials to help you get started

丑疤怪 2024-08-10 23:22:33

使用 PyGTK。与工具包一样重要的是它的基础,在 PyGTK 中,您还可以使用 GLib,其文件系统抽象(python 模块 gio)对于 Linux 桌面非常重要,其高级跨桌面功能如 glib.get_user_data_dir() 及其其他应用程序框架工具,以及 GObject 及其属性和信号模型。

Use PyGTK. As important as the toolkit is its underpinnings, with PyGTK you use GLib as well, with its filesystem abstractions (python module gio) that are very important for the Linux desktop, its high-level cross-desktop functions such as glib.get_user_data_dir() and its other application framework tools, and GObject and its property and signals model.

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