Created
December 15, 2012 20:47
-
-
Save tshirtman/4299042 to your computer and use it in GitHub Desktop.
BorderImage example, pure python and kv.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.uix.widget import Widget | |
from kivy.uix.button import Button | |
from kivy.graphics import BorderImage | |
class MyApp(App): | |
def build(self): | |
root = Widget() | |
b = Button(center=(200, 200)) | |
root.add_widget(b) | |
with b.canvas.before: | |
BorderImage( | |
size=(b.width + 100, b.height + 100), | |
pos=(b.x - 50, b.y - 50), | |
border=(10, 10, 10, 10), | |
source='tex.png') | |
return root | |
MyApp().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.lang import Builder | |
kv = ''' | |
Widget: | |
Button: | |
pos: 200, 200 | |
canvas.before: | |
BorderImage: | |
source: 'tex.png' | |
pos: self.x - 50, self.y - 50 | |
size: self.width + 100, self.height + 100 | |
''' | |
class MyApp(App): | |
def build(self): | |
return Builder.load_string(kv) | |
MyApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this was useful!