sugar-toolkit-gtk3/examples/radiopalette.py

74 lines
1.9 KiB
Python
Raw Normal View History

from gi.repository import Gtk
2009-07-13 02:32:26 +02:00
from sugar3.graphics.radiopalette import RadioPalette, RadioMenuButton, \
2009-07-13 02:32:26 +02:00
RadioToolsButton
from sugar3.graphics.radiotoolbutton import RadioToolButton
2009-07-13 02:32:26 +02:00
window = Gtk.Window()
2009-07-13 02:32:26 +02:00
box = Gtk.VBox()
2009-07-13 02:32:26 +02:00
window.add(box)
toolbar = Gtk.Toolbar()
2009-07-13 02:32:26 +02:00
box.pack_start(toolbar, False)
text_view = Gtk.TextView()
box.pack_start(text_view, True, True, 0)
2009-07-13 02:32:26 +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
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()
Gtk.main()