Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Python by Anorax ( 5 years ago )
import os
import kivy
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout

kivy.require('1.10.1')
os.environ['KIVY_GL_BACKEND'] = 'sdl2'


class MyApp(App):
    def __init__(self, _count=0, **kwargs):
        super(MyApp, self).__init__(**kwargs)
        self._count = _count
        self._change = None
        self.txt = None

    def increase(self):
        self._count += 1

    def build(self):
        self.title = 'Just an App'
        super_box = BoxLayout(orientation='vertical')
        horizontal_box = BoxLayout(orientation='vertical')

        if not self._change:
            self.txt = Button(text='Hello! Just press me!')
            self._change = True

        def change_text(button):
            self.increase()
            if not self._change:
                button.text = 'Unpressed'
                self._change = True

            elif self._change:
                button.text = 'Pressed'
                self._change = False

        self.txt.bind(on_press=change_text)
        horizontal_box.add_widget(self.txt)

        label = Label(text=str(self._count))

        horizontal_box.add_widget(label)
        super_box.add_widget(horizontal_box)
        return super_box


if __name__ == '__main__':
    MyApp().run()

 

Revise this Paste

Your Name: Code Language: