Skip to content

Instantly share code, notes, and snippets.

@kived
Created October 24, 2014 21:19
Show Gist options
  • Save kived/9448d87793835e61b418 to your computer and use it in GitHub Desktop.
Save kived/9448d87793835e61b418 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.lang import Builder
from kivy.graphics import Color, Rectangle
from kivy.properties import ObjectProperty
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.scrollview import ScrollView
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.widget import Widget
Builder.load_string('''
<Main_Class>:
Screen:
FloatLayout:
ScrollView:
Image:
FloatLayout:
Button:
text: 'Hi'
id: butt
Second_Class:
size_hint: 0.5,0.5
main__class: root
<Second_Class>:
on_release: self.function()
canvas:
Color:
rgba: 1,0,0,1
Rectangle:
size: self.size
pos: self.pos
''')
class Second_Class(ButtonBehavior, Widget):
main__class = ObjectProperty()
def function(self):
print self.main__class.ids.butt.text
class Main_Class(ScreenManager):
def __init__(self, **kwargs):
super(Main_Class, self).__init__(**kwargs)
class Application(App):
def build(self):
return Main_Class()
if __name__ == '__main__':
Application().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment