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.


    Creation of ui Elements - defaults are strange

    Pythonista
    ui.controls defaults
    3
    5
    3464
    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.
    • Phuket2
      Phuket2 last edited by

      @omz, I didn't write this as a bug because maybe you added something I am not aware about.

      But if you create a ui.Button without params you get width and height = 0.
      If you create a ui.Table without params, you get a width and height of 100.

      Maybe you added something to set this globally.

      But if not, it would seem reasonable to create the objects as you do in the designer. Eg. Ui.Button() w = 80, h = 32. ui.TableView() w = 200, h = 200

      From memory in the past you got values if not like this but close to this.

      I get the logic, if you don't specify a frame, then there is none. But it is as practical as if you did that in the Designer

      As I say, maybe there is a bigger picture going on here.

      1 Reply Last reply Reply Quote 2
      • lukaskollmer
        lukaskollmer last edited by

        The button has a size of zero because there is no title set by default.
        When you set a title and call size_to_fit(), the size will change so, that the content fits.

        I haven't tested this with other view elements but I guess it's probably the same.

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

          I made some more tests. These are the default sizes from the ui module:

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

            ui.Button autosizes upon init, if passed a title or image argument

            btn=ui.Button(image=ui.Image.named('iow:alert_32'))
            btn=ui.Button(title='Submit')
            
            1 Reply Last reply Reply Quote 0
            • Phuket2
              Phuket2 last edited by

              Thanks guys. Looks maybe its a storm in a teacup 😬 Personally I would have thought just for consistency and memorising, that the designer and the code creation would use the same defaults. Ok, created ui.Button basically does.
              Good to know about the button though. Explains why sometimes testing I get different results. Often getting the placements correct before populating them. Can you the impression that it is behaving erratically or that's something has changed when it's just the sequence in which you do things. Live and learn 👍

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