Print position in status bar

This commit is contained in:
Ian Jauslin 2021-12-20 23:14:27 +01:00
parent 1c1e2ad6f7
commit fc50782116
2 changed files with 13 additions and 0 deletions

View File

@ -203,6 +203,9 @@ class Painter(Widget):
self.draw() self.draw()
# draw status bar
self.app.status_bar.draw()
# respond to drag # respond to drag
def on_touch_move(self,touch): def on_touch_move(self,touch):
@ -218,6 +221,9 @@ class Painter(Widget):
# redraw # redraw
self.draw() self.draw()
# draw status bar
self.app.status_bar.draw()
# find the particle at position pos # find the particle at position pos
def find_particle(self,pos): def find_particle(self,pos):

View File

@ -39,5 +39,12 @@ class Status_bar(Label):
if self.app.readonly: if self.app.readonly:
self.raw_text+=" [RO]" 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:
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)
# do not wrap # do not wrap
self.text=self.raw_text[:min(len(self.raw_text),int(self.width/self.char_width))] self.text=self.raw_text[:min(len(self.raw_text),int(self.width/self.char_width))]