2018-01-02 18:57:04 +01:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
2018-01-05 22:13:30 +01:00
|
|
|
|
from .__base__ import *
|
2018-01-02 18:57:04 +01:00
|
|
|
|
|
|
|
|
|
__all__ = ["TextoutProgressTag"]
|
|
|
|
|
|
2018-01-05 22:13:30 +01:00
|
|
|
|
class TextoutProgressTag(TextoutRawBlockTag):
|
2018-01-02 18:57:04 +01:00
|
|
|
|
""" Progress tag, used to display the progress on anything.
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
|
|
[progress=50]My great progress bar[/progress]
|
|
|
|
|
[progress=100][/progress] """
|
|
|
|
|
|
2018-01-05 22:13:30 +01:00
|
|
|
|
aliases = ('[progress]',)
|
|
|
|
|
|
2018-01-02 18:57:04 +01:00
|
|
|
|
def _prepare(self):
|
|
|
|
|
self.val = int(self.value)
|
|
|
|
|
if self.val < 0 or self.val > 100:
|
|
|
|
|
raise Exception("progress value should be between 0 and 100 incl.")
|
|
|
|
|
|
2018-01-05 22:13:30 +01:00
|
|
|
|
def process_text(self, mode):
|
2018-01-02 18:57:04 +01:00
|
|
|
|
val /= 5
|
|
|
|
|
return '{}{}|{}|{}'.format(self.content, mode.newline,
|
|
|
|
|
'X' * val + '-' * (20 - val), mode.newline)
|
|
|
|
|
|
2018-01-05 22:13:30 +01:00
|
|
|
|
def process_html(self, mode):
|
2018-01-02 18:57:04 +01:00
|
|
|
|
return '<div>{}' \
|
|
|
|
|
'<div style="background-color: white; border: 1px solid black; ' \
|
|
|
|
|
'width: 50%; margin-top: 2px; text-align: left;">' \
|
|
|
|
|
'<div style="background-color: #FF3E28; color: black; ' \
|
|
|
|
|
'font-weight: bold; max-width: 100%; width: {}%;' \
|
|
|
|
|
'height: 18px;"> {}%' \
|
|
|
|
|
'</div></div></div>'.format(self.content, self.val, self.val)
|
|
|
|
|
|
|
|
|
|
# End of file.
|