omz:forum

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

    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 0
    • Topics 29
    • Posts 72
    • Best 0
    • Controversial 0
    • Groups 0

    Dann239

    @Dann239

    0
    Reputation
    1095
    Profile views
    72
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Dann239 Unfollow Follow

    Latest posts made by Dann239

    • Help with an equation

      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
      Dann239
      Dann239
    • RE: Help with an equation

      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
      Dann239
      Dann239
    • crash/hang console.input_alert

      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
      Dann239
      Dann239
    • load from url issue
      # 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
      Dann239
      Dann239
    • Feature request

      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
      Dann239
      Dann239
    • NavigationView on screen

      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
      Dann239
      Dann239
    • RE: Cell borders

      So I see!! Awesome. Thank you.

      posted in Pythonista
      Dann239
      Dann239
    • Cell borders

      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
      Dann239
      Dann239
    • RE: NavigationView on screen

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

      posted in Pythonista
      Dann239
      Dann239
    • RE: Cell borders

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