@mikael Thanks for the pull to refresh example. I really appreciate the help. I had a couple issues. The biggest issue was only being able to refresh once after the view is loaded. The second Issue was when pulled too far down, the refresh function was called multiple times. I think I solved these issues. I attached the solution I came up with below.
import ui, sound class scrollViewDelegate: maxPull = -100 def __init__(self): self.refresh = False def scrollview_did_scroll(self, scrollview): x, y = scrollview.content_offset if y <= 0: delta = max(y, self.maxPull) / self.maxPull if (y <= self.maxPull and not scrollview.tracking and scrollview.decelerating and not self.refresh): scrollview['refresh_bg'][ 'refresh_label'].text_color = 0.50, 0.50, 0.50, delta self.contentRefresh() elif (y <= self.maxPull - 10 and scrollview.tracking and not scrollview.decelerating and not self.refresh): scrollview['refresh_bg']['refresh_label'].text = 'Release to refresh' scrollview['refresh_bg'][ 'refresh_label'].text_color = 0.50, 0.50, 0.50, delta elif (y >= self.maxPull - 10 and scrollview.tracking and not scrollview.decelerating and not self.refresh): scrollview['refresh_bg']['refresh_label'].text = 'Pull to refresh' scrollview['refresh_bg'][ 'refresh_label'].text_color = 0.60, 0.60, 0.60, delta def contentRefresh(self): self.refresh = True sound.play_effect('ui:click3') #print('refreshing') ui.delay(self.contentDidRefresh, 0) def contentDidRefresh(self): self.__init__() w, h = ui.get_screen_size() sv = ui.ScrollView() sv.name = 'Scrollview' sv.always_bounce_horizontal = False sv.always_bounce_vertical = True sv.directional_lock_enabled = True sv.scroll_indicator_insets = (10, 0, 10, 0) sv.bounces = True sv.paging_enabled = False sv.indicator_style = 'black' sv.scroll_enabled = True sv.background_color = 1.0, 1.0, 1.0 sv.content_inset = (0, 0, 0, 0) sv.content_size = (w - 10, h*2) sv.delegate = scrollViewDelegate() rb = ui.View() rb.name = 'refresh_bg' rb.alpha = 1.0 rb.background_color = 0.90, 0.90, 0.90 rl = ui.Label() rl.name = 'refresh_label' rl.alpha = 1.0 rl.alignment = ui.ALIGN_CENTER #rl.background_color = 'white' rl.text = 'Pull to Refresh' rl.text_color = None rl.font = ('<system>', 14) rb.add_subview(rl) sv.frame = (0, 0, w, 0.5) rb.frame = (0, -600, sv.width, 600) rl.frame = (0, rb.height - 32, sv.width, 32) sv.add_subview(rb) sv.present('fullscreen')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.