• zipit

    I think a very substantial portion of the Python users use the language because you do not need a 'completely GUI-driven [...] IDE'. So while a market might be there it stands to question if it is that big.

    I think most users are quite happy with a text editor with some IDE-ish features like the Pythonista editor. The sucess stories of modern editors like sublime text or Atom could be viewed as a proof for such a theory. Especially sublime text is incredibly successful (there are several studies/list on IDE usage).

    posted in General Discussion read more
  • zipit

    You can import any file type into pythonista, you have just to press the share button in your source app, then select pythonista and then import file.

    posted in Pythonista read more
  • zipit

    This is how it should look like/ where the button should be.

    posted in Editorial read more
  • zipit

    It is a bit unclear to me what you are trying to do.

    • An ui.NavigationView is just a (weirdly named) StackPanel
    • You cannot present an instance of a view twice. If you do present your main_view you cannot add it to the nav_view and present it again.
    • You can however present as many views as you want alongside (views are always modal though).

    edit: You can present an instance of a view multiple times as a popover (popovers behave it a bit weirdly). Also nothing should crash if you try to present a view twice. You should just get an exception informing you that the view is already being presented. So if your code is crashing for you, you should probably provide a more extensive code example.

    Your code should look something like this:

    import ui
    
    some_view = ui.View()
    nav_view = ui.NavigationView(some_view)
    nav_view.present('popover')
    

    posted in Pythonista read more
  • zipit

    Hi, then, this not what can I do?...

    Depends on your definition of this. You cannot set the background color but you can set the text color and font. Just follow the link provided by @ccc or use the Pythonista documentation and look up the console module.

    posted in Pythonista read more
  • zipit

    Hi,

    the short and probably most useful answer is : 'No, you cannot.' The longer answer is : Pythonista does not allow custom virtual keyboard shortcuts at the moment. It is however possible to register shortcuts for physical keyboards programmatically - with some limitations/problems (for details see [1]). You can also head over to the recent Python 3.6 and A better keyboard threads where you will find partially a discussion on the very thing you want to do. @omz said he might consider it, but as always things are mostly tied to demand, so if you want to see some virtual keyboard customization you might want to express your whishes there (or more officially on github).

    [1] https://forum.omz-software.com/topic/3156/editor-configurability/2

    posted in Pythonista read more
  • zipit

    console.write_link is function of Pythonistas proprietary console module. You cannot reproduce that behaviour with a standard CPython (aka normal Python) installation since desktop shells usually do not support mouse interaction and therefore there is no such functionallity in CPython. However you can use a different Python platform on your desktop computer. IPython [1] is a very popular Python platform that has an interactive shell. IPython runs in the browser on a platform called Jupyter, so you could run IPython everywhere - on your iPad or iPhone for example.

    [1] https://ipython.org

    posted in Pythonista read more
  • zipit

    Your CheckerBoard class is sitting at position=parent.bounds.center(), so I do not understand what you do mean with 'is not placed at the 0, 0 pixel', it seems to be working as intended expected. If you want the board to sit whithin screen bounds you have to choose your Board center somewhere in the lower left corner.

    posted in Pythonista read more
  • zipit

    Sound mysterious, I am using both using numpy and matlotlib quite regularly. The only things I can say are:

    • The polar plot example runs fine for me in both Python enviroments.
    • What you told us about the exception is a bit confusing since neither numpy nor matplotlib have an init.py file afaik (they have both multiple __init__.py files though) edit: I just realized that you were probably only struggling with the forums markdown interface since your init.py is printed bold (you have to escape the first two underscores: \_\_init__.py).
    • The polar plot example does not import anything from numpy.random and neither does matplotlib.pyplot.

    I cannot think of anything obvious, I think you will have to describe more precisely (actually copy and paste the full trace of the exception) what you are doing and what is going wrong.

    posted in Pythonista read more
  • zipit

    @omz

    Jeah, I did not state that very clearly. Was I meant was that since they forbid using deprecated methods the (kinda) opposite - future imports - are also not a good idea as mixing versions goes against the zen-priniciple concise and clear.

    edit: And what is common is IMHO not an indicator of what is good. People also use cryptic bit shifts, overly complex list comprehensions, etc. all over the place and they are also not good.

    But that is just my opinion. But you are right there are cases where you need future.

    posted in Pythonista read more
  • zipit

    My approach would be to put from future import print_function

    I do not want to be rude, but using future is IMHO bad advice ( especially for a beginner). IMHO it also goes against the Google Python style guide lines, which while not speaking out explicitly agianst future do forbid the use of deprecated methods and unusal styles in multiple guide lines.

    posted in Pythonista read more
  • zipit

    As far as I know Pythoniastandoes not expose a specific control (or View in Pyhthonistas terms) for that. There is also nothing like 4sided borders so that you could draw a (0,0,0,1) border. I did it recently by just adding an ui.View with thei height of 1 in the places I did need a border.

    posted in Pythonista read more
  • zipit

    You are most likely running the script on your mac on Python 2.7 and on the iPad on Python 3.5 (Pythonistas default). With Python 3.0 the Python 2.xprint keyword got demoted to a function and therefore does now require parentheses to be invoked. Long story short, you can either:

    • set Pythonista to Python 2.7 in the settings golbally
    • or just for one instance by long pressing the play button
    • or you could add something called a shebang line, forcing python into Python 2 mode from code, the first line of your script has to be #!Python2
    • or just change the code to print (median (1,3,2)), which in this case will also run just fine under Python 2.

    posted in Pythonista read more
  • zipit

    Hi,

    had some time to poke in editor around. editor.get_theme_dict() does exactly what I want. It should be made officially public (as it is already not internal, but doesn't appear in the autocomplete for some reason). Some mentioning in the docs would also be nice.

    posted in Pythonista read more
  • zipit

    Thanks again, I'll see what I can figure out. About the quirks - This little setup shows what I consider quirky - not everything is being styled correctly.

    import editor
    import ui
    import time
    
    class SomeUi(ui.View):
        def __init__(self):
            self.frame = (0, 0, 500, 470)
            self.table_view = ui.TableView(frame=(10, 10, 480, 400))
            self.text_view = ui.TextField(frame=(10, 420, 480, 40))
            self.add_subview(self.table_view)
            self.add_subview(self.text_view)
            editor.apply_ui_theme(self)
    
    def wait(dt=1.0):
        t = time.perf_counter()
        while time.perf_counter() - t < dt:
            pass
    
    op = SomeUi()
    op.present('sheet')
    wait(3)
    op.close()
    wait(1)
    editor.present_themed(op, style='sheet')
    

    In a more complex setup I have also experieneced that when reading colors from an ui element styled with the editor.apply_ui_theme() before any ui.View.layout() has ran can give you back a wrong color (-1, 1, 1, 1).

    posted in Pythonista read more
  • zipit

    @omz

    thanks, that did work (Python really has a lib for everything):

    import plistlib
    
    path = '/private/var/mobile/Containers/Shared/AppGroup/CB0CD8AB-6A20-4ECC-8312-B0822DFFD9A1/Library/Preferences/group.pythonista.plist'
    
    with open(path, 'rb') as f:
        data = plistlib.load(f)
    
    print(data)
    

    The file however does not contain what I did hope for. Any chance you could shed some light on where the currently active theme is being stored? I know where the theme json files are stored, but I am sort of stumped on how to get the active theme.

    Ps: I am aware of the theme related editorfunctions, but these have it quirks, which is why I am trying to do it by hand.

    posted in Pythonista read more
  • zipit

    Hi,

    does anyone know how Pyhtonistas plist files are being encoded? I always assumed that plists are just XML files in UTF-8 encoding. I however do fail reading pythonistas plist files, specifically :

    private/var/mobile/Containers/Shared/AppGroup/{Pythonistas app hash}/Library/Preferences/group.pythonista.plist

    I do keep getting encoding exceptions: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 8: invalid continuation byte
    I did try ascii, utf-8, and utf-16 with no luck.

    posted in Pythonista read more
  • zipit

    You have to cast the ui.Image into a scene.Texture. Something like that:

    return scene.Texture(ctx.get_image())

    posted in Pythonista read more
  • zipit

    I do not know much about the ui module but as far as I know the auto-resize feature of it has its limits.

    • each ui.View has a flex field which allows some sort auf auto-resizing in relation to its parent. But it doesn't allow complex dependencies like for example XAML does.
    • each ui.View also has a layout() method which is called after its parent has been resized. Here you could intervene and adjust the layout of your ui node when its parent (the main form) has been resized.
    • edit: technically you could also implement a general solution (an ui.viewlooking at its children and positioning and resizing them according to an algorithm) but that would require to implement stuff like min_size for everything.
    • if I remember correctly there are also some constants floating around in the ui module (check at the bottom of the doc) that tell you about the orientation and type of device your script is running on.

    posted in Pythonista read more
  • zipit

    As for the # character, where would you put that? I can't really make the keys on the extra row much smaller, and I don't really see a key there that I'd remove to replace it with #.

    Actually I had not really thought about it. I had something like a modifier key in mind. I like the fact that the new keyboard lost a row but the hashtag character is IMHO quite essential for python. The word character keys do look quite empty regarding modifer keys, but I do not know if you can modify them.

    I personally never did care much about snippets (I think I was a bit unclear there, I actually meant shortcuts to little python scripts interacting with the editor: autopep8, autodocstring, linting etc. - I am lazzy, I use them alot), but since you mentioned them: An alternative route for shortcuts could be to allow to execute a python script instead of a snippet. Basically a command palette that would appear in the auto-complete bar. It is always a little bit of a hassle to use editor scripts atm.

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!