def test_cases_from_tree_spaces(self): """tests ``get_cases_from_tree``""" form = [ [u'Geometry', '', [ (u'NodeID', 0, []), (u'ElementID', 1, []), (u'PropertyID', 2, []), (u'MaterialID', 3, []), (u'E', 4, []), (u'Element Checks', '', [ (u'ElementDim', 5, []), (u'Min Edge Length', 6, []), (u'Min Interior Angle', 7, []), (u'Max Interior Angle', 8, [])], ),], ], ] cases = get_cases_from_tree(form) assert np.array_equal(cases, [0, 1, 2, 3, 4, 5, 6, 7, 8]), cases
def create_layout(self): """displays the menu objects""" grid = QGridLayout() irow = 0 grid.addWidget(self.icase_fringe_label, irow, 0) grid.addWidget(self.icase_fringe_edit, irow, 1) grid.addWidget(self.checkbox_fringe, irow, 2) irow += 1 grid.addWidget(self.icase_disp_label, irow, 0) grid.addWidget(self.icase_disp_edit, irow, 1) #grid.addWidget(self.checkbox_disp, irow, 2) irow += 1 grid.addWidget(self.icase_vector_label, irow, 0) grid.addWidget(self.icase_vector_edit, irow, 1) grid.addWidget(self.checkbox_vector, irow, 2) irow += 1 grid.addWidget(self.scale_label, irow, 0) grid.addWidget(self.scale_edit, irow, 1) grid.addWidget(self.scale_button, irow, 2) irow += 1 grid.addWidget(self.arrow_scale_label, irow, 0) grid.addWidget(self.arrow_scale_edit, irow, 1) grid.addWidget(self.arrow_scale_button, irow, 2) irow += 1 grid.addWidget(self.time_label, irow, 0) grid.addWidget(self.time_edit, irow, 1) grid.addWidget(self.time_button, irow, 2) irow += 1 # spacer spacer = QLabel('') grid.addWidget(self.fps_label, irow, 0) grid.addWidget(self.fps_edit, irow, 1) grid.addWidget(self.fps_button, irow, 2) irow += 1 grid.addWidget(self.animation_type, irow, 0) grid.addWidget(self.animation_type_edit, irow, 1) irow += 1 grid.addWidget(spacer, irow, 0) irow += 1 #---------- #Time grid_time = QGridLayout() jrow = 0 self.fringe_label.setAlignment(Qt.AlignCenter) self.displacement_label.setAlignment(Qt.AlignCenter) if not IS_TIME_FRINGE: self.fringe_label.hide() self.icase_fringe_delta_edit.hide() self.icase_fringe_start_edit.hide() self.icase_fringe_end_edit.hide() self.icase_fringe_delta_button.hide() grid_time.addWidget(self.displacement_label, jrow, 1) grid_time.addWidget(self.fringe_label, jrow, 2) jrow += 1 grid_time.addWidget(self.icase_start, jrow, 0) grid_time.addWidget(self.icase_disp_start_edit, jrow, 1) grid_time.addWidget(self.icase_fringe_start_edit, jrow, 2) #grid_time.addWidget(self.icase_disp_start_button, jrow, 2) jrow += 1 grid_time.addWidget(self.icase_end_label, jrow, 0) grid_time.addWidget(self.icase_disp_end_edit, jrow, 1) grid_time.addWidget(self.icase_fringe_end_edit, jrow, 2) #grid_time.addWidget(self.icase_end_button, jrow, 2) jrow += 1 grid_time.addWidget(self.icase_delta_label, jrow, 0) grid_time.addWidget(self.icase_disp_delta_edit, jrow, 1) grid_time.addWidget(self.icase_fringe_delta_edit, jrow, 2) #grid_time.addWidget(self.icase_delta_button, jrow, 2) jrow += 1 hbox_min = QHBoxLayout() hbox_min.addWidget(self.min_value_enable) hbox_min.addWidget(self.min_value_label) grid_time.addLayout(hbox_min, jrow, 0) grid_time.addWidget(self.min_value_edit, jrow, 1) grid_time.addWidget(self.min_value_button, jrow, 2) jrow += 1 hbox_max = QHBoxLayout() hbox_max.addWidget(self.max_value_enable) hbox_max.addWidget(self.max_value_label) grid_time.addLayout(hbox_max, jrow, 0) grid_time.addWidget(self.max_value_edit, jrow, 1) grid_time.addWidget(self.max_value_button, jrow, 2) jrow += 1 grid_time.addWidget(spacer, jrow, 0) jrow += 1 #-------------- grid_scale = QGridLayout() grid_scale.addWidget(self.animation_profile_label, 0, 0) grid_scale.addWidget(self.animation_profile_edit, 0, 1) #grid_scale.addWidget(self.csv_profile, 1, 0) #grid_scale.addWidget(self.csv_profile_edit, 1, 1) #grid_scale.addWidget(self.csv_profile_browse_button, 1, 2) self.csv_profile = QLabel("CSV profile:") self.csv_profile_edit = QLineEdit() self.csv_profile_button = QPushButton('Browse') #box_time = QVBoxLayout() # TODO: It's super annoying that the animate time box doesn't # line up with the previous box self.box_scale.setLayout(grid_scale) self.box_time.setLayout(grid_time) #---------- grid2 = QGridLayout() irow = 0 #grid2.addWidget(self.animate_scale_radio, 8, 0) #grid2.addWidget(self.animate_phase_radio, 8, 1) #grid2.addWidget(self.animate_time_radio, 8, 2) #grid2.addWidget(self.animate_freq_sweeep_radio, 8, 3) grid2.addWidget(self.animate_in_gui_checkbox, irow, 0) irow += 1 grid2.addWidget(self.resolution_label, irow, 0) grid2.addWidget(self.resolution_edit, irow, 1) grid2.addWidget(self.resolution_button, irow, 2) irow += 1 grid2.addWidget(self.browse_folder_label, irow, 0) grid2.addWidget(self.browse_folder_edit, irow, 1) grid2.addWidget(self.browse_folder_button, irow, 2) irow += 1 grid2.addWidget(self.gif_label, irow, 0) grid2.addWidget(self.gif_edit, irow, 1) grid2.addWidget(self.gif_button, irow, 2) irow += 1 grid2.addWidget(self.make_images_checkbox, irow, 0) #grid2.addWidget(self.overwrite_images_checkbox, irow, 0) grid2.addWidget(self.delete_images_checkbox, irow, 1) grid2.addWidget(self.make_gif_checkbox, irow, 2) irow += 1 grid2.addWidget(self.repeat_checkbox, irow, 0) irow += 1 grid2.addWidget(spacer, irow, 0) grid_hbox = QHBoxLayout() grid_hbox.addWidget(spacer) grid_hbox.addLayout(grid2) grid_hbox.addWidget(spacer) # bottom buttons step_run_box = QHBoxLayout() step_run_box.addWidget(self.step_button) step_run_box.addWidget(self.wipe_button) step_run_box.addWidget(self.stop_button) step_run_box.addWidget(self.run_button) ok_cancel_box = QHBoxLayout() ok_cancel_box.addWidget(self.cancel_button) vbox = QVBoxLayout() vbox.addLayout(grid) vbox.addWidget(self.box_scale) vbox.addWidget(self.box_time) #vbox.addLayout(checkboxes) vbox.addLayout(grid_hbox) vbox.addStretch() vbox.addLayout(step_run_box) vbox.addLayout(ok_cancel_box) if IS_RESULTS_SELECTOR and self.fringe_cases: cases = get_cases_from_tree(self.fringe_cases) parent = self name = 'main' data = self.fringe_cases choices = cases results_widget = ResultsWindow(parent, name, data, choices, include_clear=False, include_delete=False) vbox_results = QVBoxLayout() results_widget_label = QLabel('Results:') vbox_results.addWidget(results_widget_label) vbox_results.addWidget(results_widget) hbox_main = QHBoxLayout() hbox_main.addLayout(vbox) hbox_main.addLayout(vbox_results) self.setLayout(hbox_main) else: self.setLayout(vbox)
def create_layout(self): """displays the menu objects""" #---------- # bottom buttons ok_cancel_box = QHBoxLayout() ok_cancel_box.addWidget(self.cancel_button) label = QLabel('Python Console:') vbox = QVBoxLayout() #vbox.addWidget(self.code_window) vbox.addWidget(label) vbox.addLayout(self.code_window) vbox.addStretch() vbox.addLayout(ok_cancel_box) if IS_RESULTS_SELECTOR and self.fringe_cases: cases = get_cases_from_tree(self.modules_form) parent = self name = 'modules' data = self.modules_form choices = cases def on_print(icase): module, func_str = self.module_map[icase] func = getattr(module, func_str) print(func.__doc__) print('-------------------------------') print(f'on_print(icase={icase}) -> {func_str}') try: args = func.__code__.co_varnames #('x', 'y') arg_word = [', '.join(args)] word = f'{module.__name__}.{func_str}({arg_word})' self.code_window.enter_data.add(word) #print(f'on_print(icase={icase}) -> {outi}') except AttributeError: word = f'{module.__name__}.{func_str}()' self.code_window.enter_data.add(word) module_actions = [ ## (right_click_msg, callback, validate?) ##('Clear Results...', self.on_clear_results, False), ##('Apply Results to Fringe...', 'fringe', self.on_fringe, True), ##('Apply Results to Displacement...', self.on_disp, True), ##('Apply Results to Vector...', self.on_vector, True), ('Print...', on_print, True), #('Modify...', on_modify, True), ] def on_add(icase): pass results_actions = [ ## (right_click_msg, callback, validate?) ##('Clear Results...', self.on_clear_results, False), ##('Apply Results to Fringe...', 'fringe', self.on_fringe, True), ##('Apply Results to Displacement...', self.on_disp, True), ##('Apply Results to Vector...', self.on_vector, True), ('Add...', on_add, True), ] self.modules_widget = ResultsWindow(parent, name, data, choices, actions=module_actions, include_export_case=False, include_clear=False, include_delete=False) #--------------- cases = get_cases_from_tree(self.fringe_cases) parent = self name = 'main' data = self.fringe_cases choices = cases self.results_widget = ResultsWindow( parent, name, data, choices, actions=results_actions, #include_export_case=True, #include_delete=True, include_clear=False, include_delete=False) #----------------------------------------------------------------------------- vbox_modules = QVBoxLayout() results_widget_label = QLabel('Modules:') vbox_modules.addWidget(results_widget_label) vbox_modules.addWidget(self.modules_widget) vbox_results = QVBoxLayout() results_widget_label = QLabel('Results:') vbox_results.addWidget(results_widget_label) vbox_results.addWidget(self.results_widget) hbox_main = QHBoxLayout() hbox_main.addLayout(vbox_modules) hbox_main.addLayout(vbox) hbox_main.addLayout(vbox_results) self.setLayout(hbox_main) else: self.setLayout(vbox)