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.


    Pythonista View (question)

    Pythonista
    4
    32
    6062
    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.
    • DavinE
      DavinE @JonB last edited by

      @JonB said:

      i think this shows the problem, and a potential solution:

      import ui
      from objc_util import *
      
      v=ui.View(bg_color='white')
      
      b=ui.Button(title='press to resize with insets')
      
      b.border_width=1
      b.corner_radius=50
      
      @on_main_thread
      def a(sender):
      	sender.objc_instance.button().contentEdgeInsets=(0, 50,0, 50) #t,l,b,r
      	sender.size_to_fit()
      
      b.action=a
      
      v.add_subview(b)
      v.present()
      
      

      The height changes when using this method, so i assume that those edgeinsets are overriding some other sort of anchor or layout constraint that i don't get.

      thats a good example...
      but is it Possible to set the size at begin ?
      not over an action....

      is this example okay to do this so ?:

      import ui
      from objc_util import *
      
      v=ui.View(bg_color='white')
      
      b=ui.Button(title='press to resize with insets')
      
      b.border_width=5
      b.corner_radius=50
      b.objc_instance.button().contentEdgeInsets=(5, 50,5, 50)
      b.size_to_fit()
      
      v.add_subview(b)
      v.present()
      
      1 Reply Last reply Reply Quote 0
      • DavinE
        DavinE @mikael last edited by

        @mikael said:

        @DavinE said:

        First second are my two Buttons ??

        Yes, just example names.

        Thanks this works Perfect :D

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

          @mikael said:

          @JonB, sorry to be thick, but I still do not understand what the problem is or what the insets are for. In the example above I used corner radius to create buttons with rounded ends, but this must be about something else.

          My Problem is when i use border_width and border_radius my text is cutted by the Button...
          @JonB understand my Problem correctly

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

            @DavinE, inspired by your question, I uploaded a new version with an attach option with these functions:

            • above
            • below
            • left_of
            • right_of

            With those, your use case could also be:

            dock(first).top_center(superview)
            attach(second).below(first)
            
            DavinE 2 Replies Last reply Reply Quote 0
            • DavinE
              DavinE @mikael last edited by

              @mikael said:

              @DavinE, inspired by your question, I uploaded a new version with an attach option with these functions:

              • above
              • below
              • left_of
              • right_of

              With those, your use case could also be:

              dock(superview).top_center(first)
              attach(second).below(first)
              

              Great :D how can i Update my files ?
              over stash ?

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

                @DavinE, pip update pythonista-anchors

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

                  oh man..... i'm so stupid :D

                  ty @mikael

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

                    @DavinE, don’t be hard on yourself. Just remember you have the -h option for most stash commands, like pip -h.

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

                      Thanks @mikael for that great Support here Thumbs Up

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

                        @mikael said:

                        @DavinE, inspired by your question, I uploaded a new version with an attach option with these functions:

                        • above
                        • below
                        • left_of
                        • right_of

                        With those, your use case could also be:

                        dock(first).top_center(superview)
                        attach(second).below(first)
                        

                        Hay @mikael,

                        i Think i found an issue in the attach function:

                        xxx.../site-packages-3/anchors/core.py:780: ConstraintWarning: Probably missing superview
                          at(self.view).left = at(other).right
                        xxx.../site-packages-3/anchors/core.py:801: ConstraintWarning: Probably missing superview
                          getattr(anchor_at, prop) + modifier)
                        Traceback (most recent call last):
                          File "_ctypes/callbacks.c", line 234, in 'calling callback function'
                          File "xxx..../Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 1066, in OMMainThreadDispatcher_invoke_imp
                            retval = func(*args, **kwargs)
                          File "xxx.../site-packages-3/anchors/core.py", line 213, in on_change
                            value_changed = next(constraint.runner)
                          File "<string>", line 27, in constraint_runner
                        AttributeError: 'NoneType' object has no attribute 'bounds'
                        

                        i get this by:

                        attach(second).right_of(first)
                        
                        mikael 1 Reply Last reply Reply Quote 0
                        • mikael
                          mikael @DavinE last edited by

                          @DavinE, yes thank you, there was a missing add_subview, now fixed in the version on PyPI.

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

                            @mikael said:

                            @DavinE, yes thank you, there was a missing add_subview, now fixed in the version on PyPI.

                            Great :D

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