Skip to content

Instantly share code, notes, and snippets.

@Mrestof
Created April 12, 2020 13:08
Show Gist options
  • Save Mrestof/609d628f36e6061dea8bea560f979a46 to your computer and use it in GitHub Desktop.
Save Mrestof/609d628f36e6061dea8bea560f979a46 to your computer and use it in GitHub Desktop.
Position problems
<ScatterTextWidget>:
FloatLayout:
id: my_flayout
canvas:
Color:
rgba: 0, 1, 0, 1
Rectangle:
pos: self.pos
size: self.size
Scatter:
id: my_scatter
size_hint: None, None
size: 300, 100
canvas.after:
Color:
rgb: 1, 0, 1
Rectangle:
pos: self.pos
size: self.size
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
class ScatterTextWidget(BoxLayout):
pass
class LearningApp(App):
def build(self):
root_widget = ScatterTextWidget()
scat = root_widget.ids['my_scatter']
fllt = root_widget.ids['my_flayout']
print(scat.center)
print(fllt.center)
scat.center = fllt.center
print(scat.center)
print(fllt.center)
return root_widget
if __name__ == "__main__":
LearningApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment