omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Navigation Subview

    Pythonista
    2
    2
    1098
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • robertiii
      robertiii last edited by

      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

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        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
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors