def select_layout(self, layout_type):
assert layout_type in LayoutTypes._ALL<EOL>if len(self.panes) == <NUM_LIT:1>:<EOL><INDENT>layout_type = LayoutTypes.EVEN_HORIZONTAL<EOL><DEDENT>if layout_type == LayoutTypes.EVEN_HORIZONTAL:<EOL><INDENT>self.root = HSplit(self.panes)<EOL><DEDENT>elif layout_type == LayoutTypes.EVEN_VERTICAL:<EOL><INDENT>self.root = VSplit(self.panes)<EOL><DEDENT>elif layout_type == LayoutTypes.MAIN_HORIZONTAL:<EOL><INDENT>self.root = HSplit([<EOL>self.active_pane,<EOL>VSplit([p for p in self.panes if p != self.active_pane])<EOL>])<EOL><DEDENT>elif layout_type == LayoutTypes.MAIN_VERTICAL:<EOL><INDENT>self.root = VSplit([<EOL>self.active_pane,<EOL>HSplit([p for p in self.panes if p != self.active_pane])<EOL>])<EOL><DEDENT>elif layout_type == LayoutTypes.TILED:<EOL><INDENT>panes = self.panes<EOL>column_count = math.ceil(len(panes) ** <NUM_LIT>)<EOL>rows = HSplit()<EOL>current_row = VSplit()<EOL>for p in panes:<EOL><INDENT>current_row.append(p)<EOL>if len(current_row) >= column_count:<EOL><INDENT>rows.append(current_row)<EOL>current_row = VSplit()<EOL><DEDENT><DEDENT>if current_row:<EOL><INDENT>rows.append(current_row)<EOL><DEDENT>self.root = rows<EOL><DEDENT>self.previous_selected_layout = layout_type<EOL>
Select one of the predefined layouts.