diff --git a/command_box.py b/command_box.py index b9927bb..c79fc46 100644 --- a/command_box.py +++ b/command_box.py @@ -2,7 +2,10 @@ from kivy.uix.label import Label class Command_box(Label): - def __init__(self,**kwargs): + def __init__(self,app,**kwargs): + # app is used to share information between widgets + self.app=app + # init Label super(Command_box,self).__init__(**kwargs) diff --git a/cross.py b/cross.py index 5c7bb76..7cefa99 100644 --- a/cross.py +++ b/cross.py @@ -208,7 +208,7 @@ def cross_polar(t): # cross painter class Cross_painter(Widget): - def __init__(self,**kwargs): + def __init__(self,app,**kwargs): # list of crosses self.crosses=[] @@ -216,6 +216,9 @@ class Cross_painter(Widget): # selected cross self.selected=None + # app is used to share information between widgets + self.app=app + # init Widget super(Cross_painter,self).__init__(**kwargs) @@ -262,6 +265,8 @@ class Cross_painter(Widget): # redraw self.canvas.clear() self.draw() + # report position in status bar + self.app.status_bar.set_position(" {:05.2f} , {:05.2f}".format(self.selected.pos.x,self.selected.pos.y)) # find the cross at position pos diff --git a/jam.kv b/jam.kv index a572c4d..0b9e5c9 100644 --- a/jam.kv +++ b/jam.kv @@ -1,7 +1,7 @@ #: kivy 2.0.0 : - canvas: + canvas.before: Color: rgb: 1,1,1 Rectangle: @@ -9,9 +9,13 @@ size: self.size size_hint_y: None height: 20 + text_size: self.size + markup: True + color: (0,0,0,1) + : - canvas: + canvas.before: Color: rgb: 0,0,0 Rectangle: @@ -19,4 +23,5 @@ size: self.size size_hint_y: None height: 20 + text_size: self.size diff --git a/main.py b/main.py index d563c10..a76caa9 100644 --- a/main.py +++ b/main.py @@ -14,12 +14,12 @@ class Jam_app(App): def build(self): layout=BoxLayout(orientation="vertical") - painter=Cross_painter() - status=Status_bar() - command=Command_box() - layout.add_widget(painter) - layout.add_widget(status) - layout.add_widget(command) + self.painter=Cross_painter(self) + self.status_bar=Status_bar(self) + self.command_box=Command_box(self) + layout.add_widget(self.painter) + layout.add_widget(self.status_bar) + layout.add_widget(self.command_box) return layout diff --git a/status_bar.py b/status_bar.py index f1d2741..57c9409 100644 --- a/status_bar.py +++ b/status_bar.py @@ -1,8 +1,15 @@ 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,**kwargs): + def __init__(self,app,**kwargs): + # app is used to share information between widgets + self.app=app + # init Label super(Status_bar,self).__init__(**kwargs) + + def set_position(self,string): + self.text=escape_markup(string)