PDA

View Full Version : Questions for Python gurus!




itsmrjon
May 4, 2012, 09:04 PM
So for those of you very familiar with GUI's in Python, I'd like to ask a few questions about a starting point. I'm attempting to write a rather simple GUI for an F95 CFD code I have. All it really needs is a few checkboxes and some simple prompts which will then either be written to a text file (the bump file as we call it) or I may attempt to use F2PY. Nonetheless, here are the questions:

1) Since the program will be run on both Linux (Redhat) and OSx machines, which GUI framework would you recommend? Ease of use and minimal dependencies are my goal (these codes are run on supercomputers, so I may not have appropriate permissions to install additional software)

2) What are some good reference materials (more than just the tutorials on the host site)? Preferable in depth tutorials as I have very little experience with Python.

3) Does anyone have experience with F2PY? Is it a good option?

4) Anything additional you'd like to throw in? Warnings, recommendations, flaming etc?

Thanks in advance!



ytk
May 5, 2012, 06:27 AM
I can't answer the rest of your questions (I'm more of a Ruby type) but as for question 1, have you considered using curses? Your interface will be... functional, at best, but it's the only GUI framework I know of that you can pretty much be assured will run—and look the same—damn near anywhere. As an added bonus, you can run it over an ssh connection with very little hassle, which might prove useful if you're running it on a supercomputer.

subsonix
May 5, 2012, 08:11 AM
I'm far from a Python guru, but you should check out Tkinter it's installed and ready to go on OS X. http://wiki.python.org/moin/TkInter

blueillusion
May 5, 2012, 08:56 AM
I use PySide : http://www.pyside.org/

It's an officially supported gui toolkit that hooks into the Qt C++ framework.
The documentation section gives you a thorough set of examples to play with, and has an endless amount of written documentation.

Pros:
-Officially supported
-Cross platform
-Look and feel (almost) identical to your running host
-Virtually can take existing Qt C++ code, rewrite it in python syntax, and it will work

Cons:
-Potential steep learning curve (especially if you dont know what Qt is already)
-Can be a pain to get pyside packages on older distro builds (eg Ubuntu lucid 10.04 lts)
-The Modal/View widgets are really over-engineered, so it's not to easy to deal with custom TableViews and grid views.

I use Qt, Python and Obj-C on a daily basis, so transitioning to PySide from Qt C++ literally only took about an hour.

I know you said you are new to python, but im not sure if you already have used some gui toolkits already. If you have, you should be able to use PySide fairly quickly. If not, then you will have a steep learning curve no matter which toolkit you choose.

EDIT:
Just noticed that you said you might not be able to install extra packages on your deployment targets.
If that's the case, then TKinter is probably the safest choice as it is included with python already

lee1210
May 5, 2012, 09:51 AM
This isn't answering the question directly, but I thought I'd toss this out there. I'd be inclined to drive the configuration of your fortran program using text files. If people want to write scripts themselves, it's easy. If someone wants to make tweaks, no problem. You want to write a GUI? Do it with whatever tool you want, generate the text file, done. You could invoke the fortran program with the file you generate if you'd like to "integrate" the process.

This lets you use any GUI tool, the GUI could be run elsewhere and the file could be copied to your big machine for use, you can copy config files between dev/test/production easily, if there's a problem you can have the user send you the file they ran with, etc.

I don't think tightly integrating a GUI config with an otherwise "headless" app on a supercomputer makes a lot of sense.

-Lee

itsmrjon
May 5, 2012, 03:04 PM
I can't answer the rest of your questions (I'm more of a Ruby type) but as for question 1, have you considered using curses? Your interface will be... functional, at best, but it's the only GUI framework I know of that you can pretty much be assured will run—and look the same—damn near anywhere. As an added bonus, you can run it over an ssh connection with very little hassle, which might prove useful if you're running it on a supercomputer.

Honestly I never even considered it, but this is a great and potentially genius option! It would prevent us from having to run an xsession on the host machine. I'm going to look into this more.

This isn't answering the question directly, but I thought I'd toss this out there. I'd be inclined to drive the configuration of your fortran program using text files. If people want to write scripts themselves, it's easy. If someone wants to make tweaks, no problem. You want to write a GUI? Do it with whatever tool you want, generate the text file, done. You could invoke the fortran program with the file you generate if you'd like to "integrate" the process.

This lets you use any GUI tool, the GUI could be run elsewhere and the file could be copied to your big machine for use, you can copy config files between dev/test/production easily, if there's a problem you can have the user send you the file they ran with, etc.

I don't think tightly integrating a GUI config with an otherwise "headless" app on a supercomputer makes a lot of sense.

-Lee

This is currently the way we do it for the most part. We hand write our bump files which are read by the program to run the case. I currently have a matlab program that writes the bump files, but running matlab everytime I want to setup a new case is a pain.

You're right, I may stay away from f2py all together just to keep the portability.

thundersteele
May 5, 2012, 03:21 PM
I've played a bit with kivy (http://kivy.org/) but it's probably overkill for you.

itsmrjon
May 5, 2012, 03:52 PM
I've played a bit with kivy (http://kivy.org/) but it's probably overkill for you.

I've also given kivy a shot, rather steep learning curve for a guy who spends most of his time writing FORTRAN :eek:

thundersteele
May 5, 2012, 07:11 PM
I've also given kivy a shot, rather steep learning curve for a guy who spends most of his time writing FORTRAN :eek:

Well, actually I found it somewhat more straightforward than other python GUI packages. I remember having problems getting Tk/Tkinter to install on Linux, dependencies were always a problem.

My main issue with kivy was that they use OpenGL optimization, which makes a simple hello world program trigger the discrete GPU on OSX.