Ok, I feel foolish, I was after this functionality for a long time in pyui files and it's just been sitting there, God knows for how long. Maybe 1.6 😱
So, if you create a pyui file in the designer. Add a Custom View Control from the add menu to it. Then in the Custom View Class (property sheet) for that view in designer, add the class name of a Custom uiView that you have defined in your code.
Presto, that class is the class used as the ui.View.
Look, I know many just know this. But there are so many things that are possible, hard to keep up with it all.
Anyway, below is sample code. Just need to create a pyui file. Very simple one.
import ui
class OwnerDrawn(ui.View):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def draw(self):
s = ui.Path.oval(*self.bounds)
ui.set_color('red')
s.fill()
if __name__ == '__main__':
w, h = 600, 800
f = (0, 0, w, h)
# load a standard pyui file as normal. In the pyui file, there is
# a custom View Control. its Custom View Class property in the
# pyui file is set to OwnerDrawn.
v = ui.load_view('Search_bar')
v.present('sheet')