| 68 | |
| 69 | |
| 70 | class WizardLayoutFactory: |
| 71 | def create_wizard_layout(self, definition): |
| 72 | run_wizard_dialog = self._create_run_wizard_dialog(definition) |
| 73 | error_bar = self._create_error_bar() |
| 74 | container = HSplit( |
| 75 | [ |
| 76 | self._create_title(definition), |
| 77 | self._create_sections( |
| 78 | definition, run_wizard_dialog, error_bar |
| 79 | ), |
| 80 | HorizontalLine(), |
| 81 | ] |
| 82 | ) |
| 83 | return WizardLayout( |
| 84 | container=container, |
| 85 | run_wizard_dialog=run_wizard_dialog, |
| 86 | error_bar=error_bar, |
| 87 | ) |
| 88 | |
| 89 | def _create_title(self, definition): |
| 90 | title = Label(f'{definition["title"]}', style='class:wizard.title') |
| 91 | title.window.align = WindowAlign.CENTER |
| 92 | return title |
| 93 | |
| 94 | def _create_sections(self, definition, run_wizard_dialog, error_bar): |
| 95 | section_tabs = [] |
| 96 | section_bodies = [] |
| 97 | for section_name, section_definition in definition['plan'].items(): |
| 98 | if section_name == core.DONE_SECTION_NAME: |
| 99 | section_tabs.append( |
| 100 | self._create_done_section_tab(section_definition) |
| 101 | ) |
| 102 | section_bodies.append(run_wizard_dialog) |
| 103 | else: |
| 104 | section_tabs.append( |
| 105 | self._create_section_tab(section_name, section_definition) |
| 106 | ) |
| 107 | section_bodies.append( |
| 108 | self._create_section_body(section_name, section_definition) |
| 109 | ) |
| 110 | section_tabs.append(Spacer()) |
| 111 | return VSplit( |
| 112 | [ |
| 113 | HSplit( |
| 114 | section_tabs, padding=1, style='class:wizard.section.tab' |
| 115 | ), |
| 116 | ConditionalContainer( |
| 117 | VerticalLine(), filter=Condition(is_windows) |
| 118 | ), |
| 119 | HSplit( |
| 120 | [ |
| 121 | *section_bodies, |
| 122 | WizardDetailsPanel(), |
| 123 | error_bar, |
| 124 | ToolbarView(), |
| 125 | ] |
| 126 | ), |
| 127 | ] |