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
 def on_paste_point(self, *args):
     try:
         point_string = Clipboard.get('UTF8_STRING')
         lat_lon = point_string.split(",")
         lat = float(lat_lon[0])
         lon = float(lat_lon[1])
         self.ids.lat.text = str(lat)
         self.ids.lon.text = str(lon)
     except Exception:
         toast('Required format is: Latitude, Longitude\nin NN.NNNNN decimal format', True)
Example #3
0
 def on_paste_point(self, *args):
     try:
         point_string = Clipboard.get('UTF8_STRING')
         lat_lon = point_string.split(",")
         lat = float(lat_lon[0])
         lon = float(lat_lon[1])
         self.ids.lat.text = str(lat)
         self.ids.lon.text = str(lon)
     except ValueError as e:
         Logger.error("GeoPointEditor: error handling paste: {}".format(e))
         toast('Required format is: Latitude, Longitude\nin NN.NNNNN decimal format', True)
 def on_paste_point(self, *args):
     try:
         point_string = Clipboard.get('UTF8_STRING')
         lat_lon = point_string.split(",")
         lat = float(lat_lon[0])
         lon = float(lat_lon[1])
         self.ids.lat.text = str(lat)
         self.ids.lon.text = str(lon)
     except Exception:
         toast(
             'Required format is: Latitude, Longitude\nin NN.NNNNN decimal format',
             True)
Example #5
0
    def _paste(self):
        self._ensure_clipboard()
        _clip_types = Clipboard.get_types()

        mime_type = self._clip_mime_type
        if mime_type not in _clip_types:
            mime_type = 'text/plain'

        data = Clipboard.get(mime_type)
        if data is not None:
            data = data.decode(self._encoding, 'ignore')
            # remove null strings mostly a windows issue
            data = data.replace('\x00', '')
            self.delete_selection()
            self.insert_text(data)
Example #6
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)
Example #7
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)
Example #8
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)
Example #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)
Example #10
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)
Example #11
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)
Example #12
0
 def on_edit_button(self, instance):
     listOptions = list()
     
     bSelection = (self.m_oEditorInput.selection_text != "")
     if bSelection:
         listOptions.append(("Cut", self.on_cut_button))
         listOptions.append(("Copy", self.on_copy_button))
     
     clipboardcontents = None
     try:
         clipboardcontents = Clipboard.get('UTF8_STRING')
     except:
         pass
     if clipboardcontents and len(clipboardcontents) > 0:
         listOptions.append(("Paste", self.on_paste_button))
     
     if bSelection:
         listOptions.append(("", None))
         listOptions.append(("Indent", self.on_indent_button))
         listOptions.append(("Unindent", self.on_unindent_button))
     
     if len(listOptions) > 0:
         self.chooseoptionpopup = ChooseOptionPopup("Edit", listOptions)
Example #13
0
    def on_edit_button(self, instance):
        listOptions = list()

        bSelection = (self.m_oEditorInput.selection_text != "")
        if bSelection:
            listOptions.append(("Cut", self.on_cut_button))
            listOptions.append(("Copy", self.on_copy_button))

        clipboardcontents = None
        try:
            clipboardcontents = Clipboard.get('UTF8_STRING')
        except:
            pass
        if clipboardcontents and len(clipboardcontents) > 0:
            listOptions.append(("Paste", self.on_paste_button))

        if bSelection:
            listOptions.append(("", None))
            listOptions.append(("Indent", self.on_indent_button))
            listOptions.append(("Unindent", self.on_unindent_button))

        if len(listOptions) > 0:
            self.chooseoptionpopup = ChooseOptionPopup("Edit", listOptions)
Example #14
0
 def copy_to_clipboard(self, text):
     Clipboard.put(bytes(text, 'UTF-8'), 'UTF8_STRING')
     Clipboard.get('UTF8_STRING')
Example #15
0
 def copy_to_clipboard(self, text):
     Clipboard.put(bytes(text, 'UTF-8'), 'UTF8_STRING')
     Clipboard.get('UTF8_STRING')
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)
Example #17
0
 def copy_address_to_clipboard(self, instance):
     address = instance.next_address
     clipboard.copy(address)
     self.show_copied_popup(address)
     print Clipboard.get('UTF8_STRING')
Example #18
0
 def on_paste_button(self):
     clipboardcontents = Clipboard.get('UTF8_STRING')
     if clipboardcontents and len(clipboardcontents) > 0:
         self.m_oEditorInput.insert_text(clipboardcontents)
Example #19
0
 def copy_address_to_clipboard(self, instance):
     address = instance.next_address
     clipboard.copy(address)
     self.show_copied_popup(address)
     print Clipboard.get('UTF8_STRING')
Example #20
0
 def on_paste_button(self):
     clipboardcontents = Clipboard.get('UTF8_STRING')
     if clipboardcontents and len(clipboardcontents) > 0:
         self.m_oEditorInput.insert_text(clipboardcontents)
Example #21
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)