Skip to content

Instantly share code, notes, and snippets.

@tshirtman
Created December 15, 2012 20:47
Show Gist options
  • Save tshirtman/4299042 to your computer and use it in GitHub Desktop.
Save tshirtman/4299042 to your computer and use it in GitHub Desktop.
BorderImage example, pure python and kv.
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()
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()
@TanimSk
Copy link

TanimSk commented Feb 10, 2022

💖 💖 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment