Skip to content
Snippets Groups Projects
Select Git revision
  • 8fc303e7ba85b24af1fddc3ebb4a30dd6dacae7d
  • main default protected
2 results

main.py

Blame
  • Forked from Brady James Garvin / method_overriding
    8 commits behind the upstream repository.
    user avatar
    Chris Bohn authored
    8fc303e7
    History
    main.py 976 B
    from kivy.app import App
    from kivy.uix.button import Button
    from kivy.properties import NumericProperty, StringProperty
    
    
    class OneTimeButton(Button):
        count = 0
        index = NumericProperty()
    
        def __init__(self):
            super().__init__()
            self.index = OneTimeButton.count
            OneTimeButton.count += 1
    
        def on_press(self):
            self.disabled = True
            print(self.index)
    
    
    class GuessingButton(Button):
        hidden_text = StringProperty('')
    
        def __init__(self, hidden_text):
            super().__init__()
            self.hidden_text = hidden_text
    
        def on_press(self):
            if self.text == '':
                self.text = self.hidden_text
            else:
                self.text = ''
    
    
    class DemoApp(App):
        def build(self):
            for i in range(5):
                self.root.add_widget(OneTimeButton())
            for i in range(5):
                self.root.add_widget(GuessingButton(str(i)))
    
    
    if __name__ == '__main__':
        app = DemoApp()
        app.run()