Exemplo n.º 1
1
 def selectaddress(self):
     """copy address to clipboard when user clicks"""
     print('User clicked on ', self.rawaddress)
     Clipboard.put(self.rawaddress)
Exemplo n.º 2
0
def copy(data):
    if module == "mac":
        clipboard_macosx.copy(data)
    else:
        assert module == "kivy"
        Clipboard.put(data, 'UTF8_STRING')
        Clipboard.put(data, 'text/plain')
Exemplo n.º 3
0
 def _copy(self, data):
     # explicitly terminate strings with a null character
     # so as to avoid putting spurious data after the end.
     # MS windows issue.
     self._ensure_clipboard()
     data = data.encode(self._encoding) + '\x00'
     Clipboard.put(data, self._clip_mime_type)
Exemplo n.º 4
0
def copy(data):
    if module == "mac":
        clipboard_macosx.copy(data)
    else:
        assert module == "kivy"
        Clipboard.put(data, 'UTF8_STRING')
        Clipboard.put(data, 'text/plain')
Exemplo n.º 5
0
def paste_clipboard(text):
    #convert to generic
    text = text.encode('ascii')

    clipboard_types = Clipboard.get_types()
    for cb_type in clipboard_types:
        if str(cb_type).lower().strip().startswith('text'):
            Clipboard.put(text, cb_type)
            return
                
    raise Exception('Could not find plain text clipboard in ' + str(clipboard_types))
Exemplo n.º 6
0
def paste_clipboard(text):
    # convert to generic
    text = text.encode('ascii')

    clipboard_types = Clipboard.get_types()
    for cb_type in clipboard_types:
        if str(cb_type).lower().strip().startswith('text'):
            Clipboard.put(text, cb_type)
            return

    raise Exception('Could not find plain text clipboard in ' + str(clipboard_types))
 def build(self):
     root= GridLayout()
     layout = FloatLayout(orientation='horizontal', size=(450,300), size_hint=(None, None))
     #call function when text changes inside TextInput
     textinput.bind(text=on_text)
     print ('value is ', textinput.text)
     print Clipboard.put(textinput.text,'UTF8_STRING')
     print Clipboard.get('UTF8_STRING')
     #Use copied clipboard value as text for Button
     button.text= Clipboard.get('UTF8_STRING')
     layout.add_widget(button)
     layout.add_widget(textinput)
     root.add_widget(layout)
     return root
Exemplo n.º 8
0
    def _window_on_key_down(self,
                            window,
                            key,
                            scancode=None,
                            unicode=None,
                            modifiers=None):
        from kivy.core.clipboard import Clipboard

        is_osx = sys.platform == 'darwin'
        # Keycodes on OSX:
        ctrl, cmd = 64, 1024

        if unicode and not key in (self.interesting_keys.keys() + [27]):
            # This allows *either* ctrl *or* cmd, but not both.
            if modifiers == ctrl or (is_osx and modifiers == cmd):
                if key == ord('x'):  # cut selection
                    Clipboard.put(self.selection_text, 'text/plain')
                    self.delete_selection()
                elif key == ord('c'):  # copy selection
                    Clipboard.put(self.selection_text, 'text/plain')
                elif key == ord('v'):  # paste selection
                    data = Clipboard.get('text/plain')
                    if data:
                        self.delete_selection()
                        self.insert_text(data)
                elif key == ord('a'):  # select all
                    self.selection_from = 0
                    self.selection_to = len(self.text)
                    self._update_selection(True)
            else:
                if self._selection:
                    self.delete_selection()
                self.insert_text(unicode)
            #self._recalc_size()
            return

        if key == 27:  # escape
            self.focus = False
            return True
        elif key == 9:  # tab
            self.insert_text('\t')
            return True

        k = self.interesting_keys.get(key)
        if k:
            key = (None, None, k, 1)
            self._key_down(key)
Exemplo n.º 9
0
    def do(self, action):
        textinput = self.textinput

        global Clipboard
        if Clipboard is None:
            from kivy.core.clipboard import Clipboard

        if action == 'cut':
            Clipboard.put(textinput.selection_text, 'text/plain')
            textinput.delete_selection()
        elif action == 'copy':
            Clipboard.put(textinput.selection_text, 'text/plain')
        elif action == 'paste':
            data = Clipboard.get('text/plain')
            if data:
                textinput.delete_selection()
                textinput.insert_text(data)
