Answer the question
In order to leave comments, you need to log in
How to get the actual dimensions of a kivy widget?
Good day, I ran into such a problem that when calling self.size on a widget, the result 100,100 is returned.
Googled that this is due to the fact that the default sizes do not change, and in order to change them, you can write something like:
def __init__(self):
super().__init__()
self.bind(size=self.update)
Answer the question
In order to leave comments, you need to log in
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.layout import Layout
kv = '''
<Foo>:
on_touch_down: print(self.size)
'''
Builder.load_string(kv)
class Foo(Layout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
print (self.size)
class MyApp(App):
def build(self):
return Foo()
MyApp().run()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question