sugar-toolkit-gtk3/examples/radiopalette.py

76 lines
1.9 KiB
Python
Raw Normal View History

2009-07-13 02:32:26 +02:00
import gtk
from sugar.graphics.radiopalette import RadioPalette, RadioMenuButton, \
RadioToolsButton
2009-07-29 17:33:02 +02:00
from sugar.graphics.radiotoolbutton import RadioToolButton
2009-07-13 02:32:26 +02:00
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics import style
window = gtk.Window()
box = gtk.VBox()
window.add(box)
toolbar = gtk.Toolbar()
box.pack_start(toolbar, False)
text_view = gtk.TextView()
box.pack_start(text_view)
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()