diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-06-11 19:07:24 +1200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-06-11 19:07:24 +1200 |
commit | fadd1fe22cb7fa3f5b97bfbd0d0420a69e9aef3a (patch) | |
tree | 9dc2ee4e0585faecbeafd2b60fab1a3815dd5604 /ttystatus/index.py | |
parent | c8151180d084a7c91c508024be159ee5b71f18a3 (diff) | |
download | python-ttystatus-fadd1fe22cb7fa3f5b97bfbd0d0420a69e9aef3a.tar.gz |
Add Index widget.
Diffstat (limited to 'ttystatus/index.py')
-rw-r--r-- | ttystatus/index.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ttystatus/index.py b/ttystatus/index.py new file mode 100644 index 0000000..d085a40 --- /dev/null +++ b/ttystatus/index.py @@ -0,0 +1,33 @@ +# Copyright 2010 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +import ttystatus + + +class Index(ttystatus.Widget): + + '''Display the position of a value in a list of values.''' + + def __init__(self, name, listname): + self.name = name + self.listname = listname + self.value = '0' + + def update(self, master, width): + try: + self.value = str(master[self.listname].index(master[self.name])) + except ValueError: + pass |