from kivy.app import App from kivy.uix.label import Label from kivy.uix.popup import Popup from kivy.uix.textinput import TextInput class variableLabel (Label): def __init__(self, text): super(variableLabel, self).__init__() self.text = text def on_touch_down(self, touch): if touch.is_double_tap and self.collide_point(*touch.pos): _input = TextInput(text=self.text, multiline=False, auto_dismiss=False) popup = Popup(title='Editing Label text', content=_input) _input.bind (text=self.on_text) _input.bind (on_text_validate=popup.dismiss) popup.open() def on_text (self, instance, value): self.text = value class MyApp(App): def build(self): return variableLabel("New") if __name__ == '__main__': MyApp().run()
Do you have suggestions for improvement?