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.


    Create and Rotate Label

    Pythonista
    2
    3
    2133
    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.
    • mcarrara3
      mcarrara3 last edited by

      Hello, how can I create and rotate a label of pi/2? I've already tried the GState() example, but when you input pi/2 the text disappears...

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

        Can you post an example of what you tried?

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

          I think I figured it out by myself. Here's the code, in case someone needs it!

          # coding: utf-8
          import ui
          from math import pi
          
          # Preliminary step: create an empty UI and call it myview
          
          # loading view
          v = ui.load_view('myview')
          
          # creating label
          ylabel = ui.Label()
          ylabel.text = 'Hello World'
          ylabel.center = (v.width/2., v.height/2.)
          
          #creating a transform object
          rot = ui.Transform.rotation(-pi/2)
          
          # applying the transform object to the label
          ylabel.transform = rot
          
          # adding the label to the view
          v.add_subview(ylabel)
          
          v.present()
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors