2011-11-15 19:29:07 +01:00
|
|
|
from gi.repository import Gtk
|
2009-07-13 02:32:26 +02:00
|
|
|
|
2011-10-29 10:44:18 +02:00
|
|
|
from sugar3.graphics.radiopalette import RadioPalette, RadioMenuButton, \
|
2009-07-13 02:32:26 +02:00
|
|
|
RadioToolsButton
|
2011-10-29 10:44:18 +02:00
|
|
|
from sugar3.graphics.radiotoolbutton import RadioToolButton
|
2009-07-13 02:32:26 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
window = Gtk.Window()
|
2009-07-13 02:32:26 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
box = Gtk.VBox()
|
2009-07-13 02:32:26 +02:00
|
|
|
window.add(box)
|
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
toolbar = Gtk.Toolbar()
|
2009-07-13 02:32:26 +02:00
|
|
|
box.pack_start(toolbar, False)
|
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
text_view = Gtk.TextView()
|
|
|
|
box.pack_start(text_view, True, True, 0)
|
2009-07-13 02:32:26 +02:00
|
|
|
|
2010-10-15 19:53:25 +02:00
|
|
|
|
2009-07-30 13:29:52 +02:00
|
|
|
def echo(button, label):
|
2009-07-29 17:33:02 +02:00
|
|
|
if not button.props.active:
|
|
|
|
return
|
2010-10-15 21:14:59 +02:00
|
|
|
text_view.props.buffer.props.text += '\n' + label
|
2009-07-29 17:33:02 +02:00
|
|
|
|
|
|
|
# RadioMenuButton
|
2009-07-13 02:32:26 +02:00
|
|
|
|
|
|
|
palette = RadioPalette()
|
2009-07-29 17:33:02 +02:00
|
|
|
|
|
|
|
group = RadioToolButton(
|
2009-07-30 13:29:52 +02:00
|
|
|
icon_name='document-open')
|
|
|
|
group.connect('clicked', lambda button: echo(button, 'document-open'))
|
2009-07-29 18:15:38 +02:00
|
|
|
palette.append(group, 'menu.document-open')
|
2009-07-29 17:33:02 +02:00
|
|
|
|
|
|
|
button = RadioToolButton(
|
2009-07-13 02:32:26 +02:00
|
|
|
icon_name='document-save',
|
2009-07-30 13:29:52 +02:00
|
|
|
group=group)
|
|
|
|
button.connect('clicked', lambda button: echo(button, 'document-save'))
|
2009-07-29 18:15:38 +02:00
|
|
|
palette.append(button, 'menu.document-save')
|
2009-07-29 17:33:02 +02:00
|
|
|
|
|
|
|
button = RadioToolButton(
|
2009-07-13 02:32:26 +02:00
|
|
|
icon_name='document-send',
|
2009-07-30 13:29:52 +02:00
|
|
|
group=group)
|
|
|
|
button.connect('clicked', lambda button: echo(button, 'document-send'))
|
2009-07-29 18:15:38 +02:00
|
|
|
palette.append(button, 'menu.document-send')
|
2009-07-13 02:32:26 +02:00
|
|
|
|
|
|
|
button = RadioMenuButton(palette=palette)
|
|
|
|
toolbar.insert(button, -1)
|
|
|
|
|
2009-07-29 17:33:02 +02:00
|
|
|
# RadioToolsButton
|
|
|
|
|
2009-07-13 02:32:26 +02:00
|
|
|
palette = RadioPalette()
|
2009-07-29 17:33:02 +02:00
|
|
|
|
|
|
|
group = RadioToolButton(
|
2009-07-30 13:29:52 +02:00
|
|
|
icon_name='document-open')
|
|
|
|
group.connect('clicked', lambda button: echo(button, 'document-open'))
|
2009-07-29 18:15:38 +02:00
|
|
|
palette.append(group, 'menu.document-open')
|
2009-07-29 17:33:02 +02:00
|
|
|
|
|
|
|
button = RadioToolButton(
|
2009-07-13 02:32:26 +02:00
|
|
|
icon_name='document-save',
|
2009-07-30 13:29:52 +02:00
|
|
|
group=group)
|
|
|
|
button.connect('clicked', lambda button: echo(button, 'document-save'))
|
2009-07-29 18:15:38 +02:00
|
|
|
palette.append(button, 'menu.document-save')
|
2009-07-29 17:33:02 +02:00
|
|
|
|
|
|
|
button = RadioToolButton(
|
2009-07-13 02:32:26 +02:00
|
|
|
icon_name='document-send',
|
2009-07-30 13:29:52 +02:00
|
|
|
group=group)
|
|
|
|
button.connect('clicked', lambda button: echo(button, 'document-send'))
|
2009-07-29 18:15:38 +02:00
|
|
|
palette.append(button, 'menu.document-send')
|
2009-07-13 02:32:26 +02:00
|
|
|
|
|
|
|
button = RadioToolsButton(palette=palette)
|
|
|
|
toolbar.insert(button, -1)
|
|
|
|
|
|
|
|
window.show_all()
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.main()
|