[Tutor] opening a Qt .py file from within another python app.

Alan Gauld alan.gauld at btinternet.com
Thu Mar 22 08:31:22 CET 2012

On 22/03/12 03:47, ken brockman wrote:

> None of which had gotten the Qt window to open.
 > Yet when I run it directly, on it's own, it open's
 > and the Qt window is displayed.

My guess is that there is an if __name__... clause
at the bottom with some code that doesn't get
executed when you import it. That clause has some
initialisation code that starts the main window up.

Try opening the file in an editor and seeing what is
happening there. You will either need to move that
into a function then call the function after importing,
or replicate it in your top level file.

Having said that the os.system technique should have worked regardless, 
but it won't let you do any more integration.

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list