• dgelessus

    If you're on an iPad, there should be an undo button in the bottom row of the extended keyboard, as @bennr01 says. If you don't see that button (or the entire row), you need to go into the iOS keyboard settings and enable the "shortcut bar" (or whatever it's called in your device language). In addition, the iPad onscreen keyboard has built-in "keys" for undo and redo, which can be found in the ".?123" and "#+=" modes of the keyboard.

    If you're on an iPhone (or iPod touch), I think the only way to get an undo function is by shaking the device. (Yes, it's really silly. I'm sure ten years ago everyone thought it was a great idea.) If you have one of the larger iPhones, I think you also get extra buttons (including undo) on the onscreen keyboard when in landscape mode. I have an iPhone SE, so I don't know where and how the extra buttons are available (except that I don't have them :P).

    posted in Pythonista read more
  • dgelessus

    If you open a new tab in the preview/console panel, it should have an address bar and the usual browser buttons (back/forward, bookmarks, etc.) in the toolbar at the top. To use the browser you only need to type something in the address bar, there's no separate button to go into "browser mode". (If you don't see the address bar, can you post a screenshot of how it looks for you?)

    posted in Editorial read more
  • dgelessus

    If you want to show a view as a panel tab, use v.present("panel"). There can be multiple "panel" views at once, so if you present your own view as a panel it will not affect Stash (or the other way around).

    If you want to run your code so it doesn't block the main Python console, you need to run it in a background thread using the threading module. (I think Stash runs all of its code in background threads.)

    posted in Pythonista read more
  • dgelessus

    Try dialogs.share_text(editor.get_text()), I think that does what you're looking for. (It shares the text as if you pressed "Share..." on a text selection, rather than sharing the file.)

    posted in Pythonista read more
  • dgelessus

    The Pythonista app template hasn't been updated for Python 3 sadly, so the best option might be to backport your script to Python 2... You can use https://pypi.org/project/3to2/ to do some of the backporting automatically (I haven't tried it myself though).

    posted in Pythonista read more
  • dgelessus

    There was also some discussion a while back on using some sort of mocking framework, which I forget the name of, to "extend" built in types

    That sounds like @Webmaster4o's ui2 perhaps? Specifically the subclassing module.

    posted in Pythonista read more
  • dgelessus

    Note: in Python 3 you need to use input, but in Python 2 you need to use raw_input to do the same thing. (Python 2 also has an input function, but that does something different.)

    If you're a beginner, I would stronly recommend using Python 3 and not Python 2. Python 3 the current version of the language, has some nice new features, and has less strange/confusing behavior than Python 2 in some places.

    posted in Pythonista read more
  • dgelessus

    1. This is explained in general under "Overview" > "Geometry", and the exact attributes of all geometric types are listed under "Geometry Types". The scene.Scene.size docs never say that the attribute is a scene.Size, but based on the attribute name it's not that hard to guess (and if you're unsure, you can confirm it by printing out the attribute).
    2. Yes, under scene.run it's never explained exactly what running the scene does (although the scene.Scene docs explain what options you have to display a scene, and lists scene.run as one of them). The tutorial also tells you that you need to pass your scene to scene.run to display it. So yes, the docs of scene.run could be improved, but it's far from "not explained anywhere".
    3. This is literally explained in the scene.run docs: "By default, the scene's update() method is called 60 times per second." Under Scene.update it also says "Do not call this method directly; it is called exactly once per frame, so long as the scene is presented in a view and is not paused." Again, the docs could perhaps be improved, but there is not "absolutely NO mention" that run creates a loop.

    If you want to give feedback on the documentation, that's great, everyone benefits from that, but it would be really nice if you could do so in a way that isn't completely exaggerated. If you don't want to use scene, that's your choice of course, no one will stop you.

    posted in Pythonista read more
  • dgelessus

    Many of the Pythonista-specific modules are written in C (or Objective-C) and compiled, so you can't see the source code for them. To find out if that's the case, import and look at the module in the Python console:

    >>> import console
    >>> console
    <module 'console' (built-in)>
    

    The "built-in" part means that the module is compiled and not written in Python.

    Some modules (like scene) are actually made of two modules: the main module is written in Python, and it imports a second module that is compiled. For example, you can see the location of the scene module's Python code:

    >>> import scene
    >>> scene
    <module 'scene' from '/var/containers/Bundle/Application/.../Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/scene.py'>
    

    However if you look into the scene.py file, you can see that it imports a _scene2 module, which is compiled:

    >>> import _scene2
    >>> scene2
    <module '_scene2' (built-in)>
    

    That means you can read the parts of the scene module that are written in Python (scene), but not those that are compiled (_scene2).

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!