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.


    Wrapping UIStepper

    Pythonista
    ui.controls wrapper objcutil
    3
    3
    2240
    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.
    • shinyformica
      shinyformica last edited by

      Hey all, I was seeing if I could wrap the UIStepper control to use it in my UI, and I got this far:

      class Stepper(ui.View):
          def __init__(self, *args, **kws):
              import objc_util
              self._stepper = objc_util.ObjCClass("UIStepper").new()
              objcview = objc_util.ObjCInstance(self)
              objcview.addSubview_(self._stepper)
              self._stepper.flex = "WH"
              
          def layout(self):
              self._stepper.height = self.height
              self._stepper.width = self.width
      

      And it does show a UIStepper widget in my view. But...that setting of the flex attribute appears to do nothing, and the layout() method which tries to force the stepper to be the size of the parent view doesn't do anything either.

      I think this has to do with the fact that the actual objc view which the stepper is added to is not really manipulated by my view's layout() method or the flex attribute...but I'm not clear on how it works.

      I'm also curious how best to create a pass-through for all the properties of the UIStepper I'd like to be able to get/set: just write a pass-through property on my ui.View which sets the underlying property, or is there some clever way to override setattr and getattr to automatically pass through to an objc view?

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

        you need to set self.flex='wh'. then, when your view changes sizes, it calls layout.

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

          Or, to look at it in another way, you are resizing the contained Stepper, but not the containing View.

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