IDLE and gtk windows

Comments, suggestions and questions about Linux Format magazine and the coverdiscs

Moderators: ChrisThornett, LXF moderators

IDLE and gtk windows

Postby LGLudd » Sat Oct 15, 2011 11:00 am

I am attempting to follow the python tutorials but have a rather odd issue. all the code works if I run python from the command line but if I use IDLE then the only commands that appear to work are those that return their results to the IDLE shell. I cannot display any gtk windows (although no errors are returned) the music player will work (in so far as music starts playing as desired)

I think that this may be either a setup or security problem (I am running Fedora 14) but cannot work out what the problem is

Any assistance would be greatly appreciated.

Thanks
Leo
LGLudd
 
Posts: 8
Joined: Sat Oct 15, 2011 10:50 am

Postby LGLudd » Mon Oct 17, 2011 2:55 pm

OK so I worked out part of what is happening but am not sure how to fix it.

The window is being displayed but not shown on the screen I can get the window (but not the content) to display by using IDLEs shell window and typing
Code: Select all
w.get_position()
which tells me it is at 0,0.

I can get the window to display by adding the get_position method call to the end of my script but this feels wrong and still does not diplay the content.

What I do not understand is firstly why I do not see it initially and secondly how to fix it.

Any ideas?

Thanks
Leo
LGLudd
 
Posts: 8
Joined: Sat Oct 15, 2011 10:50 am

Postby evilnick » Mon Oct 17, 2011 3:56 pm

I think the 'problem' is with the way gtk works. If you want to run interactively with the shell, it's fine for almost all things. If you try to execute the code (the interactive listings anyhow) then the main gtk loop has to be invoked for some things to happen.
if you add
Code: Select all
gtk.main()

to the end of the things that don't appear to work, do they work?
User avatar
evilnick
Moderator
 
Posts: 151
Joined: Mon Apr 04, 2005 11:47 am
Location: LXF towers

Postby LGLudd » Mon Oct 17, 2011 5:51 pm

Yes that works perfectly, thanks Nick.

I was getting really frustrated by this.

Leo
LGLudd
 
Posts: 8
Joined: Sat Oct 15, 2011 10:50 am


Return to Magazine and coverdiscs

Who is online

Users browsing this forum: Google [Bot] and 1 guest