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.


    Equally spaced circle in UI

    Pythonista
    5
    28
    10704
    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.
    • AZOM
      AZOM @mikael last edited by

      @mikael
      Well thanks a lot for that but since I’m not so good, how do I get anchor.py ? I saw what is in the link, but what do I do with it?

      mikael 1 Reply Last reply Reply Quote 0
      • pavlinb
        pavlinb last edited by

        Download it in your Pythonista working folder.

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

          @AZOM, copy the contents of the file into a file called anchor.py in your site-packages directory or the same directory as your script.

          AZOM 1 Reply Last reply Reply Quote 0
          • AZOM
            AZOM @pavlinb last edited by

            @pavlinb

            It is a long 1000+ code, but thanks

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

              @mikael

              Ok, thank you

              cvp 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @AZOM last edited by cvp

                @AZOM if you go here, you can download the zip in your iCloud Drive, unzip it and copy the py to Pythonista
                Via split view

                AZOM pavlinb 2 Replies Last reply Reply Quote 0
                • AZOM
                  AZOM @cvp last edited by

                  @cvp
                  Thank you a lot, it’s working :)

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

                    @AZOM, also, if you install stash, you can just wget a file from a url.

                    1 Reply Last reply Reply Quote 0
                    • pavlinb
                      pavlinb @cvp last edited by pavlinb

                      @cvp Is it possible on iPhone (split view)?

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

                        @pavlinb Sorry but I don't know. I have a very old iPhone 5s not allowed for iOS 13 nor iPadOS

                        1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp @pavlinb last edited by

                          @pavlinb it seems that does it exist on iPhone but hoped on iOS 14.
                          It is ok on my iPad mini 4 and it is not very bigger than the biggest iPhone

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

                            @cvp, you can open and unzip a zip in Pythonista.

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

                              @mikael sure. It was only to show that you can download a file (zip or not) from GitHub without needing a Pythonista script to import it, via iCloud then split view.
                              I know there are several ways.
                              We are not yet using a lot download to Files, then drag and drop to another app, like Pythonista

                              Personally, I use my script

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

                                @mikael
                                How do I change the circle’s position (horizontally) with your code that you first gave me?

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

                                  @AZOM, GridView has a pack_x argument:

                                  g = GridView(
                                      count_x=1,
                                      pack_x=GridView.START)
                                  

                                  Using END instead would move them to the right edge.

                                  You can also control the placement down to the pixel by providing an additional gap argument, which in this case is essentially the distance to the edge.

                                  See the end of this page for the documentation.

                                  AZOM 1 Reply Last reply Reply Quote 1
                                  • AZOM
                                    AZOM @mikael last edited by

                                    @mikael
                                    Yeah, thanks for all.

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

                                      @adomanim, here you go. You need the vector.py from here.

                                      import ui
                                      import vector
                                      
                                      chars = 'ABCDEFGH'
                                      start_angle = 0 # First character on the right
                                      
                                      circle_color = 'red'
                                      char_color = 'white'
                                      char_font = ('Apple SD Gothic Neo', 32)
                                      
                                      diameter = min(ui.get_screen_size())/2
                                      
                                      root = ui.View()
                                      root.present()
                                      
                                      pointer = vector.Vector()
                                      pointer.magnitude = diameter/2
                                      pointer.degrees = start_angle
                                      
                                      for c in chars:
                                          label = ui.Label(
                                              text=c,
                                              text_color=char_color,
                                              alignment=ui.ALIGN_CENTER,
                                              font=char_font)
                                          label.center = root.bounds.center() + tuple(pointer)
                                          pointer.degrees += 360/len(chars)
                                          root.add_subview(label)
                                          
                                          
                                      class CircleView(ui.View):
                                          
                                          def layout(self):
                                              self.corner_radius = self.width/2
                                              
                                      circle = CircleView(
                                          width=diameter, height=diameter,
                                          border_width=1, border_color=circle_color,
                                          center = root.bounds.center()
                                      )
                                      
                                      root.add_subview(circle)
                                      circle.send_to_back()
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • AZOM
                                        AZOM last edited by

                                        This is for my friend: can someone make a 3 points generator on the circumference of a circle that has a diameter of 2 units. And with these three x, y coordinates, look if the point (0,5:0) is in the triangle made with the three points?

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

                                          @AZOM, sounds like a school exercise. Wouldn’t it be more useful for your friend to spend the time on cracking it?

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

                                            @mikael

                                            No, we are in high school, and this is not a homework or something like that, he just like maths and wants help to “verify” his answer to a question he gets somewhere on the web.

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