2021-09-29 19:52:31 +00:00
|
|
|
from kivy.uix.label import Label
|
|
|
|
from kivy.graphics import Color,Rectangle
|
2021-09-30 05:46:12 +00:00
|
|
|
from kivy.utils import escape_markup
|
2021-09-29 19:52:31 +00:00
|
|
|
|
|
|
|
class Status_bar(Label):
|
|
|
|
|
2021-09-30 05:46:12 +00:00
|
|
|
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=""
|
|
|
|
|
2021-10-16 20:48:42 +00:00
|
|
|
# a one-time message that shows up over the bar
|
|
|
|
self.message=""
|
|
|
|
|
2021-09-29 19:52:31 +00:00
|
|
|
# init Label
|
|
|
|
super(Status_bar,self).__init__(**kwargs)
|
2021-09-30 05:46:12 +00:00
|
|
|
|
2021-10-16 06:46:06 +00:00
|
|
|
self.draw()
|
|
|
|
|
|
|
|
def draw(self):
|
2021-10-16 20:48:42 +00:00
|
|
|
# if message is not empty, draw message instead
|
|
|
|
if self.message!="":
|
|
|
|
self.text=self.message[:min(len(self.message),int(self.width/self.char_width))]
|
|
|
|
self.message=""
|
|
|
|
return
|
|
|
|
|
2021-10-18 22:57:35 +00:00
|
|
|
# list openfile
|
2021-10-16 23:14:22 +00:00
|
|
|
if self.app.openfile!="":
|
|
|
|
self.raw_text=self.app.openfile
|
|
|
|
else:
|
|
|
|
self.raw_text="[no file]"
|
2021-10-18 22:57:35 +00:00
|
|
|
|
|
|
|
# readonly
|
|
|
|
if self.app.readonly:
|
|
|
|
self.raw_text+=" [RO]"
|
|
|
|
|
|
|
|
|
2021-10-16 06:46:06 +00:00
|
|
|
# do not wrap
|
2021-10-16 20:48:42 +00:00
|
|
|
self.text=self.raw_text[:min(len(self.raw_text),int(self.width/self.char_width))]
|