pythontraitsui

How to specify the split ratio for VSplit or HSplit in TraisUI?


My view is defined as below

DefaultView = View(
    HSplit(
        Item("figure", editor=MPLFigureEditor(toolbar=True),
             show_label=False),
        VGroup(
            Item("draw_button", show_label=False)),
        show_labels=False
    ),
    width=800, height=600, title="Facial Triangles", resizable=True)

I've look up the official document of HSplit and found there is none attribute or method to specify the initial split ratio.

Is there a method to specify the initial split ratio?


Solution

  • From this discussion, I've gotten the method: by specify the width or height attribute of the Item. For example, my above view is updated:

    DefaultView = View(
        HSplit(
            Item("figure", editor=MPLFigureEditor(toolbar=True), width=0.95,
                 show_label=False),
            VGroup(
                Item("draw_button", show_label=False)),
            show_labels=False
        ),
        width=800, height=600, title="Facial Triangles", resizable=True)