Created
June 29, 2012 19:51
-
-
Save tshirtman/3020256 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # -*- encoding: UTF-8 -*- | |
| from kivy.app import App | |
| from kivy.uix.button import Button | |
| from kivy.uix.widget import Widget | |
| #kivy.require(’1.0.6’) | |
| from kivy.graphics import Quad | |
| from kivy.uix.gridlayout import GridLayout | |
| class MyWidget(Widget): | |
| def __init__(self, *args, **kwargs): | |
| kwargs.setdefault('width', 100) | |
| kwargs.setdefault('height', 150) | |
| super(MyWidget, self).__init__(*args, **kwargs) | |
| self.bind(pos=self.refresh) | |
| self.bind(size=self.refresh) | |
| def refresh(self, *args): | |
| self.canvas.clear() | |
| with self.canvas: | |
| Quad(points=( | |
| self.x, self.y + 10, | |
| self.right, self.y + 10, | |
| self.right, self.top, | |
| self.x, self.top | |
| )) | |
| class TestApp(App): | |
| def build(self): | |
| layout = GridLayout(cols=4, padding=20, spacing=10, size_hint=(1, 1)) | |
| for i in range(8): | |
| card = MyWidget() | |
| layout.add_widget(card) | |
| return layout | |
| TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment