• Dann239

    I didn't know if this fell under share code or questions, as this isn't a question about Python or Pythonista per se.

    I know this is a simple equation. I remember doing something like this in highschool. For the life of me I can't think of the solution or how to search for the solution. Essentially I am changing the .background_color of a tableview via scrollview_did_scroll. I want to move from 1.0 to a target value as the scrollview.content_offset[1] increases, when the offset hits 70 I will change to another action. The target value being the respective values in myrgb.

    This is a snippet of example code. I know we hate snippets, but the entire project looks rather gross as its still a scratchpad draft.

    
    def scrollview_did_scroll(self, scrollview):
        x, y = scrollview.content_offset
        myrgb = (26.0/256, 188.0/256, 156.0/256)
        r = 
        g = 
        b = 
        #At y's origin, r, g, b will be (1.0, 1.0, 1.0)
        scrollview.background_color = (r, g, b)
        
    
    

    posted in Pythonista read more
  • Dann239

    Fantastic explanation. Always above and beyond, thank you omz! I was not that far off. With the exception of the from_color, I was missing the + p from what I conjured up before heading to the forums. I had multiplied to_color and the value of (1.0 - p). I also appreciate the use of min and max as I would have had to debug that when I would've caught it when reaching the end of the scrollview height.

    posted in Pythonista read more
  • Dann239

    When the input comes up Pythonista hangs. The decorator is in place (I assume correctly). Any help is much appreciated! >> Gist Link <<

    posted in Pythonista read more
  • Dann239

    # coding: utf-8
    
    import ui
    import feedparser
    import urllib2
    import webbrowser
    
    
    class MyView (object):
        def __init__(self):
            x, y = ui.get_screen_size()
            self.url_list = []
            url = 'http://appshopper.com/feed/?mode=featured&filter=price&platform=ios'
            self.feed = feedparser.parse(url)
            tblview = ui.TableView()
            tblview.name = 'AppShopper'
            tblview.data_source = self
            tblview.delegate = self
            self.segview = ui.SegmentedControl(frame=((x/2)-125, -45, 250, 30))
            self.segview.segments = ['New', 'Updates', 'Price Drop']
            tblview.add_subview(self.segview)
            naview = ui.NavigationView(tblview)
            naview.present(hide_title_bar=True)
    
        def tableview_number_of_rows(self, tableview, section):
            return len(self.feed['entries'])
    
        def tableview_cell_for_row(self, tableview, section, row):
            feed = self.feed
            html = feed['entries'][row]['summary_detail']['value']
            self.url_list.append(html[html.find('href')+6:html.find('iTunes')-2])
            title = feed['entries'][row]['title']
            thmburl = html[html.find('http', 0, 100):html.find('png', 0, 100)+3]
            beg = html.find('Price')
            end = html.find(',', beg, beg+50)
            price = html[beg+11:end]
            cell = ui.TableViewCell('subtitle')
            cell.text_label.number_of_lines = 0
            cell.text_label.font = ('<system-bold>', 12.0)
            cell.text_label.text = title
            thumb = ui.ImageView()
            ui.delay(thumb.load_from_url(thmburl), 0)
            cell.image_view.image = thumb.image
            cell.detail_text_label.text = price
            return cell
    
        def tableview_did_select(self, tableview, section, row):
            webbrowser.open(self.url_list[row])
    
        def scrollview_did_scroll(self, scrollview):
            segmentindex = self.segview.selected_index
            scry = scrollview.content_offset[1]
            if scrollview.tracking:
                if scry < -75:
                    self.segview.enabled = True
                    self.segview.y = scry+30
                    if scry < -76 and scry > -85:
                        self.segview.selected_index = 0
                    elif scry < -86 and scry > -95:
                        self.segview.selected_index = 1
                    elif scry < -96 and scry > -105:
                        self.segview.selected_index = 2
                else:
                    self.segview.y = -45
                    self.segview.enabled = False
            else:
                pass
    MyView()
    
    

    It's probably a user error but when the code is ran, the images aren't loaded until the cells are scrolled out of view. Any help appreciated!

    posted in Pythonista read more
  • Dann239

    I bought myself a thermodo for entertainment and because they have an sdk.

    The feature request would be too add the ability to 'listen' to mic data.

    posted in Pythonista read more
  • Dann239

    I didn't see anything in the documentation. I have a NavigationView with a TableView. If I push a new TableView, how can I tell when the view on screen changes? More clarification: I have a custom refresh button that disappears when I push a new view, how do I bring it back when the user returns to the initial view in the NavigationView hierarchy?

    posted in Pythonista read more
  • Dann239

    So I see!! Awesome. Thank you.

    posted in Pythonista read more
  • Dann239

    I can alter border widths and colors of the cells I create. How can I access those properties on the autogen cells that fill out the rest of the tableview?

    posted in Pythonista read more
  • Dann239

    Very cool. I will look into implementing this a little later today. Thank you for your help!

    posted in Pythonista read more
  • Dann239

    @JonB I considered that but if feels like a cheap fix. I might end up creating blank cells if this isn't something that isn't planned for any soon to be releases.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!