John Hunter wrote:

"Brice" == Brice V <[EMAIL PROTECTED]> writes:

   Brice> John Hunter wrote:
   >> How does one add a CheckButton or the analogous ToolItem to a
   >> Toolbar in 2.6 ?  I see derived classes ToolButton,
   >> ToggleToolButton and RadioToolButton, but I don't see how to
   >> make any of these behave like a CheckButton.

   Brice> you have to use a ToolItem to add a CheckButton.  first,
   Brice> create a ToolItem. then add your CheckButton and add the
   Brice> ToolItem to your Toolbar.

Thanks Brice, that was helpful.

Any idea how to get the tooltip working?  If you modify the code to
use tooltips, they work for the button but not the checkbutton.  Is
this a bug, or are there some gtk.Container events I need to deal with
such as propogate_expose or set_focus_chain?

#!/usr/bin/env python

import gtk

def toggled (obj):
    print 'toggled %s' % obj.get_active ()

def main ():
    win = gtk.Window (gtk.WINDOW_TOPLEVEL)
    win.set_title ('v %s' % '.'.join (map (str , gtk.pygtk_version)))
    win.set_size_request (320 , 200)
    win.connect ('delete-event' , gtk.main_quit)

    vbox = gtk.VBox ()
    hdlb = gtk.HandleBox ()

    tooltips = gtk.Tooltips()
tlb = gtk.Toolbar ()

    tbi = gtk.ToolItem ()
    tbi.set_tooltip(tooltips, 'Toggle me', '')
    chk = gtk.CheckButton ()
    chk.set_label ('test me')
    chk.connect ('toggled' , toggled)
    tbi.add (chk)
    tlb.add (tbi)

    tlb.add (gtk.SeparatorToolItem ())

    but = gtk.ToolButton (gtk.STOCK_QUIT)
    but.set_tooltip(tooltips, 'Click me', '')
    but.connect ('clicked' , gtk.main_quit)
    tlb.add (but)

    hdlb.add (tlb)
    vbox.pack_start (hdlb , False , False)
    vbox.pack_start (gtk.Label ('check button in a toolbar'))
    win.add (vbox)
    win.show_all ()

    gtk.main ()

if __name__ == '__main__':
    main ()
Try setting the tooltip after you add the checkbutton to the toolitem.

John
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to