• 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
  • Dann239

    Does 'currently' suggest it may be possible later on?

    <rant>

    Sorry? Sir, you have crafted the most beautiful and functional piece of software I have ever used. I bought Pythonista before I knew how to print hello world. You are the reason I've spent hours and hours on end until 5am in the morning night after night... I've changed my career goal because of Pythonista. Sorry... no omz THANK YOU!

    <\rant>

    posted in Pythonista read more
  • Dann239

    I would like the developers input on this but I believe this still falls under the uncompiled code category. The reason we are stuck with a Dropbox sync script is because Apple didn't like the idea of syncing uncompiled code. I think Codea suffers from a similar disability?! A better sync option is much needed. I've resorted to archiving my script library and using Dropbox sync script to send over a single file as it struggled with folders.

    posted in Editorial read more
  • Dann239

    A couple things. Your two loops. <code> while 100: </code> will always loop and never break it is a true statement. It needs a point of reference. So you would say that while something is below or above or not equal to this integer, do the next steps. Your if statement is outside the previous loop. If the first loop were to execute as you would want, a would never equal twenty when the first loop decided to break. So I incorporated the if loop in the while loop to catch the number twenty. There are probably prettier ways of doing this. But here is my answer:

    import console
    from random import random<p>
    a = 1
    while a < 100:
        if a == 20:
            console.set_color(random(), random(), random())
        else:
            console.set_color()
        print('hello '+str(a))
        a += 1
    

    posted in Pythonista read more
  • Dann239

    Thank you Pacco. My Dropbox has been super screwy as well. This is useful.

    posted in Pythonista read more
  • Dann239

    Thank you JonB! Awesome. I will implement it tonight. "you da real mvp"

    posted in Pythonista read more
  • Dann239

    User input is required. I'm not having any luck with a delay. I've bumped it to a whole second and I still get hangs. I took out the animations from the function and still to no avail. Thanks for the tip.

    Edit: more info

    Let me increase the mystery... As it sits, the input dialogue functions. If you simply trigger it and do not attempt to add text the result is an empty entry in the TableView. If you trigger the keyboard in the input dialogue you will cause a hang.

    posted in Pythonista read more
  • Dann239

    Check out the Photos module in the Pythonista documents. More specifically, photos.get_metadata.

    posted in Pythonista read more
  • Dann239

    Default frame for left button items?

    Also, since I'm creating a ui.Button object and placing it in that spot... In a navigation view how can I tell if I'm back at the home view? For example, I hide the button when I move into a new table (tableview_did_select) and how do I know when I'm returning to the previous table?

    posted in Pythonista read more
  • Dann239

    Are you using a Dropbox script to sync? A bug in the one I'm using will occasionally duplicate a folder and rename it using a lowercase title. The contents of the original folder deleted and its contents placed In that new folder. 'Projects' folder gets duplicated and the contents now placed in the new folder 'projects'. I've seen code disappear in that exchange as well.

    tldr: check all your folders!

    posted in Pythonista read more
  • Dann239

    Check out the TextField.delegate documentation. This might be what you are looking for.

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!