I'm pretty new to kivy, and have been having this problem accessing my canvas rectangle. I need to keep it updated as I load images throughout the code and so the size of the window changes but unlike other properties such as textboxes or images, I wasn't able to access it using id or group. Would really appreciate any help :)
my python code:
import kivy
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.widget import Widget
GUI = Builder.load_file('style.kv')
class NotebookScreen(GridLayout):
def __init__(self, **kwargs):
self.rows = 1
super(NotebookScreen, self).__init__(**kwargs)
self.bind(pos=self.update_background, size=self.update_background)
def update_background(self, *args):
background = self.ids
#can't seem to access rectangle here...
# background.size = self.size
# background.pos = self.pos
class MainApp(App):
def build(self):
return NotebookScreen()
if __name__ == "__main__":
MainApp().run()
my kv code:
<NotebookScreen>
GridLayout:
id: back_layout
cols: 1
rows: 1
canvas:
Color:
rgba: 1, 1, 1, 1
Rectangle:
id: rect
pos: self.center
size: self.width, self.height
Image:
id: notebook_image
source: 'images/notebook.jpg'