sugar-toolkit-gtk3/examples/toolbar.py

53 lines
1.3 KiB
Python
Raw Normal View History

2009-07-10 06:07:10 +02:00
import gtk
2009-07-12 03:42:23 +02:00
from sugar.graphics.toolbutton import ToolButton
2009-07-10 06:07:10 +02:00
from sugar.graphics.toolbar import Toolbar, ToolbarButton
2009-07-12 03:42:23 +02:00
from sugar.graphics import style
2009-07-10 06:07:10 +02:00
window = gtk.Window()
box = gtk.VBox()
window.add(box)
toolbar = Toolbar()
box.pack_start(toolbar, False)
2009-07-12 03:42:23 +02:00
tollbarbutton_1 = ToolbarButton(
page=gtk.Button('sub-widget #1'),
icon_name='computer-xo')
2009-07-10 06:07:10 +02:00
toolbar.top.insert(tollbarbutton_1, -1)
2009-07-12 03:42:23 +02:00
tollbarbutton_2 = ToolbarButton(
page=gtk.Button('sub-widget #2'),
2009-07-10 06:07:10 +02:00
icon_name='button_cancel',
2009-07-12 03:42:23 +02:00
tooltip='with custom palette instead of sub-widget')
2009-07-10 06:07:10 +02:00
toolbar.top.insert(tollbarbutton_2, -1)
toolbar.top.insert(gtk.SeparatorToolItem(), -1)
2009-07-11 16:22:05 +02:00
def del_cb(widget):
toolbar.top.remove(tollbarbutton_3)
del_b = gtk.Button('delete sub-widget #3')
del_b.connect('clicked', del_cb)
2009-07-12 03:42:23 +02:00
tollbarbutton_3 = ToolbarButton(
page=del_b,
icon_name='activity-journal')
2009-07-10 06:07:10 +02:00
toolbar.top.insert(tollbarbutton_3, -1)
subbar = gtk.Toolbar()
subbutton = ToolButton(
icon_name='document-send',
tooltip='document-send')
subbar.insert(subbutton, -1)
subbar.show_all()
tollbarbutton_4 = ToolbarButton(
page=subbar,
icon_name='document-save')
toolbar.top.insert(tollbarbutton_4, -1)
print [i.props.page for i in toolbar.subs]
2009-07-10 06:07:10 +02:00
window.show_all()
gtk.main()