• AddledBadger

    Superb, thanks, working now.

    posted in Pythonista read more
  • AddledBadger

    Hi,

    I'd like to lock a view to portrait on the iPhone, and the code below doesn't work to do that, for me.

    So just to clarify:

    view.present(orientations = ['portrait'])
    

    no longer works?

    What's the preferred way to lock orientation now? Will the documentation get updated? Once the suggestion above has detected the orientation, how can you lock a Navigation Controller to the correct orientation?

    Thanks!

    import ui
    
    global FRAME_WIDTH
    global FRAME_HEIGHT
    message = 'Blah'
    
    def scrollview(message):
      sv = ui.ScrollView() 
      sv.background_color = 'blue'
      FRAME_WIDTH = ui.get_screen_size().width - 2
      FRAME_HEIGHT = ui.get_screen_size().height - 66 
      sv.frame = (1, 1, FRAME_WIDTH, FRAME_HEIGHT)     
      sv.content_size = FRAME_WIDTH, FRAME_HEIGHT + 500 
      view.add_subview(sv) 
        
      tv = ui.TextView()
      tv.background_color = 'red'
      tv.frame = (2, 2, FRAME_WIDTH - 4, FRAME_HEIGHT - 4 + 500) 
      tv.font = ('Palatino', 18)
      tv.editable = False
      tv.text = message
      sv.add_subview(tv)
    
    view = ui.View()                                     
    view.name = 'Demo'                                    
    view.background_color = 'black'                       
    view.frame=(0, 0, 400, 400)
    
    scrollview(message)
    
    view.present(orientations = ['portrait'])
    
    

    posted in Pythonista read more
  • AddledBadger

    Hi,
    Searched the docs and forums but can’t seem to find this. Any help on how to set a ui date picker to a particular value, rather than the current time as it’s displaying in my code at the moment. For example, 8am tomorrow.
    Thanks, Terry

    posted in Pythonista read more
  • AddledBadger

    Hi, moved the script to the root and its been fine since, thanks for the suggestion. Thank, Terry

    posted in Pythonista read more
  • AddledBadger

    @JonB Thanks, I'll give that a try.

    posted in Pythonista read more
  • AddledBadger

    @dgelessus Hi, thanks for your reply. Yes, replaced the the text in question. In the specific case, it's just a string of integers, e.g., 1208060 . Consequently, I don't think there's any unusual characters, but thanks for the suggestion.

    posted in Pythonista read more
  • AddledBadger

    Hi,

    I’m sending blood pressure data, e.g., 1208060 to a pythonista script to graph it. I send the data via a url from Drafts:

    pythonista3://bp/add-blood-pressure-data?action=run&argv=[[Draft]]

    The first time I do this, pythonista says there’s no such script. If I then undelete the draft and run the url again, it finds the script and works fine. Any ideas? Is this likely to be a Drafts issue or a Pythonista one?

    Thanks, Terry

    posted in Pythonista read more
  • AddledBadger

    Excellent, thanks both, I can work with those.

    posted in Pythonista read more
  • AddledBadger

    Hi,

    I’m struggling to find a way to re-factor the following code to have a single method which accepts arguments when called from a Scene UI button, rather than two very similar ones. Any suggestions very welcome! Thanks.

    def show_view_A(sender):
        v = ui.View()
        v.background_color = ‘white’
        v.name = ‘A’
        global location
        location = 1 # used in another method to grab a url
        sender.navigation_view.push_view(v)
        message = get_html(page_info,location_info)
        scrollview(v,message)
    
    def show_view_B(sender):
        v = ui.View()
        v.background_color = ‘white’
        v.name = ‘B’
        global location
        location = 2 # used in another method to grab a url
        sender.navigation_view.push_view(v)
        message = get_html(page_info,location_info)
        scrollview(v,message)
        
    root_view = ui.View()
    root_view.background_color = 'white'
    root_view.name = 'Stuff'
    
    A = ui.Button(title='A')
    B = ui.Button(title='B')
    
    A.action = show_view_A
    B.action = show_view_B
    
    root_view.add_subview(A)
    root_view.add_subview(B)
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!