• ccc

    @Bjucha If the four line test_loc.py above prints None then please try rebooting your iOS device.

    What iOS version? What Pythonista version?

    posted in Pythonista read more
  • ccc

    Filesnames that end in .py are treated differently than all other files to be compliant with Apple's app review guidelines which put constraints on executable code. The workaround is to rename your file my_file.p (removing the y) on your Mac before emailing it and then on your iOS device, add the y back onto the end of the filename.

    posted in Pythonista read more
  • ccc

    Do you have Settings / Privacy / Location Services turned on? Is Pythonista's access to those location services also turned on?

    # loc_test.py
    import location
    location.start_updates()
    print(location.get_location())
    location.stop_updates()
    

    posted in Pythonista read more
  • ccc

    Just change def getLocation(): to def getLocation(sender):

    ui.actions take a parameter which is usually called sender. In this case, Pythonista will set sender to be button1, i.e. the ui element that the user selected.

    import location
    import ui
    
    
    def getLocation(sender):
        location.start_updates()
        label1.text = str(location.get_location())
        location.stop_updates()
    
    
    label1 = ui.Label(border_width=1, frame=(100, 0, 500, 200), number_of_lines=0)
    main_view = ui.View(name='Location', bg_color='#bfff8e')
    main_view.add_subview(label1)
    main_view.add_subview(ui.Button(title='location', frame=(0, 30, 75, 75),
                                    tint_color='black', action=getLocation))
    main_view.present()
    

    posted in Pythonista read more
  • ccc

    Can Swift Playgrounds do it?!?

    posted in Pythonista read more
  • ccc

    Not me... CPython, Pypy, Jython, IPython, Anaconda all run fine on Mac OS X... If you are not using homebrew to install on the Mac it might be difficult but with homebrew, there is no fiddling with config files. Just brew install python python3 pypy pypy3 jython ipython ; brew cask install anaconda. Also there are tons of editors and IDEs that have great Python support: brew cask install atom pycharm-ce sublime-text visual-studio-code... It would be difficult to compete against all of that.

    https://forum.omz-software.com/topic/92/pythonista-for-osx

    posted in General Discussion read more
  • ccc

    Thanks @dgelessus Your view.on_screen checking idea worked well at https://github.com/cclauss/f1_hack/blob/master/discover_view.py#L24. This is a ui for walking the hierarchy of any json data. It would still be much easier if views displayed in ui.NavigationViews received a will_close() or go_back() callback when the user presses <.

    posted in Pythonista read more
  • ccc

    Ideas...

    import scene
    
    # for recording x and y...
    points = []
    
    class MyScene(scene.Scene):
        def __init__(self, in_dot_color=scene.Color(0, 0, 0, 1)):
            super().__init__()
            self.dot_color = in_dot_color
            self.touch = None
            
        def draw(self):
            scene.background(0, 0, 0)
            if self.touch:
                scene.fill('red')
                loc = self.touch.location
                scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
                scene.text('{}, {}'.format(*loc), 'Futura', 20, 100, 50)
                points.append(loc)  # is it be useful to check if loc == prev_loc?
            elif points:
                scene.fill('blue')
                for loc in points:
                    scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
                
        def touch_began(self, touch):
            points.clear()
            self.touch = touch
            
        def touch_moved(self, touch):
            self.touch = touch
            
        def touch_ended(self, touch):
            self.touch = None
    
            
    scene.run(MyScene(), show_fps=True)
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!