用于跨平台 GUI 开发的 CPython、Jython 与 IronPython

发布于 2024-09-11 15:20:01 字数 1432 浏览 3 评论 0原文

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

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

发布评论

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

评论(8

绿萝 2024-09-18 15:20:01

IronPython with Mono 是跨平台的 - 对于 Mono 支持的任何平台,以及 Mono 支持的功能集Mono(这几乎意味着 Windows 窗体得到了很好的支持)。然而,GUI 工具包还有其他选项,它们可能提供更好的“跨平台”功能,或者至少在非 Windows 平台上有更好的感觉。

CPython 将取决于您选择的 GUI 套件。就我个人而言,我发现 CPython 与 PyQt 是最有用的跨平台来自 Python 的 GUI 选项。它非常强大,功能丰富,并且运行良好。

Jython 可以工作,但我个人不太喜欢 GUI 选项(不过,这是 100% 的个人偏好)。

IronPython with Mono is cross platform - to whatever platforms supported by Mono, and for the feature set supported by Mono (which pretty much means Windows Forms is supported fairly well). Other options for GUI toolkits are available, however, which may provide better "cross platform" capabilities, or at least a better feel on non-Windows platforms.

CPython will depend on the GUI suite you choose. Personally, I've found CPython with PyQt to be the most usable, cross platform GUI option from Python. It's very powerful, feature-rich, and works quite well.

Jython will work, but I personally don't like the GUI options as much (this is a 100% personal preference, however).

不必了 2024-09-18 15:20:01

我想说,如果跨平台是一个目标,那就忘记 IronPython。很多人讨厌它造成的依赖地狱,因此在某些操作系统/发行版中运行它需要做太多的工作。 Jython 也会遭受这种情况,尽管程度较轻。

I'd say that if cross-platform is a goal, forget IronPython. A lot of people hate the dependency hell it causes so it'll be too much work to get it up in running in some OSes/distributions. Jython will suffer this also, albeit to a lesser degree.

帅的被狗咬 2024-09-18 15:20:01

嗯,Mono 并没有附带大多数 Linux 发行版的基础。它也不是一个非常轻量级的依赖项,而且我认为人们更有可能已经拥有 Java。您打算将“Winforms”与 Mono 一起使用吗?如果是这样,并且您没有使用 Winforms 的经验,请阅读其他人的意见 :-) 另一个 .NET GUI 工具包是 WPF,不幸的是 Mono 没有实施计划。

Jython 也会更好,因为您可以使用 SWT,它可以呈现本机小部件并轻松提供大量布局可能性。或者,您可以将 Jython 与 Swing 一起使用,或者其他任何东西 — 如果您喜欢丑陋的话,甚至可以使用 AWT。

我真的很喜欢 wxPython(你可以将其与 CPython 一起使用,默认情况下,大多数发行版上都有 CPython),因为它可以在 OSX、Windows 和 Linux 中呈现漂亮的本机小部件(我只亲眼见过 Gnome 小部件)。 wxPython 是迄今为止我用过的最容易使用的 GUI 工具包——甚至以编程方式(即没有 Glade 或类似的布局)。我还使用过 SWT(我觉得它相当不错)、Swing(我个人不太喜欢它的外观)和 Winforms(即使尝试使用它进行简单的布局也是一场噩梦)。

解释器/语言运行时存在情况的快速比较

  • 以下是操作系统CPython
    • Windows - 可能未安装,您必须使用非 python 安装程序将其与您的软件一起安装 :-P
    • Linux - 可能已安装(Ubuntu、Gentoo)和 RedHat 都有用 Python 编写并在 CPython 上运行的系统工具)
    • Mac - 预安装在 OSX
  • Jython
    • Windows - 可能在我的经验中的某个时刻安装过,尽管它没有随
    • Linux 一起提供 - 可能已安装,但更重要的是没有人会安装讨厌你像 Mono Mac 一样依赖它
    • - 预装在 OSX 上(“Mac OS X Leopard 预装了 J2SE 5.0,基于 JDK 1.5.0_13_b05” - Apple 网站)
  • IronPython
    • Windows - 可能会运行良好,因为我打赌大多数人都有至少 .NET 2.0,如果他们有最新版本的 Windows
    • Linux - 可能没有安装 - 我在 Linux 上使用 Mono 的唯一应用程序是 Rasterbator,它运行良好,但我觉得把 .NET 放在 Linux
    • Mac 上很奇怪- 参见上文,

我会首先选择 GUI 工具包,因为这将极大地影响用户体验和整体难度(我会选择 wxPython,但 SWT 紧随其后),然后考虑以上内容,也许将其作为决胜局。

Well, Mono does not come with the base of most Linux distributions. It's not a terribly lightweight dependency either, and I think Java is considerably more likely for people to already have. Would you plan on using "Winforms" with Mono? If so, and you don't have experience with Winforms, read about what others have to say :-) The other .NET GUI toolkit is WPF, which unfortunately Mono has no plans to implement.

Jython would be better too, because you can use SWT, which renders native widgets and provides lots of layout possibilities easily. Or you can use Jython with Swing, or whatever else -- even AWT if you love ugliness.

