[PySide] Simple PySide GUI for Python Program

Algis Kabaila akabaila at pcug.org.au
Wed Feb 12 09:00:10 CET 2014


On January 24 started a thread, entitled "using QProcess to run a python 
function."  It was a discussion about communication between an extant CLI 
python program and a GUI to be developed for it.  I found it interesting, but 
was disappointed that in the end no coded examples were offered.

In the simplicissimus bunch of  elementary tutorials that I wrote, ref:

http://qt-project.org/wiki/PySide-Newbie-Tutorials

there is one tutorial, named "Engineering Application", ref:

http://qt-project.org/wiki/PySide_Engineering_Application 

which is an example of a simple interface between a CLI style Python program 
(ncrunch.py) and its GUI (truss.py).  Whilst the text of these tutorials has 
not been updated yet, the programs have been updated and placed in one 
repository on "github", named "tuts4pyside" ("Owner" OldAl).  All the blobs in 
the repository can be cloned by anybody with the git command:

git clone  https://github.com/OldAl/tuts4pyside

To run the programs one needs to install numpy (python-numpy) in addition to 
pyside. The CLI program can be run, after changing the work directory to 
"tuts4pyside/truss" in your local repository, with the command

python  ncrunch.py

Alternatively, the GUI version can be run by

python  truss.py

Refer to README.md in the same directory for further information. 
The "secret" of this dual entry to the program is a little function 
"printline".  When the ncrunch.py is started from CLI, printline prints on 
stdout.  

When ncrunch.py is used as a module of "truss.py", printline is passed as a 
parameter to ncrunch.py, where it prints on the "Solution Page" of the GUI.  
Simple, when one thinks about it.

It seems to me that many users of python programs are interested in graphical 
tools, such as PySide or PyQt,  mainly because they want to be able to provide 
GUIs for their python programs.  For that reason alone, it is a topic worthy 
of discussion.

If required or desired, I can be contacted by email on this list or by private 
email.  All feedback  is appreciated.  I live in Canberra, Australia, where I 
can also be contacted directly.

Last, but not least, I want to thank Aaron Richiger who was so generous with 
his time and his expert advice before I was put out of action by a stroke some 
6 months ago.  Yes, I have mostly recovered.

Also, I wish to thank "github" for hosting free of charge repositories for 
open source programs, including "tuts4pyside". 

OldAl (Al. Kabaila)





More information about the PySide mailing list