On Sat, 24 Jan 2004 11:21:38 -0600
David Farning <[EMAIL PROTECTED]> wrote:

> I'm trying my first go round with gygtk.  I can not seem to figure out
> how to disable individual elements within the tool bar.
> 
> I build the toolbar as such.
> 
>  def buildPackageToolBar(self):
>         toolbar = gtk.Toolbar()
>         icon = gtk.Image()
>         icon.set_from_pixbuf(self.icons.icons["not_installed_install"])
>         detailsButton = toolbar.append_item(
>             "Install",
>             "Install Package",
>             "Private",
>             icon,
>             self.aEvent,
>             "install")
>         toolbar.append_space()
> 
>         icon = gtk.Image()
>         icon.set_from_pixbuf(self.icons.icons["installed_hold"])
>         detailsButton = toolbar.append_item(
>             "Hold",
>             "Hold Package",
>             "Private",
>             icon,
>             self.aEvent,
>             "hold")
>         toolbar.append_space()
> 
>         icon = gtk.Image()
>         icon.set_from_pixbuf(self.icons.icons["installed_update"])
>         detailsButton = toolbar.append_item(
>             "Update",
>             "Update Package",
>             "Private",
>             icon,
>             self.aEvent,
>             "update")
>         toolbar.append_space()
>         
>         icon = gtk.Image()
>         icon.set_from_pixbuf(self.icons.icons["installed_remove"])
>         detailsButton = toolbar.append_item(
>             "Remove",
>             "Remove Package",
>             "Private",
>             icon,
>             self.aEvent,
>             "remove")
>         toolbar.set_border_width(5)
>         print toolbar.get_children()
>         return  toolbar
> 
> when I run the above the print statement responds with
> 
>  [<gtk.Bin object (GtkToolButton) at 0xf49bb98c>, <gtk.Bin object
> (GtkSeparatorToolItem) at 0xf49bb9b4>, <gtk.Bin object (GtkToolButton)
> at 0xf49bb9dc>, <gtk.Bin object (GtkSeparatorToolItem) at 0xf49bba04>,
> <gtk.Bin object (GtkToolButton) at 0xf49bba2c>, <gtk.Bin object
> (GtkSeparatorToolItem) at 0xf49bba54>, <gtk.Bin object (GtkToolButton)
> at 0xf49bba7c>]
> 
> I assume that I want to do something like toolbar[0].set_disabled()
> but...I can't find any reference material about a gtk.ToolButton.
> 
> Am I missing something?

The append_item method returns the widget that was added. So you can use
all widget (maybe even button?) methods on it. To disable a button I do
something like this in my application:

detailsButton.set_sensitive (gtk.FALSE)

OTOH, if you want to iterate over all items you could probably use

for item in toolbar.get_children():
    item.set_sensitive (gtk.FALSE)

I havn't tested this, though.

> 
> Thanks,
> Dave Farning
> 

Regards,
  Felix
_______________________________________________
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