Пример #1
0
def generate_grid(container, num_cols):
    """ Generate grid constraints with given number of columns.

    Notes
    -----
    Shamelessly copied from enaml/examples/layout/advanced/factory_func.enaml
    """
    rows = []
    widgets = container.visible_widgets()
    row_iters = (iter(widgets),) * num_cols
    rows = list(zip(*row_iters))
    return [
        grid(*rows, row_spacing=0, column_spacing=0, row_align="v_center", column_align="h_center"),
        align("width", *widgets),
    ]
Пример #2
0
def auto_grid_layout(self):
    """Automatic layouting function for instrument tasks views.
    """
    children = self.widgets()
    labels = children[::2]
    widgets = children[1::2]
    n_labels = len(labels)
    n_widgets = len(widgets)
    if n_labels != n_widgets:
        if n_labels > n_widgets:
            labels.pop()
        else:
            widgets.pop()

    return [grid(labels, widgets)]
Пример #3
0
def auto_grid_layout(self):
    """Automatic layout =ing function for instrument tasks views.

    """
    children = self.widgets()
    labels = children[::2]
    widgets = children[1::2]
    n_labels = len(labels)
    n_widgets = len(widgets)
    if n_labels != n_widgets:
        if n_labels > n_widgets:
            labels.pop()
        else:
            widgets.pop()

    return [grid(labels, widgets)]