Skip to content

How on earth can I make Pack(alignment=CENTER) get to work !? #2082

Answered by mhsmith
Varisox137 asked this question in Q&A
Discussion options

You must be logged in to vote

To use the full width, the inner Box needs to have a flex attribute, like this:

        self.main_window.content=(
            outer:=toga.Box(
               style=Pack(direction=ROW, alignment=CENTER),
               children=[
                   inner:=toga.Box(
                      style=Pack(direction=COLUMN, alignment=CENTER, flex=1),
                      children=[
                          self.enter_login_scene_button,
                          self.enter_offline_scene_button
                      ]
                   ),
               ]
            )
        )

This gives the desired layout with the current development version of Toga. However, it might not work with the stable…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@Varisox137
Comment options

@Varisox137
Comment options

@mhsmith
Comment options

Answer selected by Varisox137
@Varisox137
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants