Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/graphics/progressicon.py
blob: 9a91a9e77987e8176bde65d8830a04eb04305f33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright (C) 2013, One Laptop Per Child
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

"""
Test the sugar3.graphics.progressicon.ProgressIcon widget.
"""


from gi.repository import GObject

from sugar3.graphics.progressicon import ProgressIcon
from sugar3.graphics import style

import common

test = common.Test()
test.show()

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()

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)