Questions for Python gurus!

Discussion in 'Mac Programming' started by itsmrjon, May 4, 2012.

  1. itsmrjon macrumors regular

    Jun 11, 2011
    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!
  2. ytk macrumors regular

    Jul 8, 2010
    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.
  3. subsonix macrumors 68040

    Feb 2, 2008
  4. blueillusion, May 5, 2012
    Last edited: May 5, 2012

    blueillusion macrumors member

    Aug 18, 2008
    I use PySide :

    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.

    -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

    -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.

    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
  5. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    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.

  6. itsmrjon thread starter macrumors regular

    Jun 11, 2011
    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 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.
  7. thundersteele macrumors 68030

    Oct 19, 2011
    I've played a bit with kivy but it's probably overkill for you.
  8. itsmrjon thread starter macrumors regular

    Jun 11, 2011
    I've also given kivy a shot, rather steep learning curve for a guy who spends most of his time writing FORTRAN :eek:
  9. thundersteele macrumors 68030

    Oct 19, 2011
    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.

Share This Page