robertiii
Sep 15, 2017 - 18:00
The subviews of a navigation item are not showing. I have add them as a subview in the ui editor but they do not show up
The subviews of a navigation item are not showing. I have add them as a subview in the ui editor but they do not show up
NavigationViews are funny beasts. I think the subview you add in the editor is actually the rootview. Check the ui.py code:
if classname == 'NavigationView':
# Special case for ui.NavigationView: Subviews are added to an
# implicitly-created root view instead of the NavigationView itself.
root_view = View()
root_view.name = attrs.get('root_view_name')
root_view.background_color = _str2color(attrs.get('background_color'), 'white')
subview_dicts = view_dict.get('nodes', [])
if subview_dicts:
for d in subview_dicts:
subview = _view_from_dict(d, f_globals, f_locals)
if subview:
root_view.add_subview(subview)
del view_dict['nodes']
v = NavigationView(root_view)
v.title_color = _str2color(attrs.get('title_color'))
v.bar_tint_color = _str2color(attrs.get('title_bar_color'))
This makes it tricky, because navviews dont easily give you access to the rootview. But this should work:
def get_navview_root(navview):
N=ObjCInstance(navview)
for v in list(N._rootView().descendantViews()):
if 'SUIView' in str(v.description()):
root_view=v.pyObject(argtypes=[],restype=ctypes.py_object)
return root_view