Skip to content

BoxLayout widget doesn't work like a BoxLayout layout manager #94

@ghost

Description

I tried to use Mx BoxLayout to position elements, but I couldn't get desired results. It behaves differently than Clutter BoxLayout. Elements don't expand in layout orientation axis. Example script:

#!/usr/bin/env python3
from gi.repository import Clutter, Mx


class ButtonStage(Clutter.Stage):
    def create_box_mx(self):
        return Mx.BoxLayout()

    def create_box_actor(self):
        box = Clutter.Actor()
        box.set_layout_manager(Clutter.BoxLayout())
        return box

    def __init__(self):
        super().__init__()

        self.layout = Clutter.BoxLayout()
        self.set_layout_manager(self.layout)

        # Uncomment one of these lines
        #self.box = self.create_box_actor()
        self.box = self.create_box_mx()

        self.box.set_x_expand(True)
        self.box.set_y_expand(True)
        self.add_child(self.box)

        self.button_a = Mx.Button()
        self.button_a.set_label("A")
        self.box.add_child(self.button_a)

        self.button_b = Mx.Button()
        self.button_b.set_label("B")
        self.button_b.set_x_expand(True)
        self.box.add_child(self.button_b)


def main():
    Clutter.init([])
    stage = ButtonStage()
    stage.connect("destroy", lambda _: Clutter.main_quit())
    stage.show_all()
    Clutter.main()


if __name__ == '__main__':
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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