[pygtk] More pyGTK questions.

Neil Munro neilmunro at gmail.com
Fri Nov 14 02:18:15 WST 2008


2008/11/13 Frédéric <frederic.mantegazza at gbiloba.org>

> On jeudi 13 novembre 2008, Neil Munro wrote:
>
> > Hey, again, have spent most of the day playing around and reading about
> > python and glade and thus far this is what I have, now I have a few
> > issues I have questions about, firstly how do I get the text associated
> > with a toolbar button and change it for example if you notice the 'play'
> > button when this is pressed I wish for the button to be renamed and
> > re-iconed to 'pause' but have no idea how to do this or even if it's
> > possible, I imagine so, but I don't actually know.
>
> Just get the name of you menu entry (using wTree.get_widget() method), and
> change its properties. Then see documentation to retreive the properties
> associated with the menu entry.
>
> > Secondly, while I have discovered a way to close a window by essentially
> > crashing it in program what is the safest way to close a gtk window from
> > within python, in my program here I have an about dialog box that opens,
> > but when it closes it either takes the whole application with it (which
> > I quickly corrected) or crashes un-gracefully and while the window
> > appears to close, it's in fact crashed.
>
> You don't need to bind OK/Cancel dialogs buttons signals; the dialogs will
> be closed as soon as you press OK or Cancel.
>
> Look at my code, for example:
>
>
> http://trac.gbiloba.org/papywizard/browser/trunk/papywizard/controller/generalInfoController.py
>
> I bind signals just to make some special actions before the dialog is
> closed, but I don't cal a quit method.
>

I've gotten rid of the quit methods etc since I don't need them but every
time I hit my ok button (which should just close the about window) does
nothing except the code that acknowledges something happens.

#!/usr/bin/env python

import sys, os, os.path, gtk.glade, pygtk, gtk
pygtk.require( "2.0" )

def About( obj ):
    wTree = gtk.glade.XML( "musicdb-gui.glade", "dialog1" )
    dic = { "on_BTN_OK_clicked" : About_OK_clicked,
        "on_dialog1_destroy" : Window_Destroyed }
    wTree.signal_autoconnect ( dic )

def About_OK_clicked( obj ):
    ## Button was clicked. ##
    print "0"

def Window_Destroyed( obj ):
    print "Window closed."

That's what I have so far, I moved that into a separate module to easier
manage my code base, am gonna look at my other problem once solving this
one. To be quite honest I don't see that I am doing anything fundamentally
different that prevents my OK button from closing the window :S

Thanks
Niadh


>
> --
>    Frédéric
>
>    http://www.gbiloba.org
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20081113/e2e2fafd/attachment.htm 


More information about the pygtk mailing list