sugar-toolkit-gtk3/examples/radiotoolbutton.py
Ignacio Rodríguez b6d449681d Example fixes
- replaced Gtk.HBox/Gtk.VBox by GtkBox as seen in [1] and [2]
GtkHbox and GtkVBox are deprecated
- use delete-event instead of destroy event in GtkWindow
- replaced icon_size for pixel_size where used
it's also deprecated as seen in commit [3]
- use sugar_theme in all examples; set it manually not by just
importing common module
- fixed GtkBox.pack_start arguments
- flake/pep8 fixes

[1] https://developer.gnome.org/gtk3/stable/GtkHBox.html
[2] https://developer.gnome.org/gtk3/stable/GtkVBox.html
[3] 5802d67ee1
2017-01-14 13:02:50 -03:00

49 lines
1.5 KiB
Python

from gi.repository import Gtk
from sugar3.graphics.radiotoolbutton import RadioToolButton
from sugar3.graphics.radiopalette import RadioPalette, RadioMenuButton
from sugar3.graphics.xocolor import XoColor
from common import set_theme
set_theme()
window = Gtk.Window()
window.show()
window.connect("delete-event", Gtk.main_quit)
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
window.add(box)
box.show()
def echo(button, label):
if not button.props.active:
return
print label
palette = RadioPalette()
# Adding 3 RadioToolButtons to a palette
button1 = RadioToolButton(icon_name='document-save', accelerator="<ctrl>S",
xo_color=XoColor("white"))
button1.connect('toggled', lambda button: echo(button, 'document-save'))
palette.append(button1, 'menu.document-save')
button2 = RadioToolButton(icon_name='document-open', accelerator="<ctrl>O",
xo_color=XoColor("white"), group=button1)
button2.connect('toggled', lambda button: echo(button, 'document-open'))
palette.append(button2, 'menu.document-open')
button3 = RadioToolButton(icon_name='document-send', accelerator="<ctrl>F",
xo_color=XoColor("white"), group=button1)
button3.connect('toggled', lambda button: echo(button, 'document-send'))
palette.append(button3, 'menu.document-send')
button = RadioMenuButton(palette=palette)
box.pack_start(button, False, False, 1)
button.show()
if __name__ == '__main__':
Gtk.main()