I've been working on this and I have basically what I wanted with the graphs and controls. There are still some fundamental things I don't understand though with how 'View' works.
My graph has axes and labels that indicate frequency and dB level. It seems inefficient to draw these static elements each time when they don't change at all. I tried a few things, but found out I need to put statements in the draw() method to get them to work. I'm not sure why this is. Is this just the way it works and all 'static' graphics like this are always part of the draw() everytime? Is there a better standard practice approach to this type of problem?
Here's a simplified example, using the previous code from this thread, showing my ignorance. The black oval would be analogous to the graph axes and labels that aren't changing.
import ui
class testClass(ui.View):
def __init__(self):
self.height,self.width=400,400
self.background_color='white'
self.slider=ui.Slider()
self.slider.center=(200,200)
self.slider.action=self.ss_slide
self.add_subview(self.slider)
path2=ui.Path.oval(300,100,75,30)
ui.set_color('black')
path2.fill() # wondering why this doesn't get drawn
def draw(self):
path=ui.Path.oval(100,100,75,30*self.slider.value)
ui.set_color('orange')
path.fill()
def ss_slide(self,sender):
self.set_needs_display()
u=testClass()
u.present('sheet')