• Yes it is indeed possible to load a font from a .otf file at runtime (in fact, I implemented such a feature months ago using the ctypes module), but that's never as good as a proper first-party implementation.

  • @dgelessus I know but that works fundamentally different from UIPageViewController. The page view controller pages between different independent UIViewControllers while the scroll view just displays its subviews next to each other.

  • Thanks a lot!

    I have used this to make my script acting a real app by using the “Add to Home Screen” to put my script on the home screen. Without x-button, it looks more like the normal app. However, I have encountered two problems:

    When my home screen shortcut was run again, the pythonista ran again my app but not return to the last screen When I run another Pythonista script on the home screen, it will run on my original script

    Can I detect if my script is now running already and don’t run multiple times to fix problem 1?

    Can I detect that there is another script running and stop Pythonista to load a new one? Or close the old one before loading the new one?

  • Seems like it would be nice to put this into UI form using the dialogs module. Perhaps an updated where fonts can be loaded from a server too. Cool.

  • I managed to kinda achieve this, by using AnyFont to install the otf files as an iOS profile and then editing the EditorFontName key in NSUserDefaults.

    However, this doesn't work 100% well. The syntax highlighting engine uses an italic font for method names.

    @omz do you have an idea how to fix this?

  • you should be able to copy the from ObjCInstanceMethod, and change the objc_class line:

    class ObjCInstanceMethodSuperclass (object): '''Wrapper for an Objective-C instance method. ObjCInstance generates these objects automatically when accessing an attribute, you typically don't need to use this class directly.''' def __init__(self, obj, method_name, allow_property=True): self.obj = obj objc_class = obj.superclass() #modified!! ......

    then create one manually.

  • @Webmaster4o , yeah you are right. @cook is working on something now that will make searching a lot easier in the forum

  • <facepalm/>

    Thanks, @dgelessus

  • pythonista_startup is executed at some point after the app has launched, it is not tied to a particular point in the UIApplication lifecycle (and runs on a different thread).

  • Nice! Very Interesting

  • Added this script to my GitHub repository. It extends the capabilities of the @lukaskollmer script and provides support for editing existing code header comments in scripts. Suggestions and improvements are always welcome.

  • I also followed @JonB suggestion to write a one liner to stop rogue ui.delay scripts, with a wrench script that just called ui.cancel_delays() 😜👍 was actually the most straight forward way

  • Looks like this code does not work properly on 64 bit... i suspect the structure is not sized correctly..

  • I was able to get the source code of the current Safari web page using the following code:

    req = appex.get_web_page_info()

    From there I was able to parse through the HTML using BeautifulSoup.

  • When you look at the source code of the dialogs module, you'll see that the text_dialog() function is actually very simple, and you could make your own version of it like this:

    import ui import os from dialogs import _TextDialogController def my_text_dialog(title='', text='', font=('<system>', 16), autocorrection=None, autocapitalization=ui.AUTOCAPITALIZE_SENTENCES, spellchecking=None, done_button_title='Done', selected_range=None): c = _TextDialogController(title=title, text=text, font=font, autocorrection=autocorrection, autocapitalization=autocapitalization, spellchecking=spellchecking, done_button_title=done_button_title) if selected_range is not None: c.view.selected_range = selected_range c.view.present('sheet') c.view.begin_editing() c.view.wait_modal() return c.text filename = 'myfile.txt' base_name, extension = os.path.splitext(filename) my_text_dialog('Test', filename, selected_range=(0, len(base_name)))

    This is mostly the same code as the original text_dialog(), just with an additional selected_range parameter.

  • Brilliant!

    In fact opening the text file from Pythonista share didn't work and gave some type mismatch error.

    The good news is that sharing from IAwriter directly worked perfectly and produced a markdown to html conversion perfectly!

  • @JonB I know, but I want to access the data other apps send back with the url scheme. I wrote a script that basically adds app-wide x-callback-url support to Pythonista

  • As far as I can tell, Pythonista 3 loads both Python runtimes at startup. The Python 2 runtime (PythonistaKit.framework) is probably the same as the one used by Pythonista 2, so it imports modules from Documents/site-packages instead of Pythonista3/Documents/site-packages. This isn't an optimal solution (the Pythonista 3 UI treats the Pythonista 2 folder as read-only), and a few people have suggested that there should be two site-packages folders for the two Python versions.

    Pythonista 2 has no support for Python 3, so it only loads the Python 2 runtime.

Internal error.

Oops! Looks like something went wrong!