I'm using boilerplate code from the docs (http://omz-software.com/pythonista/docs/ios/ui.html#building-custom-views) and added just a label to display touch location. No matter what I define as the initial points of three label, it is always a fixed size on the screen.
No matter what settings I create the label, it is always defaulted to (0,0) and a small width. I do want it to be full width, the values shown here are for testing.
import ui
class MyView (ui.View):
def __init__(self):
self.info=ui.Label(
self.height/2,
self.width/2,
self.width/2,
self.height/4)
self.info.corner_radius=9
self.info.alignment=ui.ALIGN_CENTER
self.info.background_color='#6bff6b'
self.add_subview(self.info)
self.background_color='#fff9d6'
def draw(self):
w=self.width
h=self.height
l=w/4
t=h/4
w=w/2
h=h/2
path = ui.Path.rect(l,t,w,h)
ui.set_color('blue')
path.fill()
img = ui.Image.named('iob:alert_256')
img.draw(l,t,w,h) #self.width, self.height)
def touch_moved(self, touch):
x,y=touch.location
self.info.text = '{:04}-{:0=4}'.format(int(x),int(y))
v = MyView()
v.present('sheet')```