def __init__(self, parent, debug=False, data=None, clear_data=True): """creates the buttons in the Sidebar, not the actual layout""" QWidget.__init__(self) self.parent = parent self.debug = debug name = 'main' choices = ['keys2', 'purse2', 'cellphone2', 'credit_card2', 'money2'] if data is None: data = [] self.result_case_window = ResultsWindow(self, 'Case/Results', data, choices) data = [ ('A', 1, []), #('B', 2, []), #('C', 3, []), ] self.result_data_window = ResultsWindow(self, 'Method', data, choices) self.result_data_window.setVisible(False) self.show_pulldown = False if self.show_pulldown: combo_options = ['a1', 'a2', 'a3'] self.pulldown = QComboBox() self.pulldown.addItems(choices) self.pulldown.activated[str].connect(self.on_pulldown) self.apply_button = QPushButton('Apply', self) self.apply_button.clicked.connect(self.on_apply) self.name = str(name) self.names = [name] self.name_label = QLabel("Name:") self.name_pulldown = QComboBox() self.name_pulldown.addItem(name) self.name_pulldown.setDisabled(True) self.name_pulldown.currentIndexChanged.connect(self.on_update_name) self.setup_layout(clear_data=clear_data)
def setup_layout(self, data, choices, clear_data=True, init=True): """creates the sidebar visual layout""" if not init: #self.frameGeometry(). width = self.frameGeometry().width() height = self.frameGeometry().height() #print('width=%s height=%s' % (width, height)) #print('init...') vbox = QVBoxLayout() hbox = QHBoxLayout() irow = 0 self._add_from_setup_dict(vbox, irow) hbox.addWidget(self.name_label) hbox.addWidget(self.name_pulldown) vbox.addLayout(hbox) irow += 1 self._add_from_setup_dict(vbox, irow) nwindows = len(self.result_case_windows) #print('nwindows=%s self.names=%s' % (nwindows, self.names)) for i in range(nwindows): #print('*using existing window') result_case_window = self.result_case_windows[i] vbox.addWidget(result_case_window) #result_case_window.setVisible(False) # be very careful of this... nwindows = len(self.result_case_windows) for name in self.names[nwindows:]: #print('*creating a window') result_case_window = ResultsWindow(self, 'Case/Results', data, choices) result_case_window.setVisible(False) vbox.addWidget(result_case_window) self.result_case_windows.append(result_case_window) iname = 0 #if self.name is None: #iname = 0 #else: #iname = self.names.index(self.name) #for i in range(nwindows): #if i != iname: #self.result_case_windows[iname].setVisible(False) #self.result_case_windows[iname].setVisible(True) irow += 1 self._add_from_setup_dict(vbox, irow) if self.result_method_window: vbox.addWidget(self.result_method_window) if self.show_pulldown: vbox.addWidget(self.pulldown) irow += 1 self._add_from_setup_dict(vbox, irow) vbox.addWidget(self.apply_button) irow += 1 self._add_from_setup_dict(vbox, irow) self.setLayout(vbox) if clear_data: self.clear_data()
def __init__(self, parent, debug=False, data=None, clear_data=True, name='main', setup_dict=None): """ Creates the buttons in the Sidebar, not the actual layout Parameters ---------- parent : MainWindow() the gui debug : bool; default=False flag for debug info data : List[tree] the tree clear_data : bool; default=True ??? name : str; default='main' the active name setup_dict : Dict[irow] = List[QWidgets] a way to add additional widgets to the sidebar """ QWidget.__init__(self) self.parent = parent self.debug = debug self.setup_dict = setup_dict choices = ['keys2', 'purse2', 'cellphone2', 'credit_card2', 'money2'] if data is None: data = [] self.result_case_windows = [ ResultsWindow(self, 'Case/Results', data, choices) ] data = [ ('A', 1, []), #('B', 2, []), #('C', 3, []), ] self.result_method_window = ResultsWindow(self, 'Method', data, choices) self.result_method_window.setVisible(False) #else: #self.result_method_window = None self.show_pulldown = False if self.show_pulldown: combo_options = ['a1', 'a2', 'a3'] self.pulldown = QComboBox() self.pulldown.addItems(choices) self.pulldown.activated[str].connect(self.on_pulldown) self.apply_button = QPushButton('Apply', self) self.apply_button.clicked.connect(self.on_apply) if name is None: self.name = None self.names = ['N/A'] name = 'N/A' else: self.name = str(name) self.names = [name] self.name_label = QLabel("Name:") self.name_pulldown = QComboBox() self.name_pulldown.addItem(name) self.name_pulldown.setDisabled(True) self.setup_layout(data, choices, clear_data=clear_data) self.name_pulldown.currentIndexChanged.connect(self.on_update_name)
def __init__( self, parent, debug=False, data=None, clear_data=True, name='main', setup_dict=None, # buttons include_case_spinner=False, include_deflection_scale=False, include_vector_scale=False, # actions include_clear=True, include_export_case=False, include_delete=True, include_results=True): """ Creates the buttons in the Sidebar, not the actual layout Parameters ---------- parent : MainWindow() the gui debug : bool; default=False flag for debug info data : List[tree] the tree clear_data : bool; default=True ??? name : str; default='main' the active name setup_dict : Dict[irow] = List[QWidgets] a way to add additional widgets to the sidebar """ #include_case_spinner = False QWidget.__init__(self) self.parent = parent self.debug = debug self.setup_dict = setup_dict self._update_case = True self.case_keys = [] self.icase = 0 # default # buttons self.include_case_spinner = include_case_spinner self.include_deflection_scale = include_deflection_scale self.include_vector_scale = include_vector_scale choices = ['keys2', 'purse2', 'cellphone2', 'credit_card2', 'money2'] if data is None: data = [] self.result_case_windows = [ ResultsWindow(self, 'Case/Results', data, choices, include_clear=include_clear, include_export_case=include_export_case, include_delete=include_delete, include_results=include_results) ] data = [ ('A', 1, []), #('B', 2, []), #('C', 3, []), ] self.result_method_window = ResultsWindow(self, 'Method', data, choices) self.result_method_window.setVisible(False) #else: #self.result_method_window = None self.show_pulldown = False if self.show_pulldown: #combo_options = ['a1', 'a2', 'a3'] self.pulldown = QComboBox() self.pulldown.addItems(choices) self.pulldown.activated[str].connect(self.on_pulldown) self.apply_button = QPushButton('Apply', self) self.apply_button.clicked.connect(self.on_apply) if name is None: self.name = None self.names = ['N/A'] name = 'N/A' else: self.name = str(name) self.names = [name] self.name_label = QLabel("Name:") self.name_pulldown = QComboBox() self.name_pulldown.addItem(name) self.name_pulldown.setDisabled(True) if include_case_spinner: self.case_spinner_label = QLabel('Case:') self.case_spinner = SkippableSpinBox() self.case_spinner_label.setVisible(False) self.case_spinner.setVisible(False) self.case_spinner.lineEdit().setReadOnly(True) # -1 is actually invalid, but we'll correct it later self.case_spinner.setMinimum(-1) if self.has_cases: self.set_max_case(self.parent.result_cases) if include_deflection_scale: self.deflection_label = QLabel('Deflection Scale:') self.deflection_edit = QLineEdit() if include_vector_scale: self.vector_label = QLabel('Vector Scale:') self.vector_edit = QLineEdit() #if include_vector: self.setup_layout(data, choices, clear_data=clear_data) self.set_connections()