2018-01-02 18:57:04 +01:00
|
|
|
|
#!/usr/bin/env python3
|
2018-02-19 19:50:26 +01:00
|
|
|
|
#******************************************************************************
|
|
|
|
|
# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
|
|
|
# This file is part of the textoutpc project, which is MIT-licensed.
|
|
|
|
|
#******************************************************************************
|
2018-01-02 18:57:04 +01:00
|
|
|
|
|
2018-07-28 19:49:29 +02:00
|
|
|
|
from .. import BlockTag as _BlockTag
|
2018-01-02 18:57:04 +01:00
|
|
|
|
|
2018-07-28 19:49:29 +02:00
|
|
|
|
__all__ = ["ProgressTag"]
|
2018-01-02 18:57:04 +01:00
|
|
|
|
|
2018-08-25 17:38:24 +02:00
|
|
|
|
|
2018-07-28 19:49:29 +02:00
|
|
|
|
class ProgressTag(_BlockTag):
|
2018-01-02 18:57:04 +01:00
|
|
|
|
""" Progress tag, used to display the progress on anything.
|
|
|
|
|
Usage:
|
2018-08-25 17:38:24 +02:00
|
|
|
|
|
2018-01-02 18:57:04 +01:00
|
|
|
|
[progress=50]My great progress bar[/progress]
|
|
|
|
|
[progress=100][/progress] """
|
|
|
|
|
|
2018-01-05 22:13:30 +01:00
|
|
|
|
aliases = ('[progress]',)
|
2018-01-24 12:33:33 +01:00
|
|
|
|
raw = True
|
2018-01-05 22:13:30 +01:00
|
|
|
|
|
2018-01-16 13:34:11 +01:00
|
|
|
|
def prepare(self, name, value):
|
2018-01-21 22:08:23 +01:00
|
|
|
|
self._val = int(value)
|
|
|
|
|
if self._val < 0 or self._val > 100:
|
2018-01-02 18:57:04 +01:00
|
|
|
|
raise Exception("progress value should be between 0 and 100 incl.")
|
|
|
|
|
|
2018-01-16 13:34:11 +01:00
|
|
|
|
def begin_html(self):
|
|
|
|
|
return '<div>'
|
2018-01-02 18:57:04 +01:00
|
|
|
|
|
2018-01-16 13:34:11 +01:00
|
|
|
|
def end_html(self):
|
|
|
|
|
return '' \
|
2018-08-25 17:38:24 +02:00
|
|
|
|
'<div class="progress">' \
|
|
|
|
|
'<div class="progress-inner" style="width: {}%;"> {}%' \
|
|
|
|
|
'</div></div></div>'.format(self._val, self._val)
|
2018-01-02 18:57:04 +01:00
|
|
|
|
|
|
|
|
|
# End of file.
|