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.


    That strange little thing called NavigationView...

    Pythonista
    ui editor navigationview
    3
    7
    6003
    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.
    • marcus67
      marcus67 last edited by

      For my app I'm using a NavigationView to offer a second layer of configuration dialogs. It's configured using the built-in UI editor. The pyui is available here. There are three issues:

      • The button labels of the navigation are centered but the axis is shifted to the right. This effect is not visible in the GUI editor but only when the view is actually displayed. See the following screen shots. The first one shows the view in the GUI editor, the second one shows the view as presented by the present method, the third one shows the view as child of another larger view. Note the in the latter two cases the labels are centered around an axis which is shifted right from the horizontal center of the view.

      • The second issue is regarding the manner in which the subviews of the NavigationView are shown in the parent view. Although the parent view has a default title row, the subviews are located as though the title row were not active. Hence, the top subviews are overlayed by the title row. Since the rendering of the view in the app is actually correct this is only a little disturbing but not essential. On the other hand it's interesting to me to know if I'm making a systematic mistake by using NavigationViews in such a way.

      • The third issue also relates to the title row. As can be seen in this screenshot, using the present method to show the view results in two title rows: the top one containing the view name and a close button and the second one showing the active view of the navigation hierarchy. Actually, I would like to have the lower one only, but if I deactivate the upper one using a parameter of the present method, I'm lacking the close button. As far as I can tell it is not possible either to add a ButtonItem to the left button items of the NavigationView. It is silently ignored. Is there better way to use the NavigationView as a top level view?

      Thanks a lot for your help!

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

        About the double titlebar issue - I encountered that issue back when I wrote filenav (which is basically one big NavigationView). My solution was to hide the default title bar (I think there's an argument that you can pass to present to do that) and add my own close button manually to the titlebar of the view in the NavigationView. Using the NavigationView as the top-level view was not an option, because presenting it sometimes crashed, depending on the mode.

        marcus67 1 Reply Last reply Reply Quote 1
        • marcus67
          marcus67 @dgelessus last edited by

          @dgelessus Did you use a ButtonItemor a full-fledge ButtonView? The former did not work for me and as for the latter I have no clue how to add it since the title bar does not seem to be a public attribute. Could you give me hint, please? Thanks!

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

            Filenav is in Pythonista-Tools Utilities and contains the lines:

            lst.left_button_items = ui.ButtonItem(image=ui.Image.named("ionicons-close-24"), action=close_proxy()),
            
            # [ ... ]
            
            nav.present("popover", hide_title_bar=True)
            
            1 Reply Last reply Reply Quote 1
            • dgelessus
              dgelessus last edited by

              What @ccc said. Thank you for looking up the relevant bits of code. :) FYI, the close_proxy is a tiny one-liner that calls the main view's close method (though this does not work properly with "panel" mode views). Also the *_button_items have to be tuples, single ButtonItems are not allowed, that's what the comma at the end does (pointing it out because it's easy to overlook).

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

                The first issue with the incorrectly centered buttons is really bugging me. Last night I tried to find a wrong setting somewhere in my code and/or view but everything seems to be alright. That's why I created two small gists reproducing the phenomenon. Find the python script to open the view here and the pyui script here. I would really appreciate some help. Thanks a lot!

                1 Reply Last reply Reply Quote 0
                • marcus67
                  marcus67 @dgelessus last edited by

                  @dgelessus @ccc The code that I tried for the ButtonItems were pretty much the same as you suggested. After a lot of trying I think it's due to the NavigationView generated by the UI editor. If I create the view programmatically it works. I changed the code in my app to use a pyui file for the general frame. In the frame there is a placeholder where I insert the manually created NavigationView. As subview I insert another view loaded from another pyui file. It's definitely not straight forward anymore but at least I made some progress after being stuck for two days with the NavigationView that didn't work. By the way: this also fixes the trouble with the wrongly centered buttons.

                  @omz Could this be a general problem that the NavigationView generated by the UI editor has some flaw in it making it "misbehave"?

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors