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 # width of a character self.char_width=9 # unformatted text self.raw_text="" # a one-time message that shows up over the bar self.message="" # init Label super(Status_bar,self).__init__(**kwargs) self.draw() def draw(self): # 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 # list openfile if self.app.openfile!="": self.raw_text=self.app.openfile else: self.raw_text="[no file]" # readonly if self.app.readonly: self.raw_text+=" [RO]" # coordinates of selected cross if len(self.app.painter.selected)>0: # number of spaces to align right (use 13 characters to print position) spaces=int(self.width/self.char_width)-len(self.raw_text)-13 if spaces>0: if self.app.painter.reference==None: self.raw_text+=" "*spaces+"({:05.2f},{:05.2f})\n".format(self.app.painter.selected[0].squares[0].pos.x,self.app.painter.selected[0].squares[0].pos.y) else: self.raw_text+=" "*spaces+"({:05.2f},{:05.2f})\n".format(self.app.painter.selected[0].squares[0].pos.x-self.app.painter.reference.squares[0].pos.x,self.app.painter.selected[0].squares[0].pos.y-self.app.painter.reference.squares[0].pos.y) # do not wrap self.text=self.raw_text[:min(len(self.raw_text),int(self.width/self.char_width))]