Exemplo n.º 10
0
    def do(self, action):
        textinput = self.textinput

        global Clipboard
        if Clipboard is None:
            from kivy.core.clipboard import Clipboard

        if action == 'cut':
            Clipboard.put(textinput.selection_text, 'text/plain')
            textinput.delete_selection()
        elif action == 'copy':
            Clipboard.put(textinput.selection_text, 'text/plain')
        elif action == 'paste':
            data = Clipboard.get('text/plain')
            if data:
                textinput.delete_selection()
                textinput.insert_text(data)
Exemplo n.º 11
0
    def do(self, action):
        textinput = self.textinput

        global Clipboard
        if Clipboard is None:
            from kivy.core.clipboard import Clipboard

        if action == "cut":
            Clipboard.put(textinput.selection_text, "text/plain")
            textinput.delete_selection()
        elif action == "copy":
            Clipboard.put(textinput.selection_text, "text/plain")
        elif action == "paste":
            data = Clipboard.get("text/plain")
            if data:
                textinput.delete_selection()
                textinput.insert_text(data)
Exemplo n.º 12
0
    def _keyboard_on_key_down(self, window, keycode, text, modifiers):
        global Clipboard
        if Clipboard is None:
            from kivy.core.clipboard import Clipboard

        is_osx = sys.platform == "darwin"
        # Keycodes on OSX:
        ctrl, cmd = 64, 1024
        key, key_str = keycode

        if text and not key in (self.interesting_keys.keys() + [27]):
            # This allows *either* ctrl *or* cmd, but not both.
            if modifiers == ["ctrl"] or (is_osx and modifiers == ["meta"]):
                if key == ord("x"):  # cut selection
                    Clipboard.put(self.selection_text, "text/plain")
                    self.delete_selection()
                elif key == ord("c"):  # copy selection
                    Clipboard.put(self.selection_text, "text/plain")
                elif key == ord("v"):  # paste selection
                    data = Clipboard.get("text/plain")
                    if data:
                        self.delete_selection()
                        self.insert_text(data)
                elif key == ord("a"):  # select all
                    self.selection_from = 0
                    self.selection_to = len(self.text)
                    self._update_selection(True)
            else:
                if self._selection:
                    self.delete_selection()
                self.insert_text(text)
            # self._recalc_size()
            return

        if key == 27:  # escape
            self.focus = False
            return True
        elif key == 9:  # tab
            self.insert_text("\t")
            return True

        k = self.interesting_keys.get(key)
        if k:
            key = (None, None, k, 1)
            self._key_down(key)
Exemplo n.º 13
0
    def _window_on_key_down(self, window, key, scancode=None, unicode=None,
                            modifiers=None):
        global Clipboard
        if Clipboard is None:
            from kivy.core.clipboard import Clipboard

        is_osx = sys.platform == 'darwin'
        # Keycodes on OSX:
        ctrl, cmd = 64, 1024

        if unicode and not key in (self.interesting_keys.keys() + [27]):
            # This allows *either* ctrl *or* cmd, but not both.
            if modifiers == ['ctrl'] or (is_osx and modifiers == ['meta']):
                if key == ord('x'): # cut selection
                    Clipboard.put(self.selection_text, 'text/plain')
                    self.delete_selection()
                elif key == ord('c'): # copy selection
                    Clipboard.put(self.selection_text, 'text/plain')
                elif key == ord('v'): # paste selection
                    data = Clipboard.get('text/plain')
                    if data:
                        self.delete_selection()
                        self.insert_text(data)
                elif key == ord('a'): # select all
                    self.selection_from = 0
                    self.selection_to = len(self.text)
                    self._update_selection(True)
            else:
                if self._selection:
                    self.delete_selection()
                self.insert_text(unicode)
            #self._recalc_size()
            return

        if key == 27: # escape
            self.focus = False
            return True
        elif key == 9: # tab
            self.insert_text('\t')
            return True

        k = self.interesting_keys.get(key)
        if k:
            key = (None, None, k, 1)
            self._key_down(key)
