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.


    Image after String in UI

    Pythonista
    ui.view
    3
    3
    2425
    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.
    • psyFi
      psyFi last edited by

      I'm making a today widget that shows a number (unknown number of digits) with an image beside the number.
      Using frames, I can place the ImageView next to my Label, but I'd like the image to hug the contents of the label.
      I've tried adding the image view as a subview to the label, using flex, and hard coded paths. Can anyone please help me out on this?

      If I know how to get the width in pixels of the number string, I can adjust the frame accordingly, but I don't know how to do that either.

      cvp mikael 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @psyFi last edited by

        @psyFi Try ui.measure_string

        1 Reply Last reply Reply Quote 0
        • mikael
          mikael @psyFi last edited by

          @psyFi, call size_to_fit on the label. Your enclosing view probably needs to be custom so that you can implement the layout method where you first size the label and then position the image. If your text changes a lot, you might also implement a text property for the enclosing class, where you can set the label text and then call size_to_fit on the enclosing view, or just the repositioning code directly.

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