omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. zipit

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 2
    • Topics 5
    • Posts 59
    • Best 7
    • Controversial 0
    • Groups 0

    zipit

    @zipit

    10
    Reputation
    1528
    Profile views
    59
    Posts
    2
    Followers
    0
    Following
    Joined Last Online

    zipit Unfollow Follow

    Best posts made by zipit

    • RE: How do I convert a ui.Image into a scene.SpriteNode?

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

      return scene.Texture(ctx.get_image())

      posted in Pythonista
      zipit
      zipit
    • RE: Initial working directory?

      You could also just use os.path.dirname(__file__) - assuming your interpreted file lies in your Book Notes folder. This would have the advantage of not having to hard code any folder name.

      posted in Pythonista
      zipit
      zipit
    • RE: Reminders - Delete Calendar (List)

      Works fine for me. Your exception suggests that in your enviroment the functiondelete_calendar() in the namespace reminders has been overwritten with a string of the same name. You should investigate that with the inspector when your exception is raised.

      Or more likely ... you have missed a parenthesis while copying the snippet which often completely confuses the interpreter.

      posted in Pythonista
      zipit
      zipit
    • RE: Possible to change menubar/header color and font for ui.view?

      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
      zipit
      zipit
    • RE: 1D Coordinates?

      Ploting and calculus can be done with numpy and matplotlib. Both are available in pythonista by default.

      import numpy
      from matplotlib import pyplot
      
      #100 linear samples between -10 and 10
      x = numpy.linspace(-10, 10, 100)
      #draw a red line through f(x) = x
      pyplot.plot(x, x, 'r-')
      #draw a blue dotted line through f(x) = sin(x)
      pyplot.plot(x, numpy.sin(x), 'b--')
      #show the plot
      pyplot.show()
      
      posted in Pythonista
      zipit
      zipit
    • RE: Pure Python external libs

      In order to save space in device (iPhone), can I delete freely from Pythonista some pure python external libraries that I never use [...]

      Hm, pythonista is taking about 450 MB with some installed extra libraries for me. Sympy 1.0 is is about 4 MB big. I do not want to be rude, but I somehow fail to see how this going to make any impact on a device that measures its storage space in GB.

      posted in Pythonista
      zipit
      zipit
    • RE: draw ui.Path within the coordinate system of a node

      Okay, thanks. I gave the thread a more meaningful title. I cannot provide a full example as my code relies on other stuff, but here is a snippet how I did solve the problem now (a bit clunky). Maybe it will help someone in the future. I wrote two comments so that the code does make some sense.

      def draw_line(self):
              '''
              '''
              if self.line is not None:
                  self.line.remove_from_parent()
              minx, miny = None, None
              path = ui.Path()
              path.line_width = 2
              # self is a pythonista node. self.anchors are some phythonista node 
              # objects that are children of self. We want to draw a line through all
              # these anchors within the coord system of self.
              for i, anchor in enumerate(self.anchors):
                  p = anchor.position
                  # get/update the lower left corner minimum
                  minx, miny = (p.x if minx is None else min(minx, p.x),
                                p.y if miny is None else min(miny, p.y))
                  if i == 0: path.move_to(p.x, -p.y)
                  else: path.line_to(p.x, -p.y)
              # the offset(position) of our node has to be the lower left corner
              # point plus the center vector of our path
              self.line = ShapeNode(path,
                                    stroke_color='green',
                                    fill_color='transparent',
                                    position = (minx + path.bounds.w * .5,
                                                miny + path.bounds.h * .5),
                                    parent=self)
      
      posted in Pythonista
      zipit
      zipit

    Latest posts made by zipit

    • RE: Import Scripts written on Mac/PC to Pythonista?

      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
      zipit
      zipit
    • RE: snippets button

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

      posted in Editorial
      zipit
      zipit
    • RE: Possible to change menubar/header color and font for ui.view?

      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
      zipit
      zipit
    • RE: Colorama, see characters in color?

      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
      zipit
      zipit
    • RE: Comment Line shortcut?

      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
      zipit
      zipit
    • RE: What is command for console.write_link() on Python on PC?

      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
      zipit
      zipit
    • RE: Child nodes are not anchored within their parent node

      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
      zipit
      zipit
    • RE: import numpy fails

      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
      zipit
      zipit
    • RE: Running a program on Pythonista and Sublime Text.

      @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
      zipit
      zipit
    • RE: Running a program on Pythonista and Sublime Text.

      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
      zipit
      zipit