I really like wxPython (which you can use with CPython, which is on most distros by default), because it renders good-looking native widgets in OSX, Windows and Linux (I've only seen the Gnome widgets in person). wxPython is by far the easiest to use GUI toolkit I've used -- even programatically (i.e. layout without Glade or similar). I've also used SWT, which I found quite nice, and Swing, which I personally don't really like the looks of, and Winforms, which was a nightmare to try to do even simple layouts with.

Here's a quick comparison of the existence of the interpreter/language runtime by OS

  • CPython
    • Windows - Probably not installed, and you'd have to make a non-python installer install it with your software :-P
    • Linux - Probably installed (Ubuntu, Gentoo and RedHat all have system tools that are written in Python and run on CPython)
    • Mac - Preinstalled on OSX
  • Jython
    • Windows - Probably installed at some point in my experience, though it doesn't come with
    • Linux - Probably installed, but more importantly nobody would hate you for depending on it like Mono
    • Mac - Preinstalled on OSX ("Mac OS X Leopard comes with J2SE 5.0 preinstalled, based on JDK 1.5.0_13_b05" -- Apple's site)
  • IronPython
    • Windows - Will probably run fine because I bet most people have at the very least .NET 2.0 if they have a recent version of Windows
    • Linux - Probably not installed -- the only application with which I've used Mono on Linux was Rasterbator, which worked well but I felt weird putting .NET on Linux
    • Mac - See above

I would choose a GUI toolkit first, since that will very much impact the user experience and overall difficulty (I would choose wxPython but SWT would be a close second) then consider the above as well maybe as a tiebreaker.

如果没结果 2024-09-18 15:20:01

大约一年前,我遇到了同样的问题。在考虑了所有替代方案之后,我最终选择了 CPython 和 PyQt。在我看来,Qt/PyQt 是迄今为止所有 Python GUI 工具包中的最佳选择。在遇到 wxPython 的许多错误后,我转向 PyQt 并且再也没有回头。根据我的经验,Qt/PyQt 比 wx 工具包更可靠。

我使用完全相同的代码库,并使用适用于 Windows 的 PyInstallerPy2App 适用于 Mac(PyInstaller 也可用于 Linux)。由于这些构建器嵌入了 Python 解释器和所有依赖项,因此消除了很多麻烦。唯一的问题是您需要 Windows 和 Mac 来进行构建。让所有配置正确也可能很痛苦,但这是可能的,而且值得投入时间。

I faced this same question roughly a year ago. After looking at all the alternatives, I ended up with CPython and PyQt. IMO, Qt/PyQt is by far the best choice amongst all of the Python GUI toolkits. After hitting many bugs in wxPython I switched to PyQt and never looked back. Qt/PyQt are much more solid than the wx toolkits in my experience.

I use the exact same code base and build stand alone executables with PyInstaller for Windows and Py2App for the Mac (PyInstaller can be used for Linux as well). Because these builders embed the Python interpreter and all of the dependencies, it takes a lot of the hassle away. The only rub is that you'll need both a Windows and Mac to do the builds. Getting all of the configurations correct can be a pain too, but it's possible and time worth investing.

蓝色星空 2024-09-18 15:20:01

看一下用 python/jython/ironpython 编写的类似 GUI。寻找您喜欢的程序并了解它们的用途。我想大多数(如果不是全部)都会用 cpython + gtk 或 cpython + qt 编写。我认为python中的所有gui工具包都是跨平台的。

Take a look at comparable GUI's written in python/jython/ironpython. Look for programs that you like and find out what they use. I guess most if not all will be written in cpython + gtk or cpython + qt. I think all gui toolkits in python are cross platform.

微凉 2024-09-18 15:20:01

Java最可移植的平台。 Jython 是用 100% 纯 Java 编写的。 ”纳夫说道。

顺便说一句,我刚刚将 CPython/GTK 项目切换到 Jython (试图删除尽可能多的非托管代码),唯一的问题是 Jython 仍然是 2.5,当你习惯了 2.6/2.7/3 时,这有点糟糕: )

Java is the most portable platform. Jython is written in 100% pure Java. 'Nuff said.

BTW I just switched a CPython/GTK project to Jython (trying to remove as much unmanaged code as possible), the only problem is that Jython is at 2.5 still, which kind of sucks when you're used to 2.6/2.7/3 :)

最舍不得你 2024-09-18 15:20:01

已经有很多答案了,但我想补充一件重要的事情 - 无论您学习哪个库,当您转移到另一个库时,大多数原理都是相同的。

我不了解 Qt,但对于大多数图形程序(在 PyGTK 或 Tkinter 中)来说,就编辑而言,最好的办法是使用 PIL 图像(或类似的东西)进行绘制,然后绘制该图像在您的画布小部件上,否则如果您的窗口被覆盖,您可能会丢失像素数据。

There are plenty of answers already, but I'd like to add one important thing - regardless of which library you learn, most of the principles will be the same when you move to another library.

I don't know about Qt, but for most graphics programs (in PyGTK or Tkinter) the best thing to do, as far as editing goes, is to use a PIL image (or something similar) to draw on and then draw that image on your canvas widget, otherwise you can lose pixel data if your window gets covered.

我们只是彼此的过ke 2024-09-18 15:20:01

您可以将 Python 2.7 或 3.1 (CPython) 与 ttk 一起使用(在 2.7 的标准库中) ,3.1),ttk 支持主题(看起来不错且非常简单的编码)

(第一个屏幕是带有选项卡和语法突出显示的文本编辑器) ttk 屏幕截图

You may use Python 2.7 or 3.1 (CPython) with ttk (in Standart Library in 2.7, 3.1), ttk support themes (looks nice and very simple coding)

(1-st screen is text-editor with tabs and syntax highlighting) ttk screenshots

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