Skip to content

Instantly share code, notes, and snippets.

@kived
Created June 4, 2015 21:28
Show Gist options
  • Save kived/335207d56c8356d3ba89 to your computer and use it in GitHub Desktop.
Save kived/335207d56c8356d3ba89 to your computer and use it in GitHub Desktop.
Kivy: texture_size demo
import kivy
kivy.require('1.8.1')
from kivy.app import App
from kivy.lang import Builder
root = Builder.load_string('''
<TestButton@Button>:
size_hint: None, None
width: self.texture_size[0] + dp(16)
height: self.texture_size[1] + dp(12)
FloatLayout:
TestButton:
pos: 100, 100
text: 'hello'
TestButton:
pos: 300, 200
text: 'longer button label'
''')
class TestApp(App):
def build(self):
return root
if __name__ == '__main__':
TestApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment