working on it ...


Explore Public Snippets

Sort by

Found 2 snippets matching: "kivy gui"

    public by dave83  5057  15  8  6

    Touch down event binding in Kivy framework

    This code shows how to handle a touch event in the python Kivy framework. This snippet will generate a simple GUI, with 2 standard buttons and a custom button, where to bind the press event. Any Kivy property has a default on_ event. This event is called when the value of the property is changed. In this case the on_touch_down(self, touch) meth
    from import App
     from kivy.uix.widget import Widget
     from kivy.uix.button import Button
     from kivy.uix.boxlayout import BoxLayout
     from import ListProperty
     class RootWidget(BoxLayout):
         def __init__(self, **kwargs):
             super(RootWidget, self).__init__(**kwargs)
             self.add_widget(Button(text='btn 1'))
             cb = CustomBtn()
             self.add_widget(Button(text='btn 2'))
         def btn_pressed(self, instance, pos):
             print ('pos: printed from root widget: {pos}'.format(pos=pos))
     class CustomBtn(Widget):
         pressed = ListProperty([0, 0])
         def on_touch_down(self, touch):
             if self.collide_point(*touch.pos):
                 self.pressed = touch.pos
                 # we consumed the touch. return False here to propagate
                 # the touch further to the children.
                 return True
             return super(CustomBtn, self).on_touch_down(touch)
         def on_pressed(self, instance, pos):
             print ('pressed at {pos}'.format(pos=pos))
     class TestApp(App):
         def build(self):
             return RootWidget()
     if __name__ == '__main__':

    external by John Jung  338  1  3  0

    Beagle Bone Kivy GUI

    Beagle Bone Kivy GUI:
    Vending Machine GUI script
    Kivy GUI script to run basic scripts
    import kivy
    from kivy.animation import Animation
    from import App
    from kivy.uix.button import Button
    from kivy.uix.gridlayout import GridLayout
    import os
    class Actions(App):
        def runscript1(self, instance):
            # path to script you want to execute
            path = 'echo scriptpathhere1'
        def runscript2(self, instance):
            # path to script you want to execute
            path = 'echo scriptpathhere2'
        def build(self):
            # Use 
            layout = GridLayout(cols=2)
            layout.add_widget(Button(text='Dispense', on_press=self.runscript1,font_size=36))
            layout.add_widget(Button(text='Return', on_press=self.runscript2,font_size=36))
            return layout
    if __name__ == '__main__':

    List Complete ( 2 snippets total )

    Cannot find what you were looking for?
    Ask the Snip2Code Community

    • Public Snippets
    • Channels Snippets