• In answer to my own question at the end there: that "locations" parameter is not a "const float *", it is actually "const CGFloat *" which can be 32 or 64 bits depending on platform architecture, and therefore a C float is not necessarily compatible...so I needed to explicitly use the CGFloat datatype:

    CGFloat_p = ctypes.POINTER(objc_util.CGFloat) CGGradientCreateWithColors = objc_util.c.CGGradientCreateWithColors CGGradientCreateWithColors.restype = c_void_p CGGradientCreateWithColors.argtypes = [c_void_p, c_void_p, CGFloat_p] locations = (objc_util.CGFloat * 2)(0.0,1.0) gradient = CGGradientCreateWithColors(colorSpace, objc_util.ns(colors), ctypes.cast(locations, CGFloat_p))

    and it works fine. As always, thanks all!

  • @enceladus thanks, I knew I'd seen that somewhere before!

  • Ok, to be more correct if someone following this thread.

    I am sort of using like this. not saying it's good. Just wanted to show for completeness.

    import ui class MyClass(ui.View): def __init__(self, image_name, tint_color = 'black', shape_bg_color = 'orange', *args, **kwargs): super().__init__(*args, **kwargs) self.image_name = image_name self.image_margin = (20, 20) self.tint_color = tint_color self.shape_bg_color = shape_bg_color def draw(self): with ui.GState(): ui.set_color(self.shape_bg_color) shape = ui.Path.oval(*self.bounds) shape.fill() ui.set_color(self.tint_color) img = ui.Image.named(self.image_name) img_rect = ui.Rect(*self.bounds).inset(*self.image_margin) if img: img.with_rendering_mode(ui.RENDERING_MODE_TEMPLATE).draw(*img_rect) if __name__ == '__main__': wh = 300 mc = MyClass('iow:ios7_stopwatch_256', frame = (0, 0, wh, wh), bg_color = 'purple', shape_bg_color = 'white', tint_color = 'black') mc.present('sheet')
Internal error.

Oops! Looks like something went wrong!