简体   繁体   中英

Python + QT, Windows Forms or Swing for a cross-platform application?

I'd like to develop a small/medium-size cross-platform application (including GUI).

My background: mostly web applications with MVC architectures, both Python (Pylons + SqlAlchemy) and Java (know the language well, but don't like it that much). I also know some C#. So far, I have no GUI programming experience (neither Windows Forms, Swing nor QT).

I plan to use SQLite for data storage: It seems to be a nice cross-platform solution and has some powerful features (eg full text search, which SQL Server Compact lacks).

I have done some research and these are my favorite options:

1) QT, Python (PyQT or PySide), and SQLAlchemy

pros:

  • Python the language
  • open source is strong in the Python world (lots of libraries and users)
  • SQLAlchemy: A fantastic way to interact with a DB and incredibly well documented!

cons:

  • compilation, distribution and deployment more difficult?
  • no QT experience
  • QT Designer not as nice as the Visual Studio Winforms designer

2) .NET/Mono, Windows Forms, C#, (Fluent) NHibernate, System.Data.SQLite

pros:

  • C# (I like it, especially compared to Java and would like to get more experience in it)
  • The Winforms GUI designer in Visual Studio seems really slick
  • IntelliSense
  • ClickOnce Deployment(?)
  • Windows Forms look and feel good on Windows

cons:

  • (Fluent) NHibernate far less documented than SQLAlchemy; also annoying: Fluent docs refer to NHibernate docs which refer to Hibernate (aargh!). But plain NHibernate + XML does not look very comfortable.
  • Windows Forms will not look + behave native on Linux/Mac OS (correct?)
  • fewer open source libraries in the .NET world, fewer OSS users, less documentation in general
  • no WinForms and NHibernate experience

3) JVM, Java + Jython, Swing, SQLAlchemy
(I'm emotionally biased against this one, but listed for completeness sake)

pros:

  • JVM/Swing work well as cross-platform basis
  • Jython
  • SQLAlchemy
  • lots of open source libraries

cons:

  • Swing seems ugly and difficult to layout
  • lacks a good GUI designer
  • Guessing that I won't be able to avoid Java for UI stuff
  • Not sure how stable the Jython/Java integration is

(Options that I have ruled out... just to avoid discussion on these):
- wxWidgets/wxPython (now that QT is LGPLed)
- GTK/PyGTK

The look and feel of the final application is very important to me. The above technology stacks are very different (PyQT, .NET WinForms, JVM Swing) and require some time to get proficient, so:

Which alternative would you recommend and why?

I'm a Python guy and use PyQt myself, and I can wholly recommend it. Concerning your cons:

compilation, distribution and deployment more difficult?

No, not really. For many projects, a full setup.py for eg cx_Freeze can be less than 30 lines that rarely need to change (most import dependencies are detected automatically, only need to specify the few modules that are not recognized), and then python setup.py will build a standalone executable. Then you can distribute it just like eg a C++ .exe.

no QT experience

I didn't have notable GUI experience either when I started out with Qt (only a bit of fiddling with Tkinter), but I grew to love Qt. Most of the time, all widgets work seamlessly and do what they're supposed to do - and there's a lot of them for many purposes. You name it, there's probably a widget that does it, and doesn't annoy the user by being half-assed. All the nice things we've been spoiled with are there.

Qt is huge, but the PyQt documentation answer most question with reasonable search effort. And if all else fails and you know a bit of C++, you can also look at Qt resources.

QT Designer not as nice as the Visual Studio Winforms designer

I don't know the VS Winforms designer, but I must admit that the Qt Designer is lacking. I ended up making a sketch of the UI in the designer, generating the code, cleaning that up and taking care all remaining details by hand. It works out okay so far, but my projects are rather small.


PS:

(now that QT is LGPLed)

PyQt is still GPL only. PySide is LGPL, yes, but it's not that mature, if that's a concern. The project website states that "starting development on PySide should be pretty safe now" though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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