sugar-toolkit-gtk3/examples/progressicon.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

59 lines
1.2 KiB
Python

from gi.repository import Gtk
from gi.repository import GObject
from sugar3.graphics.toolbarbox import ToolbarBox
from sugar3.graphics.progressicon import ProgressIcon
from sugar3.graphics import style
import common
test = common.Test()
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
test.pack_start(box, True, True, 0)
toolbar_box = ToolbarBox()
box.pack_start(toolbar_box, False, False, 0)
separator = Gtk.SeparatorToolItem()
toolbar_box.toolbar.insert(separator, -1)
icon = ProgressIcon(
pixel_size=style.LARGE_ICON_SIZE,
icon_name='computer-xo',
stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
fill_color=style.COLOR_WHITE.get_svg())
test.pack_start(icon, True, True, 0)
icon.show()
icon2 = ProgressIcon(
pixel_size=style.LARGE_ICON_SIZE,
icon_name='computer-xo',
stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
fill_color=style.COLOR_WHITE.get_svg(),
direction='horizontal')
test.pack_start(icon2, True, True, 0)
icon2.show()
test.show_all()
progress = 0
def timeout_cb():
global progress
progress += 0.05
icon.update(progress)
icon2.update(progress)
if progress >= 1:
return False
return True
GObject.timeout_add(50, timeout_cb)
if __name__ == '__main__':
common.main(test)