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

时间:2022-10-31 12:27:55

I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose.

我想为数字硬件设计做一些实验性的IDE。所以我不能选择女巫平台。

I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows.

我将有带有语法高亮显示的文本编辑器,一些矢量图形和许多选项卡式窗口。

My goals: 1. to make GUI using as less custom components as possible. 2. to make it as cross-platform as possible

我的目标:1。使GUI尽可能少地使用自定义组件。2。使它尽可能地跨平台

(I know already that CPython and Jython are cross-platform-friendly, but what about IronPython+Mono?)

(我已经知道CPython和Jython是跨平台友好的,但是IronPython+Mono怎么样呢?)

So - the question is about GUI - what should I choose?

那么——问题是关于GUI的——我应该选择什么呢?

8 个解决方案

#1


9  

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.

Mono的IronPython与Mono支持的任何平台,以及Mono支持的特性集(这意味着Windows窗体的支持相当不错)。不过,GUI工具包的其他选项可以提供更好的“跨平台”功能,或者至少在非windows平台上有更好的感觉。

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.

CPython将取决于您选择的GUI套件。我个人认为,使用PyQt的CPython是Python中最可用的、跨平台的GUI选项。它非常强大,功能丰富,并且运行良好。

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

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

#2


5  

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.

我想说,如果跨平台是一个目标,那么忘掉IronPython吧。很多人讨厌它所带来的依赖关系,因此在某些os /发行版中运行它将会花费太多的工作。Jython也将遭受这种影响,尽管程度较轻。

#3


5  

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.

Mono并不是大多数Linux发行版的基础。它也不是一个非常轻量级的依赖项,我认为Java更有可能是人们已经拥有的。你打算在Mono上使用“Winforms”吗?如果是的话,而且您没有Winforms的经验,请阅读其他人不得不说的内容:-)另一个。net GUI工具包是WPF,不幸的是Mono没有实现它的计划。

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.

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

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.

我非常喜欢wxPython(在默认情况下,您可以使用CPython来使用它),因为它在OSX、Windows和Linux中呈现了漂亮的本地小部件(我只看到了person中的Gnome小部件)。到目前为止,wxPython是我所使用过的最容易使用的GUI工具包——甚至是程序化的(例如,没有网格或类似的布局)。我还使用了SWT,我觉得它很好,而且Swing,我个人并不喜欢它的外观,和Winforms,这是一场噩梦,试图做简单的布局。

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

下面是OS对解释器/语言运行时的快速比较

  • CPython
  • CPython的
    • Windows - Probably not installed, and you'd have to make a non-python installer install it with your software :-P
    • Windows -可能没有安装,你必须让一个非python的安装程序安装它与你的软件:- p
    • Linux - Probably installed (Ubuntu, Gentoo and RedHat all have system tools that are written in Python and run on CPython)
    • Linux -可能已经安装(Ubuntu、Gentoo和RedHat都有用Python编写并在CPython上运行的系统工具)
    • Mac - Preinstalled on OSX
    • Mac -预装在OSX上。
  • Jython
  • Jython
    • Windows - Probably installed at some point in my experience, though it doesn't come with
    • Windows——根据我的经验,可能是在某个时候安装的,尽管它没有附带
    • Linux - Probably installed, but more importantly nobody would hate you for depending on it like Mono
    • Linux——可能安装了,但更重要的是,没有人会因为依赖它而恨你。
    • 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)
    • Mac -预装在OSX上(“Mac OSX Leopard附带J2SE 5.0预装,基于JDK 1.5.0 _13_ b05”——苹果网站)
  • IronPython
  • 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
    • Windows -可能运行良好,因为我打赌大多数人至少有。net 2.0,如果他们有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
    • Linux——可能没有安装——我在Linux上使用Mono的唯一应用是Rasterbator,它工作得很好,但是我觉得在Linux上使用。net很奇怪
    • Mac - See above
    • Mac -见上图

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.

我将首先选择GUI工具包,因为这将很大程度上影响用户体验和总体难度(我将选择wxPython,但SWT将是紧随其后的),然后考虑上面的内容,并将其作为一个决定性因素。

#4


3  

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.

大约一年前我也遇到过同样的问题。在研究了所有的替代方案之后,我最终得到了CPython和PyQt。在所有Python GUI工具包中,Qt/PyQt是目前最好的选择。在wxPython中遇到许多bug之后,我切换到PyQt,再也不回头看了。在我的经验中,Qt/PyQt要比wx工具包坚固得多。

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.

我使用了完全相同的代码库,构建了独立的可执行程序,其中PyInstaller用于Windows, Py2App用于Mac (PyInstaller也可以用于Linux)。因为这些构建器嵌入了Python解释器和所有的依赖项,所以省去了很多麻烦。唯一的困难是你需要一个Windows和Mac来完成构建。让所有的配置都正确也是一件痛苦的事情,但这是可能的,也是值得投资的时间。

#5


2  

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.

看看用python/jython/ironpython编写的类似GUI。找一些你喜欢的程序,看看他们用什么。我想大部分(如果不是全部的话)都是用cpython + gtk或cpython + qt编写的。我认为python中的所有gui工具包都是跨平台的。

#6


2  

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

Java是最可移植的平台。Jython是用100%纯Java编写的。足够地说。

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 :)

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

#7


1  

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.

我不知道Qt,但对于大多数图形程序(PyGTK或Tkinter)最好的办法,至于编辑,是使用一个公益诉讼图像(或类似的东西),然后画上画图片在你的画布部件,否则你会失去像素数据如果你的窗口覆盖。

#8


1  

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)

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

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

(1-st屏幕是带有标签和语法突出显示的文本编辑器)ttk屏幕截图

#1


9  

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.

Mono的IronPython与Mono支持的任何平台,以及Mono支持的特性集(这意味着Windows窗体的支持相当不错)。不过,GUI工具包的其他选项可以提供更好的“跨平台”功能,或者至少在非windows平台上有更好的感觉。

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.

CPython将取决于您选择的GUI套件。我个人认为,使用PyQt的CPython是Python中最可用的、跨平台的GUI选项。它非常强大,功能丰富,并且运行良好。

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

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

#2


5  

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.

我想说,如果跨平台是一个目标,那么忘掉IronPython吧。很多人讨厌它所带来的依赖关系,因此在某些os /发行版中运行它将会花费太多的工作。Jython也将遭受这种影响,尽管程度较轻。

#3


5  

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.

Mono并不是大多数Linux发行版的基础。它也不是一个非常轻量级的依赖项,我认为Java更有可能是人们已经拥有的。你打算在Mono上使用“Winforms”吗?如果是的话,而且您没有Winforms的经验,请阅读其他人不得不说的内容:-)另一个。net GUI工具包是WPF,不幸的是Mono没有实现它的计划。

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.

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

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.

我非常喜欢wxPython(在默认情况下,您可以使用CPython来使用它),因为它在OSX、Windows和Linux中呈现了漂亮的本地小部件(我只看到了person中的Gnome小部件)。到目前为止,wxPython是我所使用过的最容易使用的GUI工具包——甚至是程序化的(例如,没有网格或类似的布局)。我还使用了SWT,我觉得它很好,而且Swing,我个人并不喜欢它的外观,和Winforms,这是一场噩梦,试图做简单的布局。

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

下面是OS对解释器/语言运行时的快速比较

  • CPython
  • CPython的
    • Windows - Probably not installed, and you'd have to make a non-python installer install it with your software :-P
    • Windows -可能没有安装,你必须让一个非python的安装程序安装它与你的软件:- p
    • Linux - Probably installed (Ubuntu, Gentoo and RedHat all have system tools that are written in Python and run on CPython)
    • Linux -可能已经安装(Ubuntu、Gentoo和RedHat都有用Python编写并在CPython上运行的系统工具)
    • Mac - Preinstalled on OSX
    • Mac -预装在OSX上。
  • Jython
  • Jython
    • Windows - Probably installed at some point in my experience, though it doesn't come with
    • Windows——根据我的经验,可能是在某个时候安装的,尽管它没有附带
    • Linux - Probably installed, but more importantly nobody would hate you for depending on it like Mono
    • Linux——可能安装了,但更重要的是,没有人会因为依赖它而恨你。
    • 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)
    • Mac -预装在OSX上(“Mac OSX Leopard附带J2SE 5.0预装,基于JDK 1.5.0 _13_ b05”——苹果网站)
  • IronPython
  • 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
    • Windows -可能运行良好,因为我打赌大多数人至少有。net 2.0,如果他们有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
    • Linux——可能没有安装——我在Linux上使用Mono的唯一应用是Rasterbator,它工作得很好,但是我觉得在Linux上使用。net很奇怪
    • Mac - See above
    • Mac -见上图

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.

我将首先选择GUI工具包,因为这将很大程度上影响用户体验和总体难度(我将选择wxPython,但SWT将是紧随其后的),然后考虑上面的内容,并将其作为一个决定性因素。

#4


3  

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.

大约一年前我也遇到过同样的问题。在研究了所有的替代方案之后,我最终得到了CPython和PyQt。在所有Python GUI工具包中,Qt/PyQt是目前最好的选择。在wxPython中遇到许多bug之后,我切换到PyQt,再也不回头看了。在我的经验中,Qt/PyQt要比wx工具包坚固得多。

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.

我使用了完全相同的代码库,构建了独立的可执行程序,其中PyInstaller用于Windows, Py2App用于Mac (PyInstaller也可以用于Linux)。因为这些构建器嵌入了Python解释器和所有的依赖项,所以省去了很多麻烦。唯一的困难是你需要一个Windows和Mac来完成构建。让所有的配置都正确也是一件痛苦的事情,但这是可能的,也是值得投资的时间。

#5


2  

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.

看看用python/jython/ironpython编写的类似GUI。找一些你喜欢的程序,看看他们用什么。我想大部分(如果不是全部的话)都是用cpython + gtk或cpython + qt编写的。我认为python中的所有gui工具包都是跨平台的。

#6


2  

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

Java是最可移植的平台。Jython是用100%纯Java编写的。足够地说。

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 :)

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

#7


1  

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.

我不知道Qt,但对于大多数图形程序(PyGTK或Tkinter)最好的办法,至于编辑,是使用一个公益诉讼图像(或类似的东西),然后画上画图片在你的画布部件,否则你会失去像素数据如果你的窗口覆盖。

#8


1  

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)

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

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

(1-st屏幕是带有标签和语法突出显示的文本编辑器)ttk屏幕截图