Hi Again everyone,
I have a question with regards to the floatlayout. Below you can find a minimal example of it, where I try to create a widget that draws an ellipse to its canvas.
Now whatever I post in the pos_hint or size_hint, makes no difference. It only uses default size (100, 100 I assume) and default pos (0,0). absolute positioning and sizing seems to work. I find this very strange.
Can anyone of you help me with that?
Thanks :)
Johannes
NOTE:
I am using kivy 1.9.1 with python 3.5.2 in ubuntu 16.04
Please also note, that I do not use the kv language for this, because for my purposes, I need to dynamically create these widgets as the game progresses. I hope that makes sense....
The code:
#!usr/bin/python3
from
kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.floatlayout import FloatLayout
from kivy.graphics import Color, Ellipse
class Dot(Widget):
def __init__(self, **kwargs):
super(Dot, self).__init__(**kwargs)
with self.canvas:
Color(255, 255, 255)
self.ell = Ellipse(pos=self.pos, size=self.size)
class SchemeGame(FloatLayout):
def __init__(self,**kwargs):
super(SchemeGame, self).__init__(**kwargs)
# Draw the ellipse widgets
e = Dot(pos_hint={'x': 1, 'y': .5}, size_hint=(0.5, 0.5))
self.add_widget(e)
class SchemeApp(App):
def build(self):
game = SchemeGame()
return game
if __name__ == '__main__':
SchemeApp().run()
Thanks! :)