2
0
Fork 0
textout/textoutpc/builtin/_Progress.py

37 lines
1021 B
Python
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
# This file is part of the textoutpc project, which is MIT-licensed.
#******************************************************************************
from .. import BlockTag as _BlockTag
__all__ = ["ProgressTag"]
class ProgressTag(_BlockTag):
""" Progress tag, used to display the progress on anything.
Usage:
[progress=50]My great progress bar[/progress]
[progress=100][/progress] """
aliases = ('[progress]',)
raw = True
def prepare(self, name, value):
self._val = int(value)
if self._val < 0 or self._val > 100:
raise Exception("progress value should be between 0 and 100 incl.")
def begin_html(self):
return '<div>'
def end_html(self):
return '' \
'<div class="progress">' \
'<div class="progress-inner" style="width: {}%;">{}%' \
'</div></div></div>'.format(self._val, self._val)
# End of file.