def on_default_labelsize(self): """action when user clicks 'Default' for number of labelsize""" self.labelsize_edit.setText(func_str_or_none(self._default_labelsize)) self.labelsize_edit.setStyleSheet("QLineEdit{background: white;}")
def on_default_phase(self): """action when user clicks 'Default' for phase angle""" self.phase_edit.setText(func_str_or_none(self._default_phase)) self.phase_edit.setStyleSheet("QLineEdit{background: white;}")
def on_default_ncolors(self): """action when user clicks 'Default' for number of colors""" self.ncolors_edit.setText(func_str_or_none(self._default_ncolors)) self.ncolors_edit.setStyleSheet("QLineEdit{background: white;}")
def on_default_arrow_scale(self): """action when user clicks 'Default' for arrow_scale factor""" self.arrow_scale_edit.setText(func_str_or_none(self._default_arrow_scale)) self.arrow_scale_edit.setStyleSheet("QLineEdit{background: white;}")
def on_default_format(self): """action when user clicks 'Default' for the number format""" self.format_edit.setText(func_str_or_none(self._default_format)) self.format_edit.setStyleSheet("QLineEdit{background: white;}")
def on_default_max(self): """action when user clicks 'Default' for max value""" self.max_edit.setText(func_str_or_none(self._default_max)) self.max_edit.setStyleSheet("QLineEdit{background: white;}")
def create_widgets(self, show_animation_button=True): """creates the menu objects""" # title self.title_label = QLabel("Title:") self.title_edit = QLineEdit(str(self._default_title)) self.title_button = QPushButton("Default") # Min self.min_label = QLabel("Min:") self.min_edit = QFloatEdit(func_str_or_none(self._default_min)) self.min_button = QPushButton("Default") # Max self.max_label = QLabel("Max:") self.max_edit = QFloatEdit(func_str_or_none(self._default_max)) self.max_button = QPushButton("Default") #--------------------------------------- # Format self.format_label = QLabel("Format (e.g. %.3f, %g, %.6e):") self.format_edit = QLineEdit(str(self._format)) self.format_button = QPushButton("Default") #--------------------------------------- # Scale self.scale_label = QLabel("True Scale:") self.scale_edit = QFloatEdit(func_str_or_none(self._scale)) self.scale_button = QPushButton("Default") if self._icase_disp is None: self.scale_label.setVisible(False) self.scale_edit.setVisible(False) self.scale_button.setVisible(False) # Phase self.phase_label = QLabel("Phase (deg):") self.phase_edit = QFloatEdit(func_str_or_none(self._phase)) self.phase_button = QPushButton("Default") if self._icase_disp is None or self._default_phase is None: self.phase_label.setVisible(False) self.phase_edit.setVisible(False) self.phase_button.setVisible(False) self.phase_edit.setText('0.0') #--------------------------------------- self.arrow_scale_label = QLabel("Arrow Scale:") self.arrow_scale_edit = QFloatEdit(func_str_or_none(self._arrow_scale)) self.arrow_scale_button = QPushButton("Default") if self._icase_vector is None: self.arrow_scale_label.setVisible(False) self.arrow_scale_edit.setVisible(False) self.arrow_scale_button.setVisible(False) #tip = QtGui.QToolTip() #tip.setTe #self.format_edit.toolTip(tip) #--------------------------------------- # nlabels self.nlabels_label = QLabel("Number of Labels:") self.nlabels_edit = QIntEdit(func_str_or_none(self._nlabels)) self.nlabels_button = QPushButton("Default") self.labelsize_label = QLabel("Label Size:") self.labelsize_edit = QIntEdit(func_str_or_none(self._labelsize)) self.labelsize_button = QPushButton("Default") self.ncolors_label = QLabel("Number of Colors:") self.ncolors_edit = QIntEdit(func_str_or_none(self._ncolors)) self.ncolors_button = QPushButton("Default") self.colormap_label = QLabel("Color Map:") self.colormap_edit = QComboBox(self) self.colormap_button = QPushButton("Default") for key in colormap_keys: self.colormap_edit.addItem(key) self.colormap_edit.setCurrentIndex(colormap_keys.index(self._colormap)) # -------------------------------------------------------------- # the header self.grid2_title = QLabel("Color Scale:") # red/blue or blue/red self.low_to_high_radio = QRadioButton('Low -> High') self.high_to_low_radio = QRadioButton('High -> Low') widget = QWidget(self) low_to_high_group = QButtonGroup(widget) low_to_high_group.addButton(self.low_to_high_radio) low_to_high_group.addButton(self.high_to_low_radio) self.low_to_high_radio.setChecked(self._default_is_low_to_high) self.high_to_low_radio.setChecked(not self._default_is_low_to_high) # horizontal / vertical self.horizontal_radio = QRadioButton("Horizontal") self.vertical_radio = QRadioButton("Vertical") widget = QWidget(self) horizontal_vertical_group = QButtonGroup(widget) horizontal_vertical_group.addButton(self.horizontal_radio) horizontal_vertical_group.addButton(self.vertical_radio) self.horizontal_radio.setChecked(self._default_is_horizontal) self.vertical_radio.setChecked(not self._default_is_horizontal) # on / off self.show_radio = QRadioButton("Show") self.hide_radio = QRadioButton("Hide") widget = QWidget(self) show_hide_group = QButtonGroup(widget) show_hide_group.addButton(self.show_radio) show_hide_group.addButton(self.hide_radio) self.show_radio.setChecked(self._default_is_shown) self.hide_radio.setChecked(not self._default_is_shown) # -------------------------------------------------------------- if self._icase_fringe is None: self.title_label.setVisible(False) self.title_edit.setVisible(False) self.title_button.setVisible(False) if not self._is_fringe: self.max_label.hide() self.min_label.hide() self.max_edit.hide() self.min_edit.hide() self.max_button.hide() self.min_button.hide() self.format_label.hide() self.format_edit.hide() self.format_button.hide() self.nlabels_label.hide() self.nlabels_edit.hide() self.nlabels_button.hide() self.ncolors_label.hide() self.ncolors_edit.hide() self.ncolors_button.hide() self.grid2_title.hide() self.vertical_radio.hide() self.horizontal_radio.hide() self.show_radio.hide() self.hide_radio.hide() self.low_to_high_radio.hide() self.high_to_low_radio.hide() self.colormap_label.hide() self.colormap_edit.hide() self.colormap_button.hide() self.animate_button = QPushButton('Create Animation') self.animate_button.setVisible(show_animation_button) #self.advanced_button = QPushButton('Advanced') if self._default_icase_disp is None: # or self._default_icase_vector is None: self.animate_button.setEnabled(False) self.animate_button.setToolTip(ANIMATE_TOOLTIP_OFF) else: self.animate_button.setEnabled(True) self.animate_button.setToolTip(ANIMATE_TOOLTIP_ON) # closing self.apply_button = QPushButton("Apply") self.ok_button = QPushButton("OK") self.cancel_button = QPushButton("Cancel")
def update_legend(self, icase_fringe, icase_disp, icase_vector, title, min_value, max_value, data_format, nlabels, labelsize, ncolors, colormap, is_fringe, scale, phase, arrow_scale, default_title, default_min_value, default_max_value, default_data_format, default_nlabels, default_labelsize, default_ncolors, default_colormap, default_scale, default_phase, default_arrow_scale, font_size=8, external_call=False): """ We need to update the legend if there's been a result change request """ self.external_call = external_call self.set_font_size(font_size) update_fringe = False update_disp = False update_vector = False #print('update_legend; fringe=%s disp=%s vector=%s' % ( #icase_fringe, icase_disp, icase_vector)) #print('update_legend; default: fringe=%s disp=%s vector=%s' % ( # self._default_icase_fringe, self._default_icase_disp, self._default_icase_vector)) if icase_fringe != self._default_icase_fringe: self._icase_fringe = icase_fringe self._default_icase_fringe = icase_fringe update_fringe = True #is_fringe = icase_fringe is not None is_disp = icase_disp is not None is_vector = icase_vector is not None if icase_disp != self._default_icase_disp: assert isinstance(scale, float_types), 'scale=%r type=%s' % (scale, type(scale)) #assert isinstance(default_scale, float), 'default_scale=%r' % default_scale self._icase_disp = icase_disp self._default_icase_disp = icase_disp self._default_scale = default_scale self._default_phase = default_phase update_disp = True if icase_vector != self._default_icase_vector: assert isinstance(arrow_scale, float_types), 'arrow_scale=%r type=%s' % (arrow_scale, type(scale)) #assert isinstance(default_arrow_scale, float), 'default_arrow_scale=%r' % default_arrow_scale self._icase_vector = icase_vector self._default_icase_vector = icase_vector self._default_arrow_scale = default_arrow_scale update_vector = True #print('*update_legend; default: fringe=%s disp=%s vector=%s' % ( # self._default_icase_fringe, self._default_icase_disp, self._default_icase_vector)) #print('update_fringe=%s update_disp=%s update_vector=%s' % ( # update_fringe, update_disp, update_vector)) #print('is_fringe=%s is_disp=%s is_vector=%s' % ( # is_fringe, is_disp, is_vector)) if update_fringe: self._icase_fringe = icase_fringe self._default_icase_fringe = icase_fringe self._default_title = default_title self._default_min = default_min_value self._default_max = default_max_value self._default_format = default_data_format #self._default_is_low_to_high = is_low_to_high self._default_is_discrete = True #self._default_is_horizontal = is_horizontal_scalar_bar self._default_nlabels = default_nlabels self._default_labelsize = default_labelsize self._default_ncolors = default_ncolors self._default_colormap = default_colormap self._is_fringe = is_fringe if colormap is None: colormap = 'jet' if labelsize is None: labelsize = '' if ncolors is None: ncolors = '' if nlabels is None: nlabels = '' self._update_defaults_to_blank() #----------------------------------------------------------------------- update = update_fringe or update_disp or update_vector if update: #self.scale_label.setEnabled(is_disp) #self.scale_edit.setEnabled(is_disp) #self.scale_button.setEnabled(is_disp) self.scale_label.setVisible(is_disp) self.scale_edit.setVisible(is_disp) self.scale_button.setVisible(is_disp) is_complex_disp = self._default_phase is not None self.phase_label.setVisible(is_complex_disp) self.phase_edit.setVisible(is_complex_disp) self.phase_button.setVisible(is_complex_disp) self._scale = set_cell_to_blank_if_value_is_none(self.scale_edit, scale) self._phase = set_cell_to_blank_if_value_is_none(self.phase_edit, phase) if self._default_icase_disp is None: # or self._default_icase_vector is None: self.animate_button.setEnabled(False) self.animate_button.setToolTip(ANIMATE_TOOLTIP_OFF) else: self.animate_button.setEnabled(True) self.animate_button.setToolTip(ANIMATE_TOOLTIP_ON) #----------------------------------------------------------------------- if update: #self.arrow_scale_label.setEnabled(is_vector) #self.arrow_scale_edit.setEnabled(is_vector) #self.arrow_scale_button.setEnabled(is_vector) self.arrow_scale_label.setVisible(is_vector) self.arrow_scale_edit.setVisible(is_vector) self.arrow_scale_button.setVisible(is_vector) self._arrow_scale = set_cell_to_blank_if_value_is_none( self.arrow_scale_edit, arrow_scale) #----------------------------------------------------------------------- if update_fringe: #self.on_default_title() #self.on_default_min() #self.on_default_max() #self.on_default_format() #self.on_default_scale() # reset defaults self.title_edit.setText(title) self.title_edit.setStyleSheet("QLineEdit{background: white;}") self.min_edit.setText(func_str_or_none(min_value)) self.min_edit.setStyleSheet("QLineEdit{background: white;}") self.max_edit.setText(func_str_or_none(max_value)) self.max_edit.setStyleSheet("QLineEdit{background: white;}") self.format_edit.setText(str(data_format)) self.format_edit.setStyleSheet("QLineEdit{background: white;}") self.nlabels_edit.setText(str(nlabels)) self.nlabels_edit.setStyleSheet("QLineEdit{background: white;}") self.labelsize_edit.setText(str(labelsize)) self.labelsize_edit.setStyleSheet("QLineEdit{background: white;}") self.ncolors_edit.setText(str(ncolors)) self.ncolors_edit.setStyleSheet("QLineEdit{background: white;}") self.colormap_edit.setCurrentIndex(colormap_keys.index(str(colormap))) self._set_legend_fringe(self._is_fringe) if update: self.on_apply() self.external_call = True