Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.uix.boxlayout import BoxLayout
- from kivy.core.clipboard import Clipboard
- from kivy.properties import ObjectProperty
- import sys
- Builder.load_string('''
- #:kivy 1.8.0
- <RootWidget>:
- label_text: label_text
- Label:
- id: label_text
- markup: True
- text: '[ref=text_selection]initial[/ref]'
- on_ref_press: root.copytext()
- TextInput:
- ''')
- class RootWidget(BoxLayout):
- """Root Kivy widget class"""
- label_text = ObjectProperty()
- def __init__(self):
- super(RootWidget, self).__init__()
- def copytext(self):
- """copy address to clipboard when user clicks"""
- text = self.label_text.text
- print('User clicked on ', text)
- Clipboard.put(text)
- class ExampleApp(App):
- def build(self):
- return RootWidget()
- if __name__ == '__main__':
- ExampleApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement