Jam/status_bar.py

30 lines
741 B
Python
Raw Normal View History

from kivy.uix.label import Label
from kivy.graphics import Color,Rectangle
from kivy.utils import escape_markup
class Status_bar(Label):
def __init__(self,app,**kwargs):
# app is used to share information between widgets
self.app=app
2021-10-16 06:46:06 +00:00
# width of a character
self.char_width=9
# unformatted text
self.raw_text=""
# init Label
super(Status_bar,self).__init__(**kwargs)
2021-10-16 06:46:06 +00:00
def set_text(self,string):
self.raw_text=string
self.draw()
def draw(self):
# do not wrap
if len(self.raw_text)<self.width/self.char_width:
self.text=self.raw_text
else:
self.text=self.raw_text[:int(self.width/self.char_width)]