/
kano-progress
executable file
·59 lines (44 loc) · 1.31 KB
/
kano-progress
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
#!/usr/bin/env python
# kano-progress
#
# Copyright (C) 2014 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
#
# usage: kano-progress title=title description=desc buttons=abc:orange:1,bcd:red:2
#
import os
import sys
import time
if __name__ == '__main__' and __package__ is None:
dir_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if dir_path != '/usr':
sys.path.insert(1, dir_path)
from kano.gtk3.kano_progress import KanoProgressBar
def parse_items(args):
global radio_returnvalue
pulse = False
title = "Loading"
rate = 0.01
timeout = 2
for arg in args:
split = arg.split('=')
if split[0] == "pulse":
pulse = True
if split[0] == "title":
title = split[1]
if split[0] == "rate":
rate = float(split[1])
if split[0] == "timeout":
timeout = int(split[1])
return pulse, title, rate, timeout
def main():
text = sys.argv[1:]
pulse, title, rate, timeout = parse_items(text)
pbar = KanoProgressBar(pulse, title, rate)
pbar.show_all()
# For now, only use timeout if the progress bar pulses
if pulse:
pbar.set_work_function(time.sleep, timeout)
pbar.run()
if __name__ == '__main__':
main()