Exemplo n.º 14
0
 def aphorism_copy(self):
     """copy the current aphorism to the clipboard"""
     if not self.current_aphorism:
         return
     A = self.current_aphorism
     tpl = "\"{aphorism}\"\n  -- {author}\n\n({source})"
     quote = tpl.format(aphorism=A.aphorism,
                        author=A.author,
                        source=A.source)
     Clipboard.put(quote, 'TEXT')
     Clipboard.put(quote, 'text/plain;charset=utf-8')
     Clipboard.put(quote, 'UTF8_STRING')
     w = self.WidgetCopy()
     w.textarea_copy.text = quote
     w.open()
Exemplo n.º 15
0
 def aphorism_copy(self):
     """copy the current aphorism to the clipboard"""
     if not self.current_aphorism:
         return
     A = self.current_aphorism
     tpl = "\"{aphorism}\"\n  -- {author}\n\n({source})"
     quote = tpl.format(
         aphorism=A.aphorism,
         author=A.author,
         source=A.source)
     Clipboard.put(quote, 'TEXT')
     Clipboard.put(quote, 'text/plain;charset=utf-8')
     Clipboard.put(quote, 'UTF8_STRING')
     w = self.WidgetCopy()
     w.textarea_copy.text = quote
     w.open()
def on_text(self, *args):
        print ('new value is ', textinput.text)
        Clipboard.put(textinput.text,'UTF8_STRING')
        button.text= Clipboard.get('UTF8_STRING')
        self.add_widget(button)
Exemplo n.º 17
0
 def on_copy_button(self):
     selection = self.m_oEditorInput.selection_text
     if selection != "":
         Clipboard.put(selection, 'UTF8_STRING')
Exemplo n.º 18
0
	def copy_result(self):
		Clipboard.put(self.ids.result_text.text, 'UTF8_STRING')
Exemplo n.º 19
0
 def selecttxid(self):
     Clipboard.put(self.txid)
Exemplo n.º 20
0
 def callback(button):
     Clipboard.put(val)
Exemplo n.º 21
0
 def copy_to_clipboard(self, text):
     Clipboard.put(bytes(text, 'UTF-8'), 'UTF8_STRING')
     Clipboard.get('UTF8_STRING')
Exemplo n.º 22
0
 def selectpaymentid(self):
     Clipboard.put(self.paymentid)
Exemplo n.º 23
0
 def selectaddress(self):
     Clipboard.put(self.address)
Exemplo n.º 24
0
 def on_copy_button(self):
     selection = self.m_oEditorInput.selection_text
     if selection != "":
         Clipboard.put(selection, 'UTF8_STRING')
Exemplo n.º 25
0
 def on_touch_up(self, touch):
     if touch.ud is None:
         return
     x, y = self.to_local(*touch.pos)
     if 'key' in touch.ud and touch.ud['key'] == self.get_key_at_pos(x, y) and self.get_key_at_pos(x, y) is not None:
         displayed_char, internal, special_char, size = touch.ud['key'][0]
         b_keycode = special_char
         b_modifiers = self._get_modifiers()
         if special_char.startswith('sug'):
             if internal is not None and internal != '':
                 word = self.get_current_word()
                 textarea = self.get_text_area()
                 textarea.select_text(textarea.cursor_index() - len(word), textarea.cursor_index())
                 textarea.delete_selection()
         if internal is not None and len(internal) == 1 and not (len(special_char) == 1 and special_char.isalpha()):
             prev_word = str(self.get_previous_word())
             cur_word = str(self.get_current_word())
             if cur_word != '':
                 self.user_nograms += 1
                 if cur_word not in self.words:
                     self.words[cur_word.lower()] = self.val_dist(tuple(map(self.key_centers.__getitem__, cur_word.lower()))) + (0.0,)
                 self.user_unigrams[cur_word] = self.user_unigrams.get(cur_word, 0) + 1
                 if prev_word != '':
                     self.user_bigrams[(prev_word, cur_word)] = self.user_bigrams.get((prev_word, cur_word), 0) + 1
                 self.dispatch('on_key_down', b_keycode, internal, b_modifiers)
                 matches = self.candidate_guesses()[:6]
                 self.update_candidates(matches)
             else:
                 self.dispatch('on_key_down', b_keycode, internal, b_modifiers)
         else:
             self.dispatch('on_key_down', b_keycode, internal, b_modifiers)
         if (len(special_char) == 1 and special_char.isalpha()) or special_char == 'backspace':
             word = self.get_current_word()
             if len(word) >= 4:
                 matches = self.candidate_predictions(word)[:6]
             else:
                 matches = []
             self.update_candidates(matches)
     elif 'ctrl' in touch.ud and self.get_key_at_pos(x, y) is not None:
         displayed_char, internal, special_char, size = self.get_key_at_pos(x, y)[0]
         k = special_char
         if k == 'c':
             textarea = self.get_text_area()
             Clipboard.put(textarea.selection_text, 'STRING')
             textarea.cancel_selection()
         elif k == 'v':
             textarea = self.get_text_area()
             textarea.delete_selection()
             textarea.insert_text(Clipboard.get('STRING'))
         elif k == 'a':
             textarea = self.get_text_area()
             textarea.select_all()
         elif k == 'x':
             textarea = self.get_text_area()
             Clipboard.put(textarea.selection_text, 'STRING')
             textarea.delete_selection()
         elif k == 'z':
             textarea = self.get_text_area()
             textarea.do_undo()
         elif k == 'y':
             textarea = self.get_text_area()
             textarea.do_redo()
         elif k == 'l':
             available_layouts = self.available_layouts.keys()
             self.layout = available_layouts[(available_layouts.index(self.layout) + 1) % len(self.available_layouts)]
             self.reload_layout()
         #elif k == 's':
         #    window = self.get_parent_window()
         #    textarea = self.get_text_area()
         #    def _on_close(self):
         #        window.children[0].remove_widget(settings)
         #        textarea.focus = True
         #    settings = Settings(on_close=_on_close)
         #    settings.add_json_panel('VKeyboard Settings', self.config, 'settings.json')
         #    window.children[1].add_widget(settings)
         #    window.release_keyboard(self)
             
     elif 'line' in touch.ud:
         gesture = touch.ud['line'].points
         gesture = [(gesture[i], gesture[i+1]) for i in xrange(0, len(gesture), 2)]
         matches = self.candidate_matches(gesture)[:6]
         self.update_candidates(matches)
         b_modifiers = self._get_modifiers()
         if 'shift' in b_modifiers and 'capslock' not in b_modifiers:
             matches = [(w[0].upper() + w[1:], p) for w, p in matches]
         elif 'capslock' in b_modifiers and 'shift' not in b_modifiers:
             matches = [(w.upper(), p) for w, p in matches]
         if len(matches) > 0:
             textarea = self.get_text_area()
             textarea.delete_selection()
             textarea.insert_text(matches[0][0])
     if touch.grab_current is self:
         self.process_key_up(touch)
     if 'line' in touch.ud:
         self.canvas.remove(touch.ud['line'])
     return super(VKeyboard, self).on_touch_up(touch)
Exemplo n.º 26
0
 def selectaddress(self):
     Clipboard.put(self.address)
Exemplo n.º 27
0
 def on_click_printed_error(self, touch):
     Clipboard.put(str(self.ids.label_conn_error.text), 'UTF8_STRING')
     if touch.is_double_tap:
         self.ids.label_conn_error.text = ''
Exemplo n.º 28
0
 def selecttxid(self):
     Clipboard.put(self.txid)
Exemplo n.º 29
0
 def callback(button):
     Clipboard.put(val)
Exemplo n.º 30
0
 def clip (self):
     Clipboard.put(self.smanager.encrypter.decripta ( self.passwd.valor ), 'UTF8_STRING')
Exemplo n.º 31
0
 def selectAddress(self):
     """Copy address to clipboard when user clicks"""
     print('User clicked on ', self.address)
     Clipboard.put(self.address)
Exemplo n.º 32
0
 def copy_to_clipboard(self, text):
     Clipboard.put(bytes(text, 'UTF-8'), 'UTF8_STRING')
     Clipboard.get('UTF8_STRING')
Exemplo n.º 33
0
 def selectpaymentid(self):
     Clipboard.put(self.paymentid)