def __init__(self, frame=(100,100,600,300),*args,**kwargs): """ clipping all beyond frame """ super().__init__(frame=frame,*args,**kwargs) self.background_color = 'pink' iv = ui.ImageView(frame=(60,10,280,240)) # location within view self.add_subview(iv) world = plottls.rect_area(*iv.frame) user = None # user will autorange to data self.context = uiView_context.uiView_context(iv, user) self.graph = xy_graph_touchable(self.context)
def __init__(self, uiImageView, *args, **kwargs): #world_frame=None, user_frame=None, font_name='Helvetica', font_size=16.0): self.uiImageView = uiImageView self.ctx = ui.ImageContext(uiImageView.width, uiImageView.height) logger.info("context:%s" % self.uiImageView.bounds) if IMGDRW: #ivfrm = uiImageView.superview.bounds #uiImageView.frame #wrld_frm = (ivfrm[0],ivfrm[1]+ivfrm[3], ivfrm[2],-ivfrm[3]) # chg origin to left under wrld_frm = (0, uiImageView.height, uiImageView.width, -uiImageView.height) super().__init__( plottls.rect_area(*wrld_frm), *args, **kwargs) #world_frame,user_frame, font_name, font_size)
canvas.add_curve(*self.xyWorld(cp1x, cp1y), *self.xyWorld(cp2x, cp2y), *self.xyWorld(x, y)) def get_text_size(self, text, font_name=None, font_size=None): ''' size of text string in user coordinates ''' if font_size is None: font_size = self.font_size if font_name is None: font_name = self.font_name return self.whUser(*canvas.get_text_size(text, font_name, font_size)) if __name__ == "__main__": from time import sleep canvas.set_size(1000, 700) world = plottls.rect_area(100, 100, 300, 300) user = plottls.rect_area(0, 0, 60, 30) #ctx = uiView_context(world ,user) ctx1 = canvas_context(world, user) ctx2 = canvas_context(world, user.sub_area(xofs=-1.2)) # left of world frame ctx1.draw_line(2, 1, 30, 15) ctx1.add_rect(4, 2, 52, 26) ctx1.draw_text('org', 4, 2) ctx1.draw_text('mid1', 30, 15) ctx1.draw_text('top', 30, 28) ctx2.add_rect(4, 2, 52, 26) ctx2.draw_text('mid2', 30, 15)
self.path.add_curve(*self.xyWorld(cp1x, cp1y), *self.xyWorld(cp2x, cp2y), *self.xyWorld(x, y)) def get_text_size(self, text, font_name=None, font_size=None): ''' size of text string in user coordinates ''' if font_size is None: font_size = self.font_size if font_name is None: font_name = self.font_name return self.whUser(*canvas.get_text_size(text, font_name, font_size)) if __name__ == "__main__": import time #world = plottls.drawing_frame(100,100, 600,300) user = plottls.rect_area(0, 0, 60, 30) #ctx = uiView_context(world ,user) class gr_view(ui.View): """ """ def __init__(self, frame=(100, 100, 600, 400), *args, **kwargs): """ clipping all beyond frame """ super().__init__(frame=frame, *args, **kwargs) #self.bounds = frame # internal coord, origin defaults to 0 #self.background_color = 'white' self.bg_color = 'white' ivL = ui.ImageView(frame=(10, 10, 280, 280))