def paste_twofa_code(self, textinput): clipboard_data = Clipboard.paste() if type(clipboard_data) in (str, unicode) and re.match( '\d+$', clipboard_data): textinput.text = clipboard_data else: toast_notification(u'Ошибка при вставке')
def remove_outdated_data(): print("remove_outdated_data thread UP") # wait for 2 seconds to make sure gui is up time.sleep(2) # DummyNode, remove comments if you want to show this #networkInterface.nodelist.update( # "Most recently received message is shown here", # "Ip slot (IPV6 supported)", # "DummyNode", # graphicalUserInterface.get_root(), # "See readme.md for instructions on message format" #) networkInterface.get_nodelist().update_from_text( node=None, text=Clipboard.paste(), selected_nodes="all", gnode_parent=graphicalUserInterface.get_root()) while is_running: for i in range(networkInterface.get_outdate_time()): if not is_running: break time.sleep(1) if is_running: networkInterface.get_nodelist().removeOutdated() print("remove_outdated_data thread DOWN")
def load_sgf_from_clipboard(self): clipboard = Clipboard.paste() if not clipboard: self.controls.set_status("Ctrl-V pressed but clipboard is empty.", STATUS_INFO) return url_match = re.match(r"(?P<url>https?://[^\s]+)", clipboard) if url_match: self.log("Recognized url: " + url_match.group(), OUTPUT_INFO) http = urllib3.PoolManager() response = http.request("GET", url_match.group()) clipboard = response.data.decode("utf-8") try: move_tree = KaTrainSGF.parse_sgf(clipboard) except Exception as exc: self.controls.set_status( i18n._("Failed to import from clipboard").format( error=exc, contents=clipboard[:50]), STATUS_INFO) return move_tree.nodes_in_tree[-1].analyze( self.engine, analyze_fast=False) # speed up result for looking at end of game self._do_new_game(move_tree=move_tree, analyze_fast=True) self("redo", 9999) self.log("Imported game from clipboard.", OUTPUT_INFO)
def paste(self): data = Clipboard.paste() text = self.text x = self.cursor[0] lenght = len(self.text) - x self.text = text[:x] + data + text[x:] self.cursor = (len(self.text) - lenght, self.cursor[1])
def _update_pos(self, dt): ''' get and update position ''' e, n, lon, lat = get_nmea(self) try: self.e_txt.text = e[:10]#self.dat['e'][:10] self.n_txt.text = n[:10]#self.dat['n'][:10] except: pass Clipboard.copy(self.n_txt.text+':'+self.e_txt.text) tmp = Clipboard.paste() self.n_txt.text = tmp.split(':')[0] self.e_txt.text = tmp.split(':')[1] if MAKEMAP: self.map.simple_marker([lat, lon], marker_color='red') self.map.save(self.mapname) if SHOWMAP: # plot position and color code by time elapsed secs = time.mktime(time.localtime())-self.starttime self.fig.gca().scatter(float(e),float(n),s=30,c=secs, vmin=1, vmax=1200, cmap='Greens') self.fig.gca().set_ylim([float(n)-IMBOX_Y, float(n)+IMBOX_Y]) self.fig.gca().set_xlim([float(e)-IMBOX_X, float(e)+IMBOX_X]) self.fig.canvas.draw()
def paste_text(self): self.pasted_str = Clipboard.paste() if len(self.pasted_str) >= 1000: MaxClipboardPopup().open() return "" else: return self.pasted_str
def _update_pos(self, dt): ''' get and update position ''' #self.dat = get_nmea(self) e, n, d = get_nmea(self) #now = time.asctime().replace(' ','_').replace(':','_') try: self.e_txt.text = e[:10]#self.dat['e'][:10] self.n_txt.text = n[:10]#self.dat['n'][:10] except: pass #self.textinput.text += 'Position obtained: '+now+'\n' Clipboard.copy(self.n_txt.text+':'+self.e_txt.text) tmp = Clipboard.paste() self.n_txt.text = tmp.split(':')[0] self.e_txt.text = tmp.split(':')[1] #self.textinput.text += 'N: '+str(self.n_txt.text)+', E: '+str(self.e_txt.text)+', D: '+str(self.dat['depth_m'])+'\n' #self.textinput2.text += str(self.dat['depth_m'])+' m'+'\n' self.textinput2.text += d+' m'+'\n' if float(d)>10: #self.dat['depth_m']>10: self.textinput2.foreground_color = (0.6,0.5,0.0,1.0) elif d=='NaN':#self.dat['depth_m']=='NaN': self.textinput2.foreground_color = (0.25,0.5,0.25,0.25) else: self.textinput2.foreground_color = (0.0,0.0,0.0,0.0)
def TakePicture(self, fig, mode):#*args): '''takes a picture and saves it to the folder according to 'mode' ''' self.export_to_png = export_to_png tmp = Clipboard.paste() self.n_txt.text = tmp.split(':')[0] self.e_txt.text = tmp.split(':')[1] now = time.asctime().replace(' ','_').replace(':','_') if mode==1: filename = 'st'+self.txt_inpt.text+'_sand_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png' elif mode==2: filename = 'st'+self.txt_inpt.text+'_gravel_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png' elif mode==3: filename = 'st'+self.txt_inpt.text+'_rock_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png' elif mode==4: filename = 'st'+self.txt_inpt.text+'_sandrock_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png' elif mode==5: filename = 'st'+self.txt_inpt.text+'_sandgravel_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png' elif mode==6: filename = 'st'+self.txt_inpt.text+'_gravelsand_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png' self.export_to_png(self.ids.camera, filename=filename) if mode==1: subprocess.Popen("python resize_n_move.py -i "+filename+" -o eyeballimages", shell=True) self.textinput.text += 'Sand image collected:\n' elif mode==2: subprocess.Popen("python resize_n_move.py -i "+filename+" -o gravelimages", shell=True) self.textinput.text += 'Gravel image collected:\n' elif mode==3: subprocess.Popen("python resize_n_move.py -i "+filename+" -o rockimages", shell=True) self.textinput.text += 'Rock image collected:\n' elif mode==4: subprocess.Popen("python resize_n_move.py -i "+filename+" -o sandrockimages", shell=True) self.textinput.text += 'Sand/Rock image collected:\n' elif mode==5: subprocess.Popen("python resize_n_move.py -i "+filename+" -o sandgravelimages", shell=True) self.textinput.text += 'Sand/Gravel image collected:\n' elif mode==6: subprocess.Popen("python resize_n_move.py -i "+filename+" -o gravelsandimages", shell=True) self.textinput.text += 'Gravel/Sand image collected:\n' if SHOWMAP: if mode==1: fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'ys') elif mode==2: fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s',color=(.5,.5,.5)) elif mode==3: fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'rs') elif mode==4: fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s', color=(1.0, 0.6, 0.0)) elif mode==5: fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s', color=(0.75, 0.6, 0.8)) elif mode==6: fig.gca().plot(float(self.e_txt.text),float(self.n_txt.text),'s', color=(0.7, 0.7, 0.1)) fig.canvas.draw()
def current_screen_paste(self): value = Clipboard.paste() taxon_id, observation_id = get_ids_from_url(value) if taxon_id: self.select_taxon_from_photo(taxon_id) alert(f'Taxon {taxon_id} selected') if observation_id: self.select_observation_from_photo(observation_id) alert(f'Observation {observation_id} selected')
def update_current_clipboard(self, *_): #Sets the current clipboard to a local variable clipboard = Clipboard.paste() if clipboard and self.current_clipboard != clipboard: self.current_clipboard = clipboard if self.config.getboolean('Settings', 'no_duplicates'): self.remove_history_matches(clipboard) self.clipboard_history.insert(0, {'text': clipboard}) self.clipboard_history = self.clipboard_history[:self.max_history]
def on_update(self, dt): """ on_update callback gets clipboard and decides if the value is different than the value previously stored. """ if 'text/plain' == ''.join(Clipboard.get_types()[0]): # Logger.info(Clippy.get_types()) if Clipboard.paste(): data = Clipboard.paste() # Gets the data currently in the clipboard else: data = None else: Logger.info('on_update', Clipboard.get_types()) data = 'Unsupported type' if data != self.last_record: self.db.insert_new_record(self.conn, data) self.last_record = data self.data_model.clip_text += ('\nClip {0}:\n{1}'.format(self.times_updated, data)) self.times_updated += 1
def on_clipboard_key_v(self): """ paste copied item or all items of the current node from the OS clipboard into the current node. """ lit = Clipboard.paste() self.vpo(f"LiszApp.on_clipboard_key_v: pasting {lit}") items = node_from_literal(lit) err_msg = self.add_items(items) if err_msg: self.show_message(err_msg, title=get_txt("{count} error(s) in adding {len(items)} item(s)", count=err_msg.count('\n') + 1)) self.refresh_all()
def _update_pos(self, dt): ''' get and update position ''' e, n, lon, lat = get_nmea(self) try: self.e_txt.text = e[:10]#self.dat['e'][:10] self.n_txt.text = n[:10]#self.dat['n'][:10] except: pass Clipboard.copy(self.n_txt.text+':'+self.e_txt.text) tmp = Clipboard.paste() self.n_txt.text = tmp.split(':')[0] self.e_txt.text = tmp.split(':')[1]
def current_screen_paste(self): value = Clipboard.paste() model_id, gt_id = 0, 0 if model_id: self.select_model(id=model_id) alert(f'Model {model_id} selected') if gt_id: # self.select_gt(id=gt_id) alert(f'GT {gt_id} selected') if self.screen_manager.current == HOME_SCREEN: if gt_id: self.image_selection_controller.screen.gt_id_input.text = str(gt_id) self.image_selection_controller.screen.model_id_input.text = '' elif model_id: self.image_selection_controller.screen.gt_id_input.text = '' self.image_selection_controller.screen.model_id_input.text = str(model_id)
def TakePicture(self, *args): '''takes a sandcam picture and saves it to the eyeball folder ''' self.export_to_png = export_to_png tmp = Clipboard.paste() self.n_txt.text = tmp.split(':')[0] self.e_txt.text = tmp.split(':')[1] now = time.asctime().replace(' ','_').replace(':','_') filename = 'st'+self.txt_inpt.text+'_sand_'+now+'_'+self.e_txt.text+'_'+self.n_txt.text+'.png' # self.export_to_png(self.ids.camera, filename=filename) subprocess.Popen("python resize_n_move.py -i "+filename+" -o eyeballimages", shell=True) #subprocess.Popen("python resize_n_move.py -i "+os.path.normpath(os.path.join(os.gwtcwd(),filename))+" -o eyeballimages", shell=True) self.textinput.text += 'Eyeball image collected:\n'#+ filename.split('.png')[0]+'\n' #: '+filename+'\n'
def TakePicture(self): '''takes a picture and saves it to the folder ''' self.export_to_png = export_to_png tmp = Clipboard.paste() n_txt = tmp.split(':')[0] e_txt = tmp.split(':')[1] now = time.asctime().replace(' ','_').replace(':','_') filename = 'im_'+now+'_'+e_txt+'_'+n_txt+'.png' #filename = 'im_'+now+'.png' self.export_to_png(self.ids.camera, filename=filename) subprocess.Popen("python move_polecam_im.py -i "+filename+" -o GPSCam_images", shell=True)
def TakePictureSandGravel(self, *args): '''takes a picture of sand and gravel ''' self.export_to_png = export_to_png tmp = Clipboard.paste() self.n_txt.text = tmp.split(':')[0] self.e_txt.text = tmp.split(':')[1] now = time.asctime().replace(' ','_').replace(':','_') filename = 'st'+self.txt_inpt.text+'_sandgravel_'+now+'.png' self.export_to_png(self.ids.camera, filename=filename) subprocess.Popen("python resize_n_move.py -i "+filename+" -o sandgravelimages", shell=True) self.textinput.text += 'Sand/Gravel image collected:\n'#+ filename.split('.png')[0]+'\n' #: '+filename+'\n'
def load_sgf_from_clipboard(self): clipboard = Clipboard.paste() if not clipboard: self.controls.set_status(f"Ctrl-V pressed but clipboard is empty.", STATUS_INFO) return try: move_tree = KaTrainSGF.parse_sgf(clipboard) except Exception as exc: self.controls.set_status( i18n._("Failed to import from clipboard").format(error=exc, contents=clipboard[:50]), STATUS_INFO ) return move_tree.nodes_in_tree[-1].analyze( self.engine, analyze_fast=False ) # speed up result for looking at end of game self._do_new_game(move_tree=move_tree, analyze_fast=True) self("redo", 999) self.log("Imported game from clipboard.", OUTPUT_INFO)
def paste(self): str_list = Clipboard.paste().split(os.linesep) data, count = [], 0 for row in str_list: if row == '': continue count += 1 row_data = row.split('\t') if len(row_data) != self.cols: ErrorPopup( f'Error parsing text on line {count}. Make sure each cell in the text is separated by tabs' ) return data.append(row_data) if len(self._data) == 1 and self._data[0] == [''] * self.cols: self._data = data else: self._data.extend(data)
def __init__(self, auth_token, **kwargs): super(CloudCBScreen, self).__init__(**kwargs) self.header = {'Authorization': "Basic %s" % auth_token} self.url = SERVER_URI + 'copy-paste/' self.old_text = Clipboard.paste() self.cloud_clip = TextInput(text="Fetching...") layout = BoxLayout(orientation='vertical') layout.add_widget(Label(text='Cloud Clipboard')) layout.add_widget(Label(text='Current text on clipboard:')) layout.add_widget(self.cloud_clip) layout.add_widget(Button(text='Refresh', on_press=self.download)) layout.add_widget(Label(text='Earlier text on your clipboard:')) layout.add_widget(TextInput(text=self.old_text)) layout.add_widget( Button(text='Update Cloud Clipboard with this text', on_press=self.upload)) self.add_widget(layout) self.download()
def val(self, value=None): if value == None: return self.value else: ## set new value self.value = value ## Put to clipboard if value == 'NULL': self.info.text = 'Failed to generate password. No file read permission?' else: Clipboard.copy(value) clipboard_check = Clipboard.paste() if type(clipboard_check) is not bytes: clipboard_check = clipboard_check.encode('utf-8') if clipboard_check == value: self.info.text = 'Copied to clipboard' if self.show.active or value == 'NULL': ## show full value self.result.text = self.value else: ## checkbox unchecked, show part of value if type(value) is not bytes: value = value.encode('utf-8') self.result.text = pswrd.hide_part(value)
def callback(instance): target.text = Clipboard.paste()
def copy(self): return Clipboard.paste()
def Paste(self): self.ids.MyText.text = Clipboard.paste()
def paste_from_clipboard(self): from kivy.core.clipboard import Clipboard return Clipboard.paste()
def paste_clipboard(self): root.ids.source.text = Clipboard.paste()
def paste(self): self.root.ids.inp.text = Clipboard.paste()
def paste_input(self): self.input.text = Clipboard.paste() paste_sound.play()
def import_from_clipboard(): imported_text = Clipboard.paste() MDApp.get_running_app().root.get_screen( "importtext" ).ids.imported_text_field.text = f'{imported_text[:1000]} ... '
def paste(self): text = Clipboard.paste() self.app1.get_screen('clipb').ids.test.text = text
def pasteURL(self): self.ids.inputUrl.text = Clipboard.paste()
def update_from_clipboard_button_pressed(instance): self.slave.get_node().get_nodelist().update_from_text( node=self.slave.get_node(), text=Clipboard.paste(), selected_nodes=self.selected_nodes, gnode_parent=self.slave.get_parent())
def remove_from_clipboard(self, pw, dt): if Clipboard.paste() == pw: Clipboard.copy("") self.msg_label.text = "clipboard emptied %s" % time.asctime()
def Token(self): token = Clipboard.paste() f = open('Token.log','w') f.write(token) f.close() self.run()
def show_add_options(self, widget: Widget) -> bool: """ open context menu with all available actions for to add/import new node/item(s). :param widget: FlowButton to open this context menu. :return: True if any add options are available and got displayed else False. """ def add_import_options(info_text: str): """ add menu options for the current node. """ info = self.node_info(node, what=() if self.verbose else ('selected_leaf_count', 'unselected_leaf_count')) if len(node) == 1: info['content'] = node[0]['id'] info_text = str(info['selected_leaf_count'] + info['unselected_leaf_count']) + " items from " + info_text if node_id: info['name'] = node_id info_text = get_txt("node '{node_id}' with ") + info_text info_text += " to" child_maps.append(dict(kwargs=dict( text=info_text, tap_flow_id=id_of_flow('open', 'node_info'), tap_kwargs=dict(popup_kwargs=dict(node_info=info)), image_size=image_size, circle_fill_color=self.flow_path_ink, circle_fill_size=image_size, square_fill_color=self.flow_id_ink[:3] + (0.39,)))) args_tpl: Dict[str, Any] = dict( tap_flow_id=id_of_flow('import', 'node'), tap_kwargs=dict(node_to_import=node, popups_to_close=('replace_with_data_map_container',)), image_size=image_size) if self.flow_path: kwargs = deepcopy(args_tpl) kwargs['text'] = get_txt("current list begin") if node_id: kwargs['tap_kwargs']['add_node_id'] = node_id child_maps.append(dict(kwargs=kwargs)) item_index = len(self.current_node_items) if item_index: kwargs = deepcopy(args_tpl) kwargs['text'] = get_txt("current list end") kwargs['tap_kwargs']['import_items_index'] = item_index if node_id: kwargs['tap_kwargs']['add_node_id'] = node_id child_maps.append(dict(kwargs=kwargs)) kwargs = deepcopy(args_tpl) kwargs['text'] = get_txt("{FLOW_PATH_ROOT_ID} list begin") kwargs['tap_kwargs']['import_items_node'] = self.root_node if node_id: kwargs['tap_kwargs']['add_node_id'] = node_id child_maps.append(dict(kwargs=kwargs)) item_index = len(self.root_node) if item_index: kwargs = deepcopy(args_tpl) kwargs['text'] = get_txt("{FLOW_PATH_ROOT_ID} list end") kwargs['tap_kwargs']['import_items_node'] = self.root_node kwargs['tap_kwargs']['import_items_index'] = item_index if node_id: kwargs['tap_kwargs']['add_node_id'] = node_id child_maps.append(dict(kwargs=kwargs)) if focused_id: item_index = self.find_item_index(focused_id) kwargs = deepcopy(args_tpl) kwargs['text'] = get_txt("before focused item '{focused_id}'") kwargs['tap_kwargs']['import_items_index'] = item_index if node_id: kwargs['tap_kwargs']['add_node_id'] = node_id child_maps.append(dict(kwargs=kwargs)) focused_item = self.item_by_id(focused_id) if 'node' in focused_item: kwargs = deepcopy(args_tpl) kwargs['text'] = get_txt("into focused sub-list '{focused_id}'") kwargs['tap_kwargs']['import_items_node'] = focused_item['node'] if node_id: kwargs['tap_kwargs']['add_node_id'] = node_id child_maps.append(dict(kwargs=kwargs)) kwargs = deepcopy(args_tpl) kwargs['text'] = get_txt("after focused '{focused_id}'") kwargs['tap_kwargs']['import_items_index'] = item_index + 1 if node_id: kwargs['tap_kwargs']['add_node_id'] = node_id child_maps.append(dict(kwargs=kwargs)) self.vpo(f"LiszApp.show_add_options({widget})") image_size = (self.font_size * 1.35, self.font_size * 1.35) focused_id = flow_key(self.flow_id) if flow_action(self.flow_id) == 'focus' else '' child_maps = list() node = node_from_literal(Clipboard.paste()) if node: node_id = '' add_import_options(get_txt("clipboard")) node_files = self.importable_node_files(folder_path=self.documents_root_path) for node_file_info in node_files: if child_maps: # add separator widget child_maps.append(dict(cls='Widget', kwargs=dict(size_hint_y=None, height=self.font_size / 3))) node_id, node, file_path, err_msg = node_file_info if not err_msg: add_import_options(get_txt("export file")) child_maps.append(dict(cls='Widget', kwargs=dict(size_hint_y=None, height=self.font_size / 3))) node_id = '' add_import_options(get_txt("export file")) elif self.verbose: child_maps.append(dict(kwargs=dict( cls='ImageLabel', text=node_id + " error: " + err_msg, square_fill_color=(1, 0, 0, 0.39,)))) if not child_maps: self.show_message(get_txt("neither clipboard nor '{self.documents_root_path}' contains items to import"), title=get_txt("import error(s)", count=1)) return False popup_kwargs = dict(parent=widget, child_data_maps=child_maps, auto_width_child_padding=self.font_size * 3) return self.change_flow(id_of_flow('open', 'alt_add'), popup_kwargs=popup_kwargs)