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.


    View.center not the center?

    Pythonista
    2
    2
    1156
    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.
    • TutorialDoctor
      TutorialDoctor last edited by

      I am working with the UI module, and I came across an issue where view.center wasn't giving me the center of the view. Some created my own function for getting the center of the view as a tuple.

      They return different values.

      <pre>
      def Get_Center(frame):
      center = (frame.width/2,frame.height/2)
      return center

      print customView.center
      print Get_Center(customView)
      </pre>
      My function made the UI control go to the center.
      Any ideas what is happening?

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

        center doesn't tell you where the center of your view is in its own coords, it tells you the center in the containing views coords, just like frame, and x and y. If your view's x and y attributes happen to be 0, then you'll get the same answer (assuming you have not used transform to rotate the view, or are doing funny things with bounds)

        So, you use center for positioning a view, not for positioning its subviews.

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