def post_submission(self) -> None: client = self.get_client() blog = dialogs.list_dialog( title='Submissions from which blog?', items=constants.BLOGS, multiple=False, ) submissions = client.submission(blog) dialogs.text_dialog(title='', text=pformat(submissions))
def post_reblog_original(self) -> None: client = self.get_client() post = self.get_post_from_post_id() tags = post.get('tags') reblog_key = self.get_reblog_key(post) comment = dialogs.text_dialog(title='Enter comment:', ) state = dialogs.list_dialog( title='Reblog state:', items=constants.POST_STATES, ) for blog in constants.BLOGS: response = client.reblog( blog, id=self.post_id, reblog_key=reblog_key, comment=comment, tags=tags, state=state, ) if not response.get('id'): dialogs.alert(title='Error', message=pformat(response)) print( 'Reblogged to all blogs:', pformat(constants.BLOGS), )
def do_solve(self): testgame = Sudoku(self.game) strgame = str(testgame).replace(',', '') pre = testgame.board[:] if not testgame.hsolve(): sound.play_effect('game:Crashing') self.label.text = "Solve Failed" else: strsoln = str(testgame).replace(',', '') # Prompt or default title for new db entry, always update rating and rating string if self.save_on_solve: savtitle = self.game_title if self.game_title is not None else time.ctime( ) title = text_dialog("Title this game", savtitle) if title is None: title = savtitle self.db.save(strgame, strsoln, testgame.log, title) self.save_on_solve = False self.label.text = "Success! " + testgame.log + "[Saved]" else: self.db.annotate(strgame, testgame.log, None) self.label.text = "Success! " + testgame.log bd = testgame.board[:] for i in range(81): if bd[i] != pre[i]: self.game.fill(i, bd[i]) self.sync_to_game() self.add_undo_block(pre, self.game.board)
def addsnippet(self, sender, title=None, contents=None): if title == None: title = dialogs.input_alert(title='Title Entry', message='Please enter a title') if contents == None: contents = dialogs.text_dialog('Contents Entry') db = dbmanager() db.insert_snippet(title=title, contents=contents) self.updatesnippetslistview()
def tweet(text): all_accounts = twitter.get_all_accounts() if len(all_accounts) >= 1: account = all_accounts[0] # get main account text = dialogs.text_dialog( text=text, autocapitalization=ui.AUTOCAPITALIZE_SENTENCES) if text: twitter.post_tweet(account, text, parameters=None) console.hud_alert('Tweet Posted!', 'success', 1.5) else: console.hud_alert('Canceled', 'error', 1.5)
def post_new_comment(self, sender): text = dialogs.text_dialog() if text: try: glv.PARSER.post_new_comment(self.info.get('url'), text) except: console.hud_alert('Error', 'error') else: info = glv.PARSER.get_gallery_infos_only(self.info.get('url')) self.info.update(comments=info['comments']) self.refresh()
def snippetselectaction(self, snippet): selection = dialogs.alert(title='Action', message='Please select your action', button1='Copy to clipboard', button2='Create new file', button3='Show/Edit Snippet contents') if selection == 1: clipboard.set(snippet[2]) elif selection == 2: title = dialogs.input_alert(title='Filename Entry', message='Please enter a title for your new file, to insert in a folder foldername\filename.py') self.make_file(filename=title, contents=snippet[2]) elif selection == 3: dialogs.alert(title='Message',message='Press\nDone - to save content changes \nX - to cancel and not save', button1='Ok', hide_cancel_button=True) contents = dialogs.text_dialog(title=snippet[1], text=snippet[2]) if not contents == None: dbmanager().edit_snippet(contents = contents, title=snippet[1], snippetid=snippet[0]) self.updatesnippetslistview()
def main(): base_theme_name = get_current_theme_name() default_theme_path = get_theme_path(base_theme_name) with open(default_theme_path) as f: theme_json = f.read() edited_theme = dialogs.text_dialog('Edit Theme (%s)' % base_theme_name, theme_json, font=('Menlo', 14), autocorrection=False, spellchecking=False, autocapitalization=ui.AUTOCAPITALIZE_NONE, done_button_title='Apply') if not edited_theme: return user_theme_path = os.path.join(get_user_themes_path(), 'MyTheme.json') with open(user_theme_path, 'w') as f: f.write(edited_theme) set_theme('User:MyTheme') dialogs.hud_alert('Theme saved')
def action_change_key(sender=None): """Input the WordNik API key with a dialog box.""" try: with open(CONFIG_FILE, 'r') as file: config = json.load(file) except (FileNotFoundError, json.JSONDecodeError): config = {} d = dialogs.text_dialog(title='WordNik.com API Key', text=config.get('wordnik_api_key') or '') if d is not None: config['wordnik_api_key'] = d with open(CONFIG_FILE, 'w') as file: json.dump(config, file) define.check_wordnik_key()
def main(): input = ' '.join(sys.argv[1:]) or dialogs.text_dialog() if input: referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input) rootVC = UIApplication.sharedApplication().keyWindow().rootViewController() tabVC = rootVC.detailViewController() referenceViewController.setTitle_("Definition: '{}'".format(input)) referenceViewController.setPreferredContentSize_(CGSize(540, 540)) referenceViewController.setModalPresentationStyle_(2) #tabVC.addTabWithViewController_(referenceViewController) tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
def btn_secret_push(self, sender): tmpsecret = self.secret if tmpsecret is None: tmpsecret = '' tmpsecret = dialogs.text_dialog( title='Set secret', text=tmpsecret, autocorrection=False, autocapitalization=ui.AUTOCAPITALIZE_NONE, spellchecking=False) if tmpsecret is None: return tmpsecret = tmpsecret.strip() if tmpsecret: keychain.set_password(appname, appname, tmpsecret) self.secret = tmpsecret self.activate_button() else: keychain.delete_password(appname, appname) self.secret = None self.deactivate_button()
def more_about_project(src, project): import dialogs res = dialogs.list_dialog(items=["Velocity", "Epics", "Search"]) if not res: return if res == "Epics": epics_page(src, project) if res == "Velocity": velocity_issues(src, project, 30) if res == "Search": from dialogs import text_dialog txt = text_dialog() if not txt: return search_for_stories(src, project, txt)
def main(): resp = console.alert('Alert!', 'Choose File Extension', '.py', '.pyui', hide_cancel_button=False) if resp == 1: ext = '.py' elif resp == 2: ext = '.pyui' text = clipboard.get() assert text, 'No text on the clipboard!' filename = dialogs.text_dialog(title="What's your script called?") console.clear() print('Wait a Moment Please!') filename = save(filename.strip().lower().replace(" ", "_"), text.strip(), ext) console.set_font('Futura', 16) save_path = str( "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/downloads/scripts/" + filename) print('Done!\nFile Saved as:\n\n' + filename + "\n\nin:\n\n" + save_path) editor.open_file(save_path, new_tab=True)
def main(): input_dict = None if len(sys.argv) >= 2 and sys.argv[1] == 'quick': if appex.is_running_extension() and re.search('http*:\/\/[^\s]+', appex.get_attachments()[0]) is None: input_dict = appex.get_attachments()[0] else: clip = re.search('^(?!http)+', clipboard.get()) if clip != None: input_dict = clipboard.get() input = input_dict or dialogs.text_dialog() if input: referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input) rootVC = UIApplication.sharedApplication().keyWindow().rootViewController() tabVC = rootVC.detailViewController() referenceViewController.setTitle_("Definition: '{}'".format(input)) referenceViewController.setPreferredContentSize_(CGSize(540, 540)) referenceViewController.setModalPresentationStyle_(2) #tabVC.addTabWithViewController_(referenceViewController) tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
settings_dict = json.load(in_file) # your data has been read in from file into a new dict print(settings_dict) except IOError: print("No settings found") settings_dict = { 'local': {} } name = None local = settings_dict['local'] if 'ios_device_name' in local: name = local['ios_device_name'] else: name = dialogs.text_dialog(title='name this device', text='').lower() local['ios_device_name'] = name items = [ { 'title': 'name' }, { 'title': 'address' }, ] source = ui.ListDataSource(items) dialogs.edit_list_dialog(title='remote machines', items=source, move=True, delete=True) print name #os.path.isfile(path) print(settings_dict) _stash('ls')
def get(self, name): value = keychain.get_password(table(), name) if not value: value = dialogs.text_dialog('%s ?' % name) self.put(name, value) return value
from collections import Counter from console import hud_alert, input_alert import dialogs count_text = dialogs.text_dialog(title='Enter text to count', text='') letter = input_alert('Counter', 'Enter a letter or number to count', '', 'Count', hide_cancel_button=False) counter = Counter(count_text) hud_alert(('There are %s total %s\'s') % (counter[letter], letter), 'success', 3)
import dialogs, clipboard txt = clipboard.get() edited_text = dialogs.text_dialog(title='View and edit clipboard text', text=txt) if edited_text != txt: clipboard.set(edited_text) #dialogs.share_text(clipboard.get())
import json import requests # default settings, overwritten if choosen branch is master is_production = False # user prompt branch = console.alert('Deployer','What do you want to deploy?','master','develop','Other branch...') if branch == 1: is_production = True branch = 'master' # actually not used by the server, only for script correctness elif branch == 2: branch = 'develop' # IMPORTANT: change this to your integration branch elif branch == 3: branch = dialogs.text_dialog(title='Insert exact branch name:') branch = branch.split('\n')[0] # todo: add confirmation: you really want to deploy (branch name) to testing dir? else: exit() console.hud_alert('deploying '+branch+'...') # data and configuration api_token = "" # not implemented yet config = { "action": "deploy", "deploy_branch": branch, "is_production": is_production }
def testf(self, tableview, section, row): dialogs.text_dialog(text="{}_{}_{}".format(tableview, section, row))
) from logg import * from tmz import * import urllib.parse clips = str(clipboard.get()) text = editor.get_text() s = editor.get_selection() selection = text[s[0]:s[1]] search_url = 'http://stackoverflow.com/search?q=' if len(selection) > 0: query = urllib.parse.quote(selection) else: selection = dialogs.text_dialog(title="Stack Overflow Search", text=clips) query = urllib.parse.quote(selection) filename = editor.get_path().split("/")[-1] folder_path = '/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/notes/' subfilepath = str(folder_path + filename + " - notes.md") with LoggingPrinter(submodule=subfilepath): print("####stack overflow search") print() print("+ **datetime:** ", tmz()) print("+ **so.query:** ", str("[" + selection + "](" + search_url + query + ")")) print("_____")
def tableview_did_select(self, tableview, section, row): dialogs.text_dialog('Full Text', tableview.data_source.comments[section]['comment'])
def edit_post(self, sender): old_text = self['textview'].text text = dialogs.text_dialog(text=old_text) if text and text != old_text: glv.PARSER.post_edited_comment(self.url, self.comment['comment_id'], text) self['textview'].text = text
if choose_option == 3: new_content = selected_text elif choose_option == 2: new_content = clipboard.get() elif choose_option == 1: new_content = text else: sys.exit() #if choose_option == "Selection": # new_content = selected_text #elif choose_option == "Clipboard": # new_content = clipboard.get() #elif choose_option == "Script": # new_content = text #else: # sys.exit() try: new_name = str(dialogs.text_dialog(title="New Script Name:", text=current_filepath) + ".py") editor.make_new_file(new_name, new_content) editor.open_file(new_name, new_tab=True) except TypeError: sys.exit() except FileNotFoundError: print("To save to iPhone ~/Documents, don't include any file path") sys.exit()
import twitter, ui, dialogs, console all_accounts = twitter.get_all_accounts() if len(all_accounts) >= 1: account = all_accounts[0] # get main account text = dialogs.text_dialog(title='Tweet a Tweet', autocapitalization=ui.AUTOCAPITALIZE_SENTENCES) if len(text) < 140: twitter.post_tweet(account, text, parameters=None) console.hud_alert('Tweet Posted!', 'success', 1.5) else: console.hud_alert('Exceeded Character Limit', 'error', 1.5)
def add_note(self, btn): title = dialogs.input_alert('Title') text = dialogs.text_dialog(title=title, autocorrection=True, done_button_title='Save') pb.add_note(title, text, 'qtey uenr')
jdata = json.loads(r2.text) soup = BeautifulSoup(r.content, "html.parser") tables = soup.findAll("table")[1] rows = tables.findAll("tr")[2] corona_val_list = list() for i, val in enumerate(rows.findAll("td")): corona_val_list.append(int(val.text)) pref_data = "和歌山" #+ soup.select("#content > div > h5:nth-child(13) > strong")[0].text positive = "現在陽性の方:" + str(corona_val_list[0]) infected = "新規感染者:" + str(corona_val_list[-2]) total = "累計:" + str(corona_val_list[-1]) jp_data = '日本' jp_positive = '現在陽性の方:' + str(jdata['data'][0]['active']) jp_infected = "新規感染者:" + str(jdata['data'][0]['todayCases']) jp_total = "累計:" + str(jdata['data'][0]['cases']) dtext = jp_data + '\n\n' + jp_positive + '\n' + jp_infected + '\n' + jp_total + '\n\n' dtext2 = pref_data + '\n\n' + positive + '\n' + infected + '\n' + total text = dtext + dtext2 now = datetime.datetime.now() dialogs.text_dialog(title='COVID-19 ' + str(now.month) + '/' + str(now.day), text=text)
def tweet(account, text, param=None): if len(text) < 140: twitter.post_tweet(account, text, parameters=param) console.hud_alert('Tweet Posted', 'success', 1.5) else: console.hud_alert('Exceeded Character Limit', 'error', 1.5) assets = photos.pick_asset(title='Pick Some Assets', multi=False) params = { 'media_id_string': assets.local_id, 'image_type': assets.media_type, 'image': { 'w': assets.pixel_width, 'h': assets.pixel_height } } all_accounts = twitter.get_all_accounts() if len(all_accounts) >= 1: account = all_accounts[0] text = dialogs.text_dialog(title='Input Tweet') if text: tweet(account, text + ' #my_hash_tag', params) else: console.hud_alert('User Cancelled') # --------------------
def text_dialog_action(sender): print(dialogs.text_dialog('text dialog', text='Testing text dialog'))
sys.path.append('/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/util/hellpaz') from logg import * from tmz import * import urllib.parse clips = str(clipboard.get()) text = editor.get_text() s = editor.get_selection() selection = text[s[0]:s[1]] search_url = 'http://google.com/search?tbs=qdr:y&q=' if len(selection) > 0: query = urllib.parse.quote(selection) else: selection = dialogs.text_dialog(title="Past Year Google Search", text=clips) query = urllib.parse.quote(selection) filename = editor.get_path().split("/")[-1] folder_path = '/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/notes/' subfilepath = str(folder_path + filename + " - notes.md") with LoggingPrinter(submodule=subfilepath): print("####past year google search") print() print("+ **datetime:** ", tmz()) print("+ **g.query:** ", str("[" + selection + "](" + search_url+query + ")")) print("_____")