Re: [gedit-list] Adding items at the beginning of the toolbar




area42 wrote:
> 
> For the "New from Temlate" plugin i'd like to add a button at the  
> beginning of the toolbar.
> 
You can insert the buttons wherever you want if you add them through the GTK
object methods rather than through the UI manager.

# These two lines are presumptuous about the arrangement of widgets in the
gedit window.
vbox = window.get_children()[0]
toolbar = vbox.get_children()[1]

# Add the button at position 0
button = gtk.ToolButton(gtk.STOCK_YES)
button.set_tooltip_text('Yes button')
toolbar.insert(item=button, pos=0)
button.show()

# Give the button a callback
def on_yes_button(toolbutton):
    md = gtk.MessageDialog(buttons=gtk.BUTTONS_OK,
                            message_format="Yes pressed")
    md.run()
    md.destroy()
yes_button_handler = button.connect('clicked', on_yes_button)

The pos=0 puts the button at the beginning.  You can examine the toolbar
children to determine an appropriate index for your button.


-- 
View this message in context: http://old.nabble.com/Adding-items-at-the-beginning-of-the-toolbar-tp28522420p28527184.html
Sent from the Gnome - Gedit mailing list archive at Nabble.com.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]