Skip to content

Improve alignment options #1194

@richierh

Description

@richierh

I don't find anyway to make a button widget in the center of a window/mainwindow

class TryWindow(toga.App):

    def startup(self):
        """
        Construct and show the Toga application.

        Usually, you would add your application to a main content box.
        We then create a main window (with a name matching the app), and
        show the main window.
        """

        self.boxa = toga.Box()
        self.main_box2 = toga.Box('box2',children=[self.boxa],style=Pack(direction='row'))
        self.main_box = toga.Box('box',children=[self.main_box2])

        self.button1 = toga.Button("Clicck", on_press = self.clickButton)#,style = Pack(direction=COLUMN,alignment=CENTER))

        self.main_box.add(self.button1)

        self.main_box.style.update(direction='row',alignment='center')

        self.main_window = toga.MainWindow(title=self.name)
        self.main_window.content = self.main_box
        self.main_window.show()
    
    def clickButton(self,event):
        print ("succeded")
        self.main_window.close()


def main():
    return TryWindow()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions