def __init__(self, parent=None, **kw):
     BasePopup.__init__(self, parent, "compact_bar_settings", "Compact Bar"
                        "Plot")
     self.bar_cols = LabelledSpinBox(self,
                                     text="Columns Per Page",
                                     minimum=1,
                                     step=1)
     self.bar_rows = LabelledSpinBox(self,
                                     text="Rows Per Page",
                                     minimum=1,
                                     step=1)
     self.x_tick_font = FontComboBox(self, "X Tick Font")
     self.x_tick_font_size = LabelledSpinBox(self,
                                             "X Tick Font Size",
                                             minimum=0,
                                             step=1)
     self.x_tick_rotation = LabelledSpinBox(self,
                                            "X Tick Rotation",
                                            minimum=0,
                                            maximum=360,
                                            step=1)
     self.x_tick_weight = LabelledCombobox(self,
                                           "X Tick Font Weight",
                                           items=font_weights)
     self.shade_unassigned_checkbox = LabelledCheckbox(
         self, "Shade Unassigned?")
     self.unassigned_shade_alpha = LabelledDoubleSpinBox(self,
                                                         "Unassigned Shade "
                                                         "Transparency",
                                                         minimum=0,
                                                         maximum=1,
                                                         step=0.1)
     self.layout().addWidget(self.bar_cols, 0, 0)
     self.layout().addWidget(self.bar_rows, 1, 0)
     self.layout().addWidget(self.x_tick_font_size, 2, 0)
     self.layout().addWidget(self.x_tick_font, 3, 0)
     self.layout().addWidget(self.x_tick_rotation, 4, 0)
     self.layout().addWidget(self.x_tick_weight, 5, 0)
     self.layout().addWidget(self.shade_unassigned_checkbox, 6, 0)
     self.layout().addWidget(self.unassigned_shade_alpha, 7, 0)
     self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                       | QDialogButtonBox.Cancel
                                       | QDialogButtonBox.RestoreDefaults)
     self.buttonBox.accepted.connect(self.set_values)
     self.buttonBox.rejected.connect(self.reject)
     self.buttonBox.button(
         QDialogButtonBox.RestoreDefaults).clicked.connect(
             self.get_defaults)
     self.layout().addWidget(self.buttonBox, 8, 0)
     self.get_values()
Exemple #2
0
 def __init__(self, parent=None, **kw):
     BasePopup.__init__(self,
                        parent,
                        title="Extended Bar Plot",
                        settings_key=["extended_bar_settings"])
     self.bar_cols = LabelledSpinBox(self,
                                     text="Columns Per Page",
                                     minimum=1,
                                     step=1)
     self.bar_rows = LabelledSpinBox(self,
                                     text="Rows Per Page",
                                     minimum=1,
                                     step=1)
     self.x_tick_font = FontComboBox(self, "X Tick Font")
     self.x_tick_font_size = LabelledSpinBox(self,
                                             "X Tick Font Size",
                                             minimum=0,
                                             step=1)
     self.x_tick_rotation = LabelledSpinBox(self,
                                            "X Tick Rotation",
                                            minimum=0,
                                            maximum=90,
                                            step=1)
     self.x_tick_font_weight = LabelledCombobox(self,
                                                "X Tick Font Weight",
                                                items=font_weights)
     self.x_tick_colour = LabelledCheckbox(self, "Colour X Ticks?")
     # adds widgets
     self.layout().addWidget(self.bar_cols, 0, 0)
     self.layout().addWidget(self.bar_rows, 1, 0)
     self.layout().addWidget(self.x_tick_font_size, 2, 0)
     self.layout().addWidget(self.x_tick_font, 3, 0)
     self.layout().addWidget(self.x_tick_rotation, 4, 0)
     self.layout().addWidget(self.x_tick_font_weight, 5, 0)
     self.layout().addWidget(self.x_tick_colour, 6, 0)
     # buttons
     self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                       | QDialogButtonBox.Cancel
                                       | QDialogButtonBox.RestoreDefaults)
     self.buttonBox.accepted.connect(self.set_values)
     self.buttonBox.rejected.connect(self.reject)
     self.buttonBox.button(
         QDialogButtonBox.RestoreDefaults).clicked.connect(
             self.get_defaults)
     # sets widget in tab
     self.layout().addWidget(self.buttonBox, 8, 0)
     self.get_values()
 def __init__(self, parent=None, **kw):
     BasePopup.__init__(self,
                        parent,
                        title="Residue Evolution Plot",
                        settings_key=["revo_settings"])
     self.do_revo_fit = LabelledCheckbox(self,
                                         text="Fit Parameter Evolution")
     self.revo_subtitle_fn = FontComboBox(self, text="Subtitle Font")
     self.revo_subtitle_fs = LabelledSpinBox(self,
                                             text="Subtitle Font Size",
                                             minimum=0,
                                             step=1)
     self.revo_subtitle_pad = LabelledDoubleSpinBox(self,
                                                    text="Subtitle Padding",
                                                    minimum=-100,
                                                    maximum=100,
                                                    step=0.1)
     self.revo_subtitle_weight = LabelledCombobox(
         self, text="Subtitle Font Weight", items=font_weights)
     self.revo_x_label_fn = FontComboBox(self, text="X Label Font")
     self.revo_x_label_fs = LabelledSpinBox(self,
                                            text="X Label Font Size",
                                            minimum=0,
                                            step=1)
     self.revo_x_label_pad = LabelledDoubleSpinBox(self,
                                                   text="X Label Padding",
                                                   minimum=-100,
                                                   maximum=100,
                                                   step=0.1)
     self.revo_x_label_weight = LabelledCombobox(self,
                                                 text="X Label Font Weight",
                                                 items=font_weights)
     self.revo_y_label_fn = FontComboBox(self, text="Y Label Font Size")
     self.revo_y_label_fs = LabelledSpinBox(self,
                                            text="Y Label Font Size",
                                            minimum=0,
                                            step=1)
     self.revo_y_label_pad = LabelledSpinBox(self,
                                             text="Y Label Padding",
                                             minimum=-100,
                                             maximum=100,
                                             step=0.1)
     self.revo_y_label_weight = LabelledCombobox(self,
                                                 text="Y Label Font Weight",
                                                 items=font_weights)
     self.revo_x_ticks_fn = FontComboBox(self, text="X Tick Font")
     self.revo_x_ticks_fs = LabelledSpinBox(self,
                                            text="X Tick Font Size",
                                            minimum=0,
                                            step=1)
     self.revo_x_ticks_pad = LabelledDoubleSpinBox(self,
                                                   text="X Tick Padding",
                                                   minimum=-100,
                                                   maximum=100,
                                                   step=0.1)
     self.revo_x_ticks_weight = LabelledCombobox(self,
                                                 text="X Tick Font Weight",
                                                 items=font_weights)
     self.revo_x_ticks_rotation = LabelledDoubleSpinBox(
         self, text="X Tick Rotation", minimum=0, maximum=360, step=1)
     self.revo_y_ticks_fn = FontComboBox(self, text="Y Tick Font")
     self.revo_y_ticks_fs = LabelledSpinBox(self,
                                            text="Y Tick Font Size",
                                            minimum=0,
                                            step=1)
     self.revo_y_ticks_pad = LabelledDoubleSpinBox(self,
                                                   text="Y Tick Padding",
                                                   minimum=-100,
                                                   maximum=100,
                                                   step=0.1)
     self.revo_y_ticks_weight = LabelledCombobox(self,
                                                 text="Y Tick Font Weight",
                                                 items=font_weights)
     self.revo_y_ticks_rot = LabelledSpinBox(self,
                                             text="Y Tick Rotation",
                                             minimum=0,
                                             maximum=360,
                                             step=1)
     self.titration_x_values = LabelledLineEdit(self,
                                                text="Titration X Values")
     # add widgets
     self.layout().addWidget(self.revo_subtitle_fn, 0, 0)
     self.layout().addWidget(self.revo_subtitle_fs, 1, 0)
     self.layout().addWidget(self.revo_subtitle_pad, 2, 0)
     self.layout().addWidget(self.revo_subtitle_weight, 3, 0)
     self.layout().addWidget(self.revo_x_label_fn, 4, 0)
     self.layout().addWidget(self.revo_x_label_fs, 5, 0)
     self.layout().addWidget(self.revo_x_label_pad, 6, 0)
     self.layout().addWidget(self.revo_x_label_weight, 7, 0)
     self.layout().addWidget(self.revo_y_label_fn, 8, 0)
     self.layout().addWidget(self.revo_y_label_fs, 9, 0)
     self.layout().addWidget(self.revo_y_label_pad, 10, 0)
     self.layout().addWidget(self.titration_x_values, 11, 0)
     self.layout().addWidget(self.revo_y_label_weight, 0, 1)
     self.layout().addWidget(self.revo_x_ticks_fn, 1, 1)
     self.layout().addWidget(self.revo_x_ticks_fs, 2, 1)
     self.layout().addWidget(self.revo_x_ticks_pad, 3, 1)
     self.layout().addWidget(self.revo_x_ticks_weight, 4, 1)
     self.layout().addWidget(self.revo_x_ticks_rotation, 5, 1)
     self.layout().addWidget(self.revo_y_ticks_fn, 6, 1)
     self.layout().addWidget(self.revo_y_ticks_fs, 7, 1)
     self.layout().addWidget(self.revo_y_ticks_pad, 8, 1)
     self.layout().addWidget(self.revo_y_ticks_weight, 9, 1)
     self.layout().addWidget(self.revo_y_ticks_rot, 10, 1)
     self.layout().addWidget(self.do_revo_fit, 11, 1)
     self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                       | QDialogButtonBox.Cancel
                                       | QDialogButtonBox.RestoreDefaults)
     self.buttonBox.accepted.connect(self.set_values)
     self.buttonBox.rejected.connect(self.reject)
     self.buttonBox.button(
         QDialogButtonBox.RestoreDefaults).clicked.connect(
             self.get_defaults)
     self.layout().addWidget(self.buttonBox, 12, 0, 1, 2)
     self.get_values()
class GeneralResidueEvolution(BasePopup):
    """
    A popup for setting General Residue Evolution Plot specific settings in the
    Farseer-NMR configuration.

    Parameters:
        parent(QWidget): parent widget for popup.

    Methods:
        .get_defaults()
        .get_values()
        .set_values()
    """
    def __init__(self, parent=None, **kw):
        BasePopup.__init__(self,
                           parent,
                           title="Residue Evolution Plot",
                           settings_key=["revo_settings"])
        self.do_revo_fit = LabelledCheckbox(self,
                                            text="Fit Parameter Evolution")
        self.revo_subtitle_fn = FontComboBox(self, text="Subtitle Font")
        self.revo_subtitle_fs = LabelledSpinBox(self,
                                                text="Subtitle Font Size",
                                                minimum=0,
                                                step=1)
        self.revo_subtitle_pad = LabelledDoubleSpinBox(self,
                                                       text="Subtitle Padding",
                                                       minimum=-100,
                                                       maximum=100,
                                                       step=0.1)
        self.revo_subtitle_weight = LabelledCombobox(
            self, text="Subtitle Font Weight", items=font_weights)
        self.revo_x_label_fn = FontComboBox(self, text="X Label Font")
        self.revo_x_label_fs = LabelledSpinBox(self,
                                               text="X Label Font Size",
                                               minimum=0,
                                               step=1)
        self.revo_x_label_pad = LabelledDoubleSpinBox(self,
                                                      text="X Label Padding",
                                                      minimum=-100,
                                                      maximum=100,
                                                      step=0.1)
        self.revo_x_label_weight = LabelledCombobox(self,
                                                    text="X Label Font Weight",
                                                    items=font_weights)
        self.revo_y_label_fn = FontComboBox(self, text="Y Label Font Size")
        self.revo_y_label_fs = LabelledSpinBox(self,
                                               text="Y Label Font Size",
                                               minimum=0,
                                               step=1)
        self.revo_y_label_pad = LabelledSpinBox(self,
                                                text="Y Label Padding",
                                                minimum=-100,
                                                maximum=100,
                                                step=0.1)
        self.revo_y_label_weight = LabelledCombobox(self,
                                                    text="Y Label Font Weight",
                                                    items=font_weights)
        self.revo_x_ticks_fn = FontComboBox(self, text="X Tick Font")
        self.revo_x_ticks_fs = LabelledSpinBox(self,
                                               text="X Tick Font Size",
                                               minimum=0,
                                               step=1)
        self.revo_x_ticks_pad = LabelledDoubleSpinBox(self,
                                                      text="X Tick Padding",
                                                      minimum=-100,
                                                      maximum=100,
                                                      step=0.1)
        self.revo_x_ticks_weight = LabelledCombobox(self,
                                                    text="X Tick Font Weight",
                                                    items=font_weights)
        self.revo_x_ticks_rotation = LabelledDoubleSpinBox(
            self, text="X Tick Rotation", minimum=0, maximum=360, step=1)
        self.revo_y_ticks_fn = FontComboBox(self, text="Y Tick Font")
        self.revo_y_ticks_fs = LabelledSpinBox(self,
                                               text="Y Tick Font Size",
                                               minimum=0,
                                               step=1)
        self.revo_y_ticks_pad = LabelledDoubleSpinBox(self,
                                                      text="Y Tick Padding",
                                                      minimum=-100,
                                                      maximum=100,
                                                      step=0.1)
        self.revo_y_ticks_weight = LabelledCombobox(self,
                                                    text="Y Tick Font Weight",
                                                    items=font_weights)
        self.revo_y_ticks_rot = LabelledSpinBox(self,
                                                text="Y Tick Rotation",
                                                minimum=0,
                                                maximum=360,
                                                step=1)
        self.titration_x_values = LabelledLineEdit(self,
                                                   text="Titration X Values")
        # add widgets
        self.layout().addWidget(self.revo_subtitle_fn, 0, 0)
        self.layout().addWidget(self.revo_subtitle_fs, 1, 0)
        self.layout().addWidget(self.revo_subtitle_pad, 2, 0)
        self.layout().addWidget(self.revo_subtitle_weight, 3, 0)
        self.layout().addWidget(self.revo_x_label_fn, 4, 0)
        self.layout().addWidget(self.revo_x_label_fs, 5, 0)
        self.layout().addWidget(self.revo_x_label_pad, 6, 0)
        self.layout().addWidget(self.revo_x_label_weight, 7, 0)
        self.layout().addWidget(self.revo_y_label_fn, 8, 0)
        self.layout().addWidget(self.revo_y_label_fs, 9, 0)
        self.layout().addWidget(self.revo_y_label_pad, 10, 0)
        self.layout().addWidget(self.titration_x_values, 11, 0)
        self.layout().addWidget(self.revo_y_label_weight, 0, 1)
        self.layout().addWidget(self.revo_x_ticks_fn, 1, 1)
        self.layout().addWidget(self.revo_x_ticks_fs, 2, 1)
        self.layout().addWidget(self.revo_x_ticks_pad, 3, 1)
        self.layout().addWidget(self.revo_x_ticks_weight, 4, 1)
        self.layout().addWidget(self.revo_x_ticks_rotation, 5, 1)
        self.layout().addWidget(self.revo_y_ticks_fn, 6, 1)
        self.layout().addWidget(self.revo_y_ticks_fs, 7, 1)
        self.layout().addWidget(self.revo_y_ticks_pad, 8, 1)
        self.layout().addWidget(self.revo_y_ticks_weight, 9, 1)
        self.layout().addWidget(self.revo_y_ticks_rot, 10, 1)
        self.layout().addWidget(self.do_revo_fit, 11, 1)
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel
                                          | QDialogButtonBox.RestoreDefaults)
        self.buttonBox.accepted.connect(self.set_values)
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.button(
            QDialogButtonBox.RestoreDefaults).clicked.connect(
                self.get_defaults)
        self.layout().addWidget(self.buttonBox, 12, 0, 1, 2)
        self.get_values()

    def get_defaults(self):
        # checkbox
        self.do_revo_fit.checkBox.setChecked(
            self.defaults["perform_resevo_fitting"])
        # dropdown list
        self.revo_subtitle_fn.select(self.defaults["subtitle_fn"])
        self.revo_subtitle_weight.select(self.defaults["subtitle_weight"])
        self.revo_x_label_fn.select(self.defaults["x_label_fn"])
        self.revo_x_label_weight.select(self.defaults["x_label_weight"])
        self.revo_y_label_fn.select(self.defaults["y_label_fn"])
        self.revo_y_label_weight.select(self.defaults["y_label_weight"])
        self.revo_x_ticks_fn.select(self.defaults["x_ticks_fn"])
        self.revo_x_ticks_weight.select(self.defaults["x_ticks_weight"])
        self.revo_y_ticks_fn.select(self.defaults["y_ticks_fn"])
        self.revo_y_ticks_weight.select(self.defaults["y_ticks_weight"])
        # value
        self.revo_subtitle_fs.setValue(self.defaults["subtitle_fs"])
        self.revo_subtitle_pad.setValue(self.defaults["subtitle_pad"])
        self.revo_x_label_fs.setValue(self.defaults["x_label_fs"])
        self.revo_x_label_pad.setValue(self.defaults["x_label_pad"])
        self.revo_y_label_fs.setValue(self.defaults["y_label_fs"])
        self.revo_y_label_pad.setValue(self.defaults["y_label_pad"])
        self.revo_x_ticks_fs.setValue(self.defaults["x_ticks_fs"])
        self.revo_x_ticks_pad.setValue(self.defaults["x_ticks_pad"])
        self.revo_x_ticks_rotation.setValue(self.defaults["x_ticks_rot"])
        self.revo_y_ticks_fs.setValue(self.defaults["y_ticks_fs"])
        self.revo_y_ticks_pad.setValue(self.defaults["y_ticks_pad"])
        self.revo_y_ticks_rot.setValue(self.defaults["y_ticks_rot"])
        # text
        self.titration_x_values.field.setText(','.join(
            [str(x) for x in self.defaults["titration_x_values"]]))

    def set_values(self):
        # checkbox
        self.local_variables[
            "perform_resevo_fitting"] = self.do_revo_fit.isChecked()
        # text
        self.local_variables["subtitle_fn"] = str(
            self.revo_subtitle_fn.fields.currentText())
        self.local_variables["subtitle_weight"] = str(
            self.revo_subtitle_weight.fields.currentText())
        self.local_variables["x_label_fn"] = str(
            self.revo_x_label_fn.fields.currentText())
        self.local_variables["x_label_weight"] = str(
            self.revo_x_label_weight.fields.currentText())
        self.local_variables["y_label_fn"] = str(
            self.revo_y_label_fn.fields.currentText())
        self.local_variables["y_label_weight"] = str(
            self.revo_y_label_weight.fields.currentText())
        self.local_variables["x_ticks_fn"] = str(
            self.revo_x_ticks_fn.fields.currentText())
        self.local_variables["x_ticks_weight"] = str(
            self.revo_x_ticks_weight.fields.currentText())
        self.local_variables["y_ticks_fn"] = str(
            self.revo_y_ticks_fn.fields.currentText())
        self.local_variables["y_ticks_weight"] = str(
            self.revo_y_ticks_weight.fields.currentText())
        # value
        self.local_variables[
            "subtitle_fs"] = self.revo_subtitle_fs.field.value()
        self.local_variables[
            "subtitle_pad"] = self.revo_subtitle_pad.field.value()
        self.local_variables["x_label_fs"] = self.revo_x_label_fs.field.value()
        self.local_variables[
            "x_label_pad"] = self.revo_x_label_pad.field.value()
        self.local_variables["y_label_fs"] = self.revo_y_label_fs.field.value()
        self.local_variables[
            "y_label_pad"] = self.revo_y_label_pad.field.value()
        self.local_variables["x_ticks_fs"] = self.revo_x_ticks_fs.field.value()
        self.local_variables[
            "x_ticks_pad"] = self.revo_x_ticks_pad.field.value()
        self.local_variables[
            "x_ticks_rot"] = self.revo_x_ticks_rotation.field.value()
        self.local_variables["y_ticks_fs"] = self.revo_y_ticks_fs.field.value()
        self.local_variables[
            "y_ticks_pad"] = self.revo_y_ticks_pad.field.value()
        self.local_variables[
            "y_ticks_rot"] = self.revo_y_ticks_rot.field.value()
        # text string list
        self.local_variables["titration_x_values"] = \
            [float(x) for x in self.titration_x_values.field.text().split(',')]
        self.accept()

    def get_values(self):
        # check
        self.do_revo_fit.setChecked(
            self.local_variables["perform_resevo_fitting"])
        # dropdown
        self.revo_subtitle_fn.select(self.local_variables["subtitle_fn"])
        self.revo_subtitle_weight.select(
            self.local_variables["subtitle_weight"])
        self.revo_x_label_fn.select(self.local_variables["x_label_fn"])
        self.revo_x_label_weight.select(self.local_variables["x_label_weight"])
        self.revo_y_label_fn.select(self.local_variables["y_label_fn"])
        self.revo_y_label_weight.select(self.local_variables["y_label_weight"])
        self.revo_x_ticks_fn.select(self.local_variables["x_ticks_fn"])
        self.revo_x_ticks_weight.select(self.local_variables["x_ticks_weight"])
        self.revo_y_ticks_fn.select(self.local_variables["y_ticks_fn"])
        self.revo_y_ticks_weight.select(self.local_variables["y_ticks_weight"])
        #value
        self.revo_subtitle_fs.setValue(self.local_variables["subtitle_fs"])
        self.revo_subtitle_pad.setValue(self.local_variables["subtitle_pad"])
        self.revo_x_label_fs.setValue(self.local_variables["x_label_fs"])
        self.revo_x_label_pad.setValue(self.local_variables["x_label_pad"])
        self.revo_y_label_fs.setValue(self.local_variables["y_label_fs"])
        self.revo_y_label_pad.setValue(self.local_variables["y_label_pad"])
        self.revo_x_ticks_fs.setValue(self.local_variables["x_ticks_fs"])
        self.revo_x_ticks_pad.setValue(self.local_variables["x_ticks_pad"])
        self.revo_x_ticks_rotation.setValue(
            self.local_variables["x_ticks_rot"])
        self.revo_y_ticks_fs.setValue(self.local_variables["y_ticks_fs"])
        self.revo_y_ticks_pad.setValue(self.local_variables["y_ticks_pad"])
        self.revo_y_ticks_rot.setValue(self.local_variables["y_ticks_rot"])
        self.revo_y_ticks_rot.setValue(self.local_variables["y_ticks_rot"])
        # text list string
        self.titration_x_values.field.setText(','.join(
            [str(x) for x in self.local_variables["titration_x_values"]]))
Exemple #5
0
class ExtendedBarPopup(BasePopup):
    """
    A popup for setting Extended Bar Plot specific settings in the Farseer-NMR
    configuration.

    Parameters:
        parent(QWidget): parent widget for popup.

    Methods:
        .get_defaults()
        .get_values()
        .set_values()
    """
    def __init__(self, parent=None, **kw):
        BasePopup.__init__(self,
                           parent,
                           title="Extended Bar Plot",
                           settings_key=["extended_bar_settings"])
        self.bar_cols = LabelledSpinBox(self,
                                        text="Columns Per Page",
                                        minimum=1,
                                        step=1)
        self.bar_rows = LabelledSpinBox(self,
                                        text="Rows Per Page",
                                        minimum=1,
                                        step=1)
        self.x_tick_font = FontComboBox(self, "X Tick Font")
        self.x_tick_font_size = LabelledSpinBox(self,
                                                "X Tick Font Size",
                                                minimum=0,
                                                step=1)
        self.x_tick_rotation = LabelledSpinBox(self,
                                               "X Tick Rotation",
                                               minimum=0,
                                               maximum=90,
                                               step=1)
        self.x_tick_font_weight = LabelledCombobox(self,
                                                   "X Tick Font Weight",
                                                   items=font_weights)
        self.x_tick_colour = LabelledCheckbox(self, "Colour X Ticks?")
        # adds widgets
        self.layout().addWidget(self.bar_cols, 0, 0)
        self.layout().addWidget(self.bar_rows, 1, 0)
        self.layout().addWidget(self.x_tick_font_size, 2, 0)
        self.layout().addWidget(self.x_tick_font, 3, 0)
        self.layout().addWidget(self.x_tick_rotation, 4, 0)
        self.layout().addWidget(self.x_tick_font_weight, 5, 0)
        self.layout().addWidget(self.x_tick_colour, 6, 0)
        # buttons
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel
                                          | QDialogButtonBox.RestoreDefaults)
        self.buttonBox.accepted.connect(self.set_values)
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.button(
            QDialogButtonBox.RestoreDefaults).clicked.connect(
                self.get_defaults)
        # sets widget in tab
        self.layout().addWidget(self.buttonBox, 8, 0)
        self.get_values()

    def get_defaults(self):
        # check
        self.x_tick_colour.setChecked(self.defaults["x_ticks_color_flag"])
        # values
        self.bar_cols.setValue(self.defaults["cols_page"])
        self.bar_rows.setValue(self.defaults["rows_page"])
        self.x_tick_font_size.setValue(self.defaults["x_ticks_fs"])
        self.x_tick_rotation.setValue(self.defaults["x_ticks_rot"])
        # select
        self.x_tick_font.select(self.defaults["x_ticks_fn"])
        self.x_tick_font_weight.select(self.defaults["x_ticks_weight"])

    def get_values(self):
        # checked
        self.x_tick_colour.setChecked(
            self.local_variables["x_ticks_color_flag"])
        # value
        self.bar_cols.setValue(self.local_variables["cols_page"])
        self.bar_rows.setValue(self.local_variables["rows_page"])
        self.x_tick_font_size.setValue(self.local_variables["x_ticks_fs"])
        self.x_tick_rotation.setValue(self.local_variables["x_ticks_rot"])
        # select
        self.x_tick_font.select(self.local_variables["x_ticks_fn"])
        self.x_tick_font_weight.select(self.local_variables["x_ticks_weight"])

    def set_values(self):
        # checked
        self.local_variables[
            "x_ticks_color_flag"] = self.x_tick_colour.isChecked()
        # value
        self.local_variables["cols_page"] = self.bar_cols.field.value()
        self.local_variables["rows_page"] = self.bar_rows.field.value()
        self.local_variables["x_ticks_fs"] = self.x_tick_font_size.field.value(
        )
        self.local_variables["x_ticks_rot"] = self.x_tick_rotation.field.value(
        )
        # text
        self.local_variables["x_ticks_fn"] = str(
            self.x_tick_font.fields.currentText())
        self.local_variables["x_ticks_weight"] = str(
            self.x_tick_font_weight.fields.currentText())
        self.accept()
 def __init__(self, parent=None, **kw):
     BasePopup.__init__(
         self,
         parent,
         title="Scatter Flower Plot",
         settings_key=["cs_scatter_flower_settings"]
         )
     self.x_label = LabelledLineEdit(self, "X Label")
     self.y_label = LabelledLineEdit(self, "Y Label")
     self.mksize = LabelledSpinBox(self, "Mark Size", minimum=0, step=1)
     self.color_grad = LabelledCheckbox(self, "Colour Gradient")
     self.color_start = ColourBox(self, text="Mark Start Colour")
     self.color_end = ColourBox(self, text="Mark End Colour")
     self.color_list = LabelledLineEdit(self, "Colour List")
     self.x_label_fn = FontComboBox(self, "X Label Font")
     self.x_label_fs = LabelledSpinBox(self, "X Label Font Size", minimum=0, step=1)
     self.x_label_pad = LabelledDoubleSpinBox(
         self,
         "X Label Padding",
         minimum=-100,
         maximum=100,
         step=0.1
         )
     self.x_label_weight = LabelledCombobox(self, text="X Label Font Weight", items=font_weights)
     self.y_label_fn = FontComboBox(self, "Y Label Font")
     self.y_label_fs = LabelledSpinBox(self, "Y Label Font Size", minimum=0, step=1)
     self.y_label_pad = LabelledDoubleSpinBox(
         self,
         "Y Label Padding",
         minimum=-100,
         maximum=100,
         step=0.1
         )
     self.y_label_weight = LabelledCombobox(
         self,
         text="Y Label Font Weight",
         items=font_weights
         )
     self.x_ticks_fn = FontComboBox(self, "X Tick Font")
     self.x_ticks_fs = LabelledSpinBox(self, "X Tick Font Size", minimum=0, step=1)
     self.x_ticks_pad = LabelledDoubleSpinBox(
         self,
         "X Tick Padding",
         minimum=-100,
         maximum=100,
         step=0.1
         )
     self.x_ticks_weight = LabelledCombobox(self, text="X Tick Weight", items=font_weights)
     self.x_ticks_rot = LabelledSpinBox(
         self,
         "X Tick Rotation",
         minimum=0,
         maximum=360,
         step=1
         )
     self.y_ticks_fn = FontComboBox(self, "Y Tick Font")
     self.y_ticks_fs = LabelledSpinBox(self, "Y Tick Font Size", minimum=0, step=1)
     self.y_ticks_pad = LabelledDoubleSpinBox(
         self,
         "Y Tick Padding",
         minimum=-100,
         maximum=100,
         step=0.1
         )
     self.y_ticks_weight = LabelledCombobox(self, text="Y Tick Weight", items=font_weights)
     self.y_ticks_rot = LabelledSpinBox(
         self,
         "Y Tick Rotation",
         minimum=0,
         maximum=360,
         step=1
         )
     self.res_label_color = ColourBox(self, text="Residue Label Colour")
     # layout
     self.layout().addWidget(self.x_label, 0, 0)
     self.layout().addWidget(self.y_label, 1, 0)
     self.layout().addWidget(self.mksize, 2, 0)
     self.layout().addWidget(self.color_grad, 3, 0)
     self.layout().addWidget(self.color_start, 4, 0)
     self.layout().addWidget(self.color_end, 5, 0)
     self.layout().addWidget(self.x_label_fn, 6, 0)
     self.layout().addWidget(self.x_label_fs, 7, 0)
     self.layout().addWidget(self.color_list, 8, 0)
     self.layout().addWidget(self.res_label_color, 8, 1)
     self.layout().addWidget(self.x_label_pad, 0, 1)
     self.layout().addWidget(self.x_label_weight, 1, 1)
     self.layout().addWidget(self.y_label_fn, 2, 1)
     self.layout().addWidget(self.y_label_fs, 3, 1)
     self.layout().addWidget(self.y_label_pad, 4, 1)
     self.layout().addWidget(self.y_label_weight, 5, 1)
     self.layout().addWidget(self.x_ticks_fn, 6, 1)
     self.layout().addWidget(self.x_ticks_fs, 7, 1)
     self.layout().addWidget(self.x_ticks_pad, 0, 2)
     self.layout().addWidget(self.x_ticks_weight, 1, 2)
     self.layout().addWidget(self.x_ticks_rot, 2, 2)
     self.layout().addWidget(self.y_ticks_fn, 3, 2)
     self.layout().addWidget(self.y_ticks_fs, 4, 2)
     self.layout().addWidget(self.y_ticks_pad, 5, 2)
     self.layout().addWidget(self.y_ticks_weight, 6, 2)
     self.layout().addWidget(self.y_ticks_rot, 7, 2)
     self.buttonBox = QDialogButtonBox(
         QDialogButtonBox.Ok |
         QDialogButtonBox.Cancel |
         QDialogButtonBox.RestoreDefaults
         )
     self.buttonBox.accepted.connect(self.set_values)
     self.buttonBox.rejected.connect(self.reject)
     self.buttonBox.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.get_defaults)
     self.layout().addWidget(self.buttonBox, 9, 0, 1, 2)
     self.get_values()
class ScatterFlowerPlotPopup(BasePopup):
    """
    A popup for setting Scatter Flower Plot specific settings in the
    Farseer-NMR configuration.

    Parameters:
        parent(QWidget): parent widget for popup.

    Methods:
        .get_defaults()
        .get_values()
        .set_values()
    """
    def __init__(self, parent=None, **kw):
        BasePopup.__init__(
            self,
            parent,
            title="Scatter Flower Plot",
            settings_key=["cs_scatter_flower_settings"]
            )
        self.x_label = LabelledLineEdit(self, "X Label")
        self.y_label = LabelledLineEdit(self, "Y Label")
        self.mksize = LabelledSpinBox(self, "Mark Size", minimum=0, step=1)
        self.color_grad = LabelledCheckbox(self, "Colour Gradient")
        self.color_start = ColourBox(self, text="Mark Start Colour")
        self.color_end = ColourBox(self, text="Mark End Colour")
        self.color_list = LabelledLineEdit(self, "Colour List")
        self.x_label_fn = FontComboBox(self, "X Label Font")
        self.x_label_fs = LabelledSpinBox(self, "X Label Font Size", minimum=0, step=1)
        self.x_label_pad = LabelledDoubleSpinBox(
            self,
            "X Label Padding",
            minimum=-100,
            maximum=100,
            step=0.1
            )
        self.x_label_weight = LabelledCombobox(self, text="X Label Font Weight", items=font_weights)
        self.y_label_fn = FontComboBox(self, "Y Label Font")
        self.y_label_fs = LabelledSpinBox(self, "Y Label Font Size", minimum=0, step=1)
        self.y_label_pad = LabelledDoubleSpinBox(
            self,
            "Y Label Padding",
            minimum=-100,
            maximum=100,
            step=0.1
            )
        self.y_label_weight = LabelledCombobox(
            self,
            text="Y Label Font Weight",
            items=font_weights
            )
        self.x_ticks_fn = FontComboBox(self, "X Tick Font")
        self.x_ticks_fs = LabelledSpinBox(self, "X Tick Font Size", minimum=0, step=1)
        self.x_ticks_pad = LabelledDoubleSpinBox(
            self,
            "X Tick Padding",
            minimum=-100,
            maximum=100,
            step=0.1
            )
        self.x_ticks_weight = LabelledCombobox(self, text="X Tick Weight", items=font_weights)
        self.x_ticks_rot = LabelledSpinBox(
            self,
            "X Tick Rotation",
            minimum=0,
            maximum=360,
            step=1
            )
        self.y_ticks_fn = FontComboBox(self, "Y Tick Font")
        self.y_ticks_fs = LabelledSpinBox(self, "Y Tick Font Size", minimum=0, step=1)
        self.y_ticks_pad = LabelledDoubleSpinBox(
            self,
            "Y Tick Padding",
            minimum=-100,
            maximum=100,
            step=0.1
            )
        self.y_ticks_weight = LabelledCombobox(self, text="Y Tick Weight", items=font_weights)
        self.y_ticks_rot = LabelledSpinBox(
            self,
            "Y Tick Rotation",
            minimum=0,
            maximum=360,
            step=1
            )
        self.res_label_color = ColourBox(self, text="Residue Label Colour")
        # layout
        self.layout().addWidget(self.x_label, 0, 0)
        self.layout().addWidget(self.y_label, 1, 0)
        self.layout().addWidget(self.mksize, 2, 0)
        self.layout().addWidget(self.color_grad, 3, 0)
        self.layout().addWidget(self.color_start, 4, 0)
        self.layout().addWidget(self.color_end, 5, 0)
        self.layout().addWidget(self.x_label_fn, 6, 0)
        self.layout().addWidget(self.x_label_fs, 7, 0)
        self.layout().addWidget(self.color_list, 8, 0)
        self.layout().addWidget(self.res_label_color, 8, 1)
        self.layout().addWidget(self.x_label_pad, 0, 1)
        self.layout().addWidget(self.x_label_weight, 1, 1)
        self.layout().addWidget(self.y_label_fn, 2, 1)
        self.layout().addWidget(self.y_label_fs, 3, 1)
        self.layout().addWidget(self.y_label_pad, 4, 1)
        self.layout().addWidget(self.y_label_weight, 5, 1)
        self.layout().addWidget(self.x_ticks_fn, 6, 1)
        self.layout().addWidget(self.x_ticks_fs, 7, 1)
        self.layout().addWidget(self.x_ticks_pad, 0, 2)
        self.layout().addWidget(self.x_ticks_weight, 1, 2)
        self.layout().addWidget(self.x_ticks_rot, 2, 2)
        self.layout().addWidget(self.y_ticks_fn, 3, 2)
        self.layout().addWidget(self.y_ticks_fs, 4, 2)
        self.layout().addWidget(self.y_ticks_pad, 5, 2)
        self.layout().addWidget(self.y_ticks_weight, 6, 2)
        self.layout().addWidget(self.y_ticks_rot, 7, 2)
        self.buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok |
            QDialogButtonBox.Cancel |
            QDialogButtonBox.RestoreDefaults
            )
        self.buttonBox.accepted.connect(self.set_values)
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.get_defaults)
        self.layout().addWidget(self.buttonBox, 9, 0, 1, 2)
        self.get_values()

    def get_defaults(self):
        # text
        self.x_label.field.setText(self.defaults["x_label"])
        self.y_label.field.setText(self.defaults["y_label"])
        self.color_list.field.setText(','.join(self.defaults["color_list"]))
        # value
        self.mksize.setValue(self.defaults["mksize"])
        self.x_label_fs.setValue(self.defaults["x_label_fs"])
        self.x_label_pad.setValue(self.defaults["x_label_pad"])
        self.y_label_fs.setValue(self.defaults["y_label_fs"])
        self.y_label_pad.setValue(self.defaults["y_label_pad"])
        self.x_ticks_fs.setValue(self.defaults["x_ticks_fs"])
        self.x_ticks_pad.setValue(self.defaults["x_ticks_pad"])
        self.x_ticks_rot.setValue(self.defaults["x_ticks_rot"])
        self.y_ticks_fs.setValue(self.defaults["y_ticks_fs"])
        self.y_ticks_pad.setValue(self.defaults["y_ticks_pad"])
        self.y_ticks_rot.setValue(self.defaults["y_ticks_rot"])
        # colour
        self.color_start.get_colour(self.defaults["mk_start_color"])
        self.color_end.get_colour(self.defaults["mk_end_color"])
        self.res_label_color.get_colour(self.defaults["res_label_color"])
        # chceked
        self.color_grad.setChecked(self.defaults["color_grad"])
        # dropdown
        self.x_label_fn.select(self.defaults["x_label_fn"])
        self.x_label_weight.select(self.defaults["x_label_weight"])
        self.y_label_fn.select(self.defaults["y_label_fn"])
        self.y_label_weight.select(self.defaults["y_label_weight"])
        self.x_ticks_fn.select(self.defaults["x_ticks_fn"])
        self.x_ticks_weight.select(self.defaults["x_ticks_weight"])
        self.y_ticks_fn.select(self.defaults["y_ticks_fn"])
        self.y_ticks_weight.select(self.defaults["y_ticks_weight"])

    def set_values(self):
        # text
        self.local_variables["x_label"] = self.x_label.field.text()
        self.local_variables["y_label"] = self.y_label.field.text()
        self.local_variables["x_label_fn"] = self.x_label_fn.fields.currentText()
        self.local_variables["x_label_weight"] = self.x_label_weight.fields.currentText()
        self.local_variables["y_label_fn"] = self.y_label_fn.fields.currentText()
        self.local_variables["y_label_weight"] = self.y_label_weight.fields.currentText()
        self.local_variables["x_label_fn"] = self.x_label_fn.fields.currentText()
        self.local_variables["x_label_weight"] = self.x_label_weight.fields.currentText()
        self.local_variables["x_ticks_fn"] = self.x_ticks_fn.fields.currentText()
        self.local_variables["x_ticks_weight"] = self.x_ticks_weight.fields.currentText()
        self.local_variables["y_ticks_fn"] = self.y_ticks_fn.fields.currentText()
        self.local_variables["y_ticks_weight"] = self.y_ticks_weight.fields.currentText()
        # value
        self.local_variables["mksize"] = self.mksize.field.value()
        self.local_variables["x_label_fs"] = self.x_label_fs.field.value()
        self.local_variables["x_label_pad"] = self.x_label_pad.field.value()
        self.local_variables["y_label_fs"] = self.y_label_fs.field.value()
        self.local_variables["y_label_pad"] = self.y_label_pad.field.value()
        self.local_variables["x_label_fs"] = self.x_label_fs.field.value()
        self.local_variables["x_label_pad"] = self.x_label_pad.field.value()
        self.local_variables["x_ticks_fs"] = self.x_ticks_fs.field.value()
        self.local_variables["x_ticks_pad"] = self.x_ticks_pad.field.value()
        self.local_variables["x_ticks_rot"] = self.x_ticks_rot.field.value()
        self.local_variables["y_ticks_fs"] = self.y_ticks_fs.field.value()
        self.local_variables["y_ticks_pad"] = self.y_ticks_pad.field.value()
        self.local_variables["y_ticks_rot"] = self.y_ticks_rot.field.value()
        # check
        self.local_variables["color_grad"] = self.color_grad.isChecked()
        # colours
        self.local_variables["mk_start_color"] = colours[self.color_start.fields.currentText()]
        self.local_variables["mk_end_color"] = colours[self.color_end.fields.currentText()]
        self.local_variables["res_label_color"] = self.res_label_color.fields.currentText()
        self.local_variables["color_list"] = \
            [x.translate(translator) for x in self.color_list.field.text().split(',')]
        self.accept()

    def get_values(self):
        # text
        self.x_label.field.setText(self.local_variables["x_label"])
        self.y_label.field.setText(self.local_variables["y_label"])
        self.color_list.field.setText(','.join(self.local_variables["color_list"]))
        # value
        self.mksize.setValue(self.local_variables["mksize"])
        self.x_label_fs.setValue(self.local_variables["x_label_fs"])
        self.x_label_pad.setValue(self.local_variables["x_label_pad"])
        self.y_label_fs.setValue(self.local_variables["y_label_fs"])
        self.y_label_pad.setValue(self.local_variables["y_label_pad"])
        self.x_ticks_fs.setValue(self.local_variables["x_ticks_fs"])
        self.x_ticks_pad.setValue(self.local_variables["x_ticks_pad"])
        self.x_ticks_rot.setValue(self.local_variables["x_ticks_rot"])
        self.y_ticks_fs.setValue(self.local_variables["y_ticks_fs"])
        self.y_ticks_pad.setValue(self.local_variables["y_ticks_pad"])
        self.y_ticks_rot.setValue(self.local_variables["y_ticks_rot"])
        # checked
        self.color_grad.setChecked(self.local_variables["color_grad"])
        # colours
        self.color_start.get_colour(self.local_variables["mk_start_color"])
        self.color_end.get_colour(self.local_variables["mk_end_color"])
        self.res_label_color.get_colour(self.local_variables["res_label_color"])
        # dropdown
        self.x_label_fn.select(self.local_variables["x_label_fn"])
        self.x_label_weight.select(self.local_variables["x_label_weight"])
        self.y_label_fn.select(self.local_variables["y_label_fn"])
        self.y_label_weight.select(self.local_variables["y_label_weight"])
        self.x_ticks_fn.select(self.local_variables["x_ticks_fn"])
        self.x_ticks_weight.select(self.local_variables["x_ticks_weight"])
        self.y_ticks_fn.select(self.local_variables["y_ticks_fn"])
        self.y_ticks_weight.select(self.local_variables["y_ticks_weight"])
class CompactBarPopup(BasePopup):
    """
    A popup for setting Compact Bar Plot specific settings in the Farseer-NMR
    configuration.

    Parameters:
        parent(QWidget): parent widget for popup.

    Methods:
        .get_defaults()
        .get_values()
        .set_values()
    """
    def __init__(self, parent=None, **kw):
        BasePopup.__init__(self, parent, "compact_bar_settings", "Compact Bar"
                           "Plot")
        self.bar_cols = LabelledSpinBox(self,
                                        text="Columns Per Page",
                                        minimum=1,
                                        step=1)
        self.bar_rows = LabelledSpinBox(self,
                                        text="Rows Per Page",
                                        minimum=1,
                                        step=1)
        self.x_tick_font = FontComboBox(self, "X Tick Font")
        self.x_tick_font_size = LabelledSpinBox(self,
                                                "X Tick Font Size",
                                                minimum=0,
                                                step=1)
        self.x_tick_rotation = LabelledSpinBox(self,
                                               "X Tick Rotation",
                                               minimum=0,
                                               maximum=360,
                                               step=1)
        self.x_tick_weight = LabelledCombobox(self,
                                              "X Tick Font Weight",
                                              items=font_weights)
        self.shade_unassigned_checkbox = LabelledCheckbox(
            self, "Shade Unassigned?")
        self.unassigned_shade_alpha = LabelledDoubleSpinBox(self,
                                                            "Unassigned Shade "
                                                            "Transparency",
                                                            minimum=0,
                                                            maximum=1,
                                                            step=0.1)
        self.layout().addWidget(self.bar_cols, 0, 0)
        self.layout().addWidget(self.bar_rows, 1, 0)
        self.layout().addWidget(self.x_tick_font_size, 2, 0)
        self.layout().addWidget(self.x_tick_font, 3, 0)
        self.layout().addWidget(self.x_tick_rotation, 4, 0)
        self.layout().addWidget(self.x_tick_weight, 5, 0)
        self.layout().addWidget(self.shade_unassigned_checkbox, 6, 0)
        self.layout().addWidget(self.unassigned_shade_alpha, 7, 0)
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel
                                          | QDialogButtonBox.RestoreDefaults)
        self.buttonBox.accepted.connect(self.set_values)
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.button(
            QDialogButtonBox.RestoreDefaults).clicked.connect(
                self.get_defaults)
        self.layout().addWidget(self.buttonBox, 8, 0)
        self.get_values()

    def get_defaults(self):
        # value
        self.bar_cols.setValue(self.defaults["cols_page"])
        self.bar_rows.setValue(self.defaults["rows_page"])
        self.x_tick_font_size.setValue(self.defaults["x_ticks_fs"])
        self.x_tick_rotation.setValue(self.defaults["x_ticks_rot"])
        self.unassigned_shade_alpha.setValue(
            self.defaults["unassigned_shade_alpha"])
        # drop down list
        self.x_tick_font.select(self.defaults["x_ticks_fn"])
        self.x_tick_weight.select(self.defaults["x_ticks_weight"])
        # check
        self.shade_unassigned_checkbox.setChecked(
            self.defaults["unassigned_shade"])

    def get_values(self):
        # value
        self.bar_cols.setValue(self.local_variables["cols_page"])
        self.bar_rows.setValue(self.local_variables["rows_page"])
        self.x_tick_font_size.setValue(self.local_variables["x_ticks_fs"])
        self.x_tick_rotation.setValue(self.local_variables["x_ticks_rot"])
        self.unassigned_shade_alpha.setValue(
            self.local_variables["unassigned_shade_alpha"])
        # drop down list
        self.x_tick_font.select(self.local_variables["x_ticks_fn"])
        self.x_tick_weight.select(self.local_variables["x_ticks_weight"])
        # checkbox
        self.shade_unassigned_checkbox.setChecked(
            self.local_variables["unassigned_shade"])

    def set_values(self):
        # value
        self.local_variables["cols_page"] = self.bar_cols.field.value()
        self.local_variables["rows_page"] = self.bar_rows.field.value()
        self.local_variables["x_ticks_fs"] = self.x_tick_font_size.field.value(
        )
        self.local_variables["x_ticks_rot"] = self.x_tick_rotation.field.value(
        )
        self.local_variables[
            "unassigned_shade_alpha"] = self.unassigned_shade_alpha.field.value(
            )
        # dropdown list
        self.local_variables["x_ticks_fn"] = str(
            self.x_tick_font.fields.currentText())
        self.local_variables["x_ticks_weight"] = str(
            self.x_tick_weight.fields.currentText())
        # check
        self.local_variables[
            "unassigned_shade"] = self.shade_unassigned_checkbox.isChecked()
        #
        self.accept()
 def __init__(self, parent=None, **kw):
     BasePopup.__init__(self,
                        parent,
                        title="DPRE Plot",
                        settings_key=["DPRE_plot_settings"])
     self.DPRE_plot_rows = LabelledSpinBox(self,
                                           "Number of Rows",
                                           minimum=1,
                                           step=1)
     self.DPRE_plot_width = LabelledSpinBox(self, "Scale Factor for Width")
     self.DPRE_plot_y_label = LabelledLineEdit(self, "Y Label")
     self.DPRE_plot_y_label_fs = LabelledSpinBox(self,
                                                 "Y Label Font Size",
                                                 minimum=0,
                                                 step=1)
     self.DPRE_plot_ymax = LabelledDoubleSpinBox(self,
                                                 "Y Maximum",
                                                 minimum=0,
                                                 step=0.1)
     self.DPRE_plot_dpre_ms = LabelledSpinBox(self,
                                              "Marker Size",
                                              minimum=0,
                                              step=1)
     self.DPRE_plot_dpre_alpha = LabelledDoubleSpinBox(
         self, "Marker Transparency", minimum=0, maximum=1, step=0.1)
     self.DPRE_plot_smooth_lw = LabelledSpinBox(self,
                                                "Smoothed DPRE Line Width",
                                                minimum=0,
                                                step=1)
     self.DPRE_plot_ref_color = ColourBox(self, "Reference Data Colour")
     self.DPRE_plot_color_init = ColourBox(self, "Grad Start Colour")
     self.DPRE_plot_color_end = ColourBox(self, "Grad End Colour")
     self.DPRE_plot_x_ticks_fn = FontComboBox(self, "X Tick Font")
     self.DPRE_plot_x_ticks_fs = LabelledSpinBox(self,
                                                 "X Tick Font Size",
                                                 minimum=0,
                                                 step=1)
     self.DPRE_plot_x_ticks_pad = LabelledDoubleSpinBox(self,
                                                        "X Tick Padding",
                                                        minimum=-100,
                                                        maximum=100,
                                                        step=0.1)
     self.DPRE_plot_x_ticks_weight = LabelledCombobox(self,
                                                      text="X Font Weight",
                                                      items=font_weights)
     self.DPRE_plot_grid_color = ColourBox(self, "Grid Colour")
     self.DPRE_plot_res_highlight = LabelledCheckbox(
         self, "Highlight Residues?")
     self.DPRE_plot_res_highlight_list = LabelledLineEdit(
         self, "Residues to Highlight")
     self.DPRE_plot_shade = LabelledCheckbox(self, "Shade Residues?")
     self.DPRE_plot_regions = LabelledLineEdit(self, "Regions to Shade")
     self.DPRE_plot_rh_fs = LabelledSpinBox(self,
                                            "Highlight Font Size ",
                                            minimum=0,
                                            step=1)
     self.DPRE_plot_rh_y = LabelledDoubleSpinBox(self,
                                                 "Residue Label Scale",
                                                 minimum=0,
                                                 maximum=1,
                                                 step=0.01)
     self.layout().addWidget(self.DPRE_plot_rows, 0, 0)
     self.layout().addWidget(self.DPRE_plot_width, 1, 0)
     self.layout().addWidget(self.DPRE_plot_y_label, 2, 0)
     self.layout().addWidget(self.DPRE_plot_ref_color, 3, 0)
     self.layout().addWidget(self.DPRE_plot_color_init, 4, 0)
     self.layout().addWidget(self.DPRE_plot_color_end, 5, 0)
     self.layout().addWidget(self.DPRE_plot_x_ticks_fs, 6, 0)
     self.layout().addWidget(self.DPRE_plot_x_ticks_fn, 7, 0)
     self.layout().addWidget(self.DPRE_plot_x_ticks_pad, 8, 0)
     self.layout().addWidget(self.DPRE_plot_x_ticks_weight, 9, 0)
     self.layout().addWidget(self.DPRE_plot_grid_color, 10, 0)
     self.layout().addWidget(self.DPRE_plot_dpre_ms, 0, 1)
     self.layout().addWidget(self.DPRE_plot_dpre_alpha, 1, 1)
     self.layout().addWidget(self.DPRE_plot_y_label_fs, 2, 1)
     self.layout().addWidget(self.DPRE_plot_smooth_lw, 3, 1)
     self.layout().addWidget(self.DPRE_plot_res_highlight, 4, 1)
     self.layout().addWidget(self.DPRE_plot_res_highlight_list, 5, 1)
     self.layout().addWidget(self.DPRE_plot_shade, 6, 1)
     self.layout().addWidget(self.DPRE_plot_regions, 7, 1)
     self.layout().addWidget(self.DPRE_plot_rh_fs, 8, 1)
     self.layout().addWidget(self.DPRE_plot_rh_y, 9, 1)
     self.layout().addWidget(self.DPRE_plot_ymax, 10, 1)
     self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                       | QDialogButtonBox.Cancel
                                       | QDialogButtonBox.RestoreDefaults)
     self.buttonBox.accepted.connect(self.set_values)
     self.buttonBox.rejected.connect(self.reject)
     self.buttonBox.button(
         QDialogButtonBox.RestoreDefaults).clicked.connect(
             self.get_defaults)
     self.layout().addWidget(self.buttonBox, 11, 0, 2, 2)
     self.get_values()
class DeltaPREPlotPopup(BasePopup):
    """
    A popup for setting Delta PRE Plot specific settings in the
    Farseer-NMR configuration.

    Parameters:
        parent(QWidget): parent widget for popup.

    Methods:
        .get_defaults()
        .get_values()
        .set_values()
    """
    def __init__(self, parent=None, **kw):
        BasePopup.__init__(self,
                           parent,
                           title="DPRE Plot",
                           settings_key=["DPRE_plot_settings"])
        self.DPRE_plot_rows = LabelledSpinBox(self,
                                              "Number of Rows",
                                              minimum=1,
                                              step=1)
        self.DPRE_plot_width = LabelledSpinBox(self, "Scale Factor for Width")
        self.DPRE_plot_y_label = LabelledLineEdit(self, "Y Label")
        self.DPRE_plot_y_label_fs = LabelledSpinBox(self,
                                                    "Y Label Font Size",
                                                    minimum=0,
                                                    step=1)
        self.DPRE_plot_ymax = LabelledDoubleSpinBox(self,
                                                    "Y Maximum",
                                                    minimum=0,
                                                    step=0.1)
        self.DPRE_plot_dpre_ms = LabelledSpinBox(self,
                                                 "Marker Size",
                                                 minimum=0,
                                                 step=1)
        self.DPRE_plot_dpre_alpha = LabelledDoubleSpinBox(
            self, "Marker Transparency", minimum=0, maximum=1, step=0.1)
        self.DPRE_plot_smooth_lw = LabelledSpinBox(self,
                                                   "Smoothed DPRE Line Width",
                                                   minimum=0,
                                                   step=1)
        self.DPRE_plot_ref_color = ColourBox(self, "Reference Data Colour")
        self.DPRE_plot_color_init = ColourBox(self, "Grad Start Colour")
        self.DPRE_plot_color_end = ColourBox(self, "Grad End Colour")
        self.DPRE_plot_x_ticks_fn = FontComboBox(self, "X Tick Font")
        self.DPRE_plot_x_ticks_fs = LabelledSpinBox(self,
                                                    "X Tick Font Size",
                                                    minimum=0,
                                                    step=1)
        self.DPRE_plot_x_ticks_pad = LabelledDoubleSpinBox(self,
                                                           "X Tick Padding",
                                                           minimum=-100,
                                                           maximum=100,
                                                           step=0.1)
        self.DPRE_plot_x_ticks_weight = LabelledCombobox(self,
                                                         text="X Font Weight",
                                                         items=font_weights)
        self.DPRE_plot_grid_color = ColourBox(self, "Grid Colour")
        self.DPRE_plot_res_highlight = LabelledCheckbox(
            self, "Highlight Residues?")
        self.DPRE_plot_res_highlight_list = LabelledLineEdit(
            self, "Residues to Highlight")
        self.DPRE_plot_shade = LabelledCheckbox(self, "Shade Residues?")
        self.DPRE_plot_regions = LabelledLineEdit(self, "Regions to Shade")
        self.DPRE_plot_rh_fs = LabelledSpinBox(self,
                                               "Highlight Font Size ",
                                               minimum=0,
                                               step=1)
        self.DPRE_plot_rh_y = LabelledDoubleSpinBox(self,
                                                    "Residue Label Scale",
                                                    minimum=0,
                                                    maximum=1,
                                                    step=0.01)
        self.layout().addWidget(self.DPRE_plot_rows, 0, 0)
        self.layout().addWidget(self.DPRE_plot_width, 1, 0)
        self.layout().addWidget(self.DPRE_plot_y_label, 2, 0)
        self.layout().addWidget(self.DPRE_plot_ref_color, 3, 0)
        self.layout().addWidget(self.DPRE_plot_color_init, 4, 0)
        self.layout().addWidget(self.DPRE_plot_color_end, 5, 0)
        self.layout().addWidget(self.DPRE_plot_x_ticks_fs, 6, 0)
        self.layout().addWidget(self.DPRE_plot_x_ticks_fn, 7, 0)
        self.layout().addWidget(self.DPRE_plot_x_ticks_pad, 8, 0)
        self.layout().addWidget(self.DPRE_plot_x_ticks_weight, 9, 0)
        self.layout().addWidget(self.DPRE_plot_grid_color, 10, 0)
        self.layout().addWidget(self.DPRE_plot_dpre_ms, 0, 1)
        self.layout().addWidget(self.DPRE_plot_dpre_alpha, 1, 1)
        self.layout().addWidget(self.DPRE_plot_y_label_fs, 2, 1)
        self.layout().addWidget(self.DPRE_plot_smooth_lw, 3, 1)
        self.layout().addWidget(self.DPRE_plot_res_highlight, 4, 1)
        self.layout().addWidget(self.DPRE_plot_res_highlight_list, 5, 1)
        self.layout().addWidget(self.DPRE_plot_shade, 6, 1)
        self.layout().addWidget(self.DPRE_plot_regions, 7, 1)
        self.layout().addWidget(self.DPRE_plot_rh_fs, 8, 1)
        self.layout().addWidget(self.DPRE_plot_rh_y, 9, 1)
        self.layout().addWidget(self.DPRE_plot_ymax, 10, 1)
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel
                                          | QDialogButtonBox.RestoreDefaults)
        self.buttonBox.accepted.connect(self.set_values)
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.button(
            QDialogButtonBox.RestoreDefaults).clicked.connect(
                self.get_defaults)
        self.layout().addWidget(self.buttonBox, 11, 0, 2, 2)
        self.get_values()

    def set_ranges(self, field_value):
        ll = field_value.split(',')
        return [[int(x.split('-')[0]), int(x.split('-')[1])] for x in ll]

    def get_ranges(self, ranges):
        return ','.join(["%s-%s" % (x[0], x[1]) for x in ranges])

    def get_defaults(self):
        # value
        self.DPRE_plot_rows.setValue(self.defaults["rows"])
        self.DPRE_plot_width.setValue(self.defaults["width"])
        self.DPRE_plot_y_label_fs.setValue(self.defaults["y_label_fs"])
        self.DPRE_plot_dpre_ms.setValue(self.defaults["dpre_ms"])
        self.DPRE_plot_dpre_alpha.setValue(self.defaults["dpre_alpha"])
        self.DPRE_plot_smooth_lw.setValue(self.defaults["smooth_lw"])
        self.DPRE_plot_x_ticks_fs.setValue(self.defaults["x_ticks_fs"])
        self.DPRE_plot_x_ticks_pad.setValue(self.defaults["x_ticks_pad"])
        self.DPRE_plot_rh_fs.setValue(self.defaults["res_highlight_fs"])
        self.DPRE_plot_rh_y.setValue(self.defaults["res_highlight_y"])
        self.DPRE_plot_ymax.setValue(self.defaults["ymax"])
        # text
        self.DPRE_plot_y_label.setText(self.defaults["y_label"])
        self.DPRE_plot_regions.setText(
            self.get_ranges(self.defaults["shade_regions"]))
        # colour
        self.DPRE_plot_ref_color.get_colour(self.defaults["ref_color"])
        self.DPRE_plot_color_init.get_colour(self.defaults["color_init"])
        self.DPRE_plot_color_end.get_colour(self.defaults["color_end"])
        self.DPRE_plot_grid_color.get_colour(self.defaults["grid_color"])
        # dropdown
        self.DPRE_plot_x_ticks_fn.select(self.defaults["x_ticks_fn"])
        self.DPRE_plot_x_ticks_weight.select(self.defaults["x_ticks_weight"])
        # check
        self.DPRE_plot_shade.setChecked(self.defaults["shade"])
        self.DPRE_plot_res_highlight.setChecked(self.defaults["res_highlight"])
        # list
        self.DPRE_plot_res_highlight_list.field.setText(','.join(
            list(map(str, self.defaults["res_hl_list"]))))

    def set_values(self):
        # value
        self.local_variables["rows"] = self.DPRE_plot_rows.field.value()
        self.local_variables["width"] = self.DPRE_plot_width.field.value()
        self.local_variables[
            "y_label_fs"] = self.DPRE_plot_y_label_fs.field.value()
        self.local_variables["dpre_ms"] = self.DPRE_plot_dpre_ms.field.value()
        self.local_variables[
            "dpre_alpha"] = self.DPRE_plot_dpre_alpha.field.value()
        self.local_variables[
            "smooth_lw"] = self.DPRE_plot_smooth_lw.field.value()
        self.local_variables[
            "x_ticks_fs"] = self.DPRE_plot_x_ticks_fs.field.value()
        self.local_variables[
            "x_ticks_pad"] = self.DPRE_plot_x_ticks_pad.field.value()
        self.local_variables[
            "res_highlight_fs"] = self.DPRE_plot_rh_fs.field.value()
        self.local_variables[
            "res_highlight_y"] = self.DPRE_plot_rh_y.field.value()
        self.local_variables["ymax"] = self.DPRE_plot_ymax.field.value()
        # text
        self.local_variables["y_label"] = self.DPRE_plot_y_label.field.text()
        self.local_variables["shade_regions"] = self.set_ranges(
            self.DPRE_plot_regions.field.text())
        self.local_variables["res_hl_list"] = \
            list(map(int, self.DPRE_plot_res_highlight_list.field.text().split(',')))
        # dropdown
        self.local_variables[
            "ref_color"] = self.DPRE_plot_ref_color.fields.currentText()
        self.local_variables[
            "x_ticks_fn"] = self.DPRE_plot_x_ticks_fn.fields.currentText()
        self.local_variables[
            "x_ticks_weight"] = self.DPRE_plot_x_ticks_weight.fields.currentText(
            )
        # colour
        self.local_variables["color_init"] = colours[
            self.DPRE_plot_color_init.fields.currentText()]
        self.local_variables["color_end"] = colours[
            self.DPRE_plot_color_end.fields.currentText()]
        self.local_variables[
            "grid_color"] = self.DPRE_plot_grid_color.fields.currentText()
        # checkbox
        self.local_variables["shade"] = self.DPRE_plot_shade.isChecked()
        self.local_variables[
            "res_highlight"] = self.DPRE_plot_res_highlight.isChecked()
        self.accept()

    def get_values(self):
        # value
        self.DPRE_plot_rows.setValue(self.local_variables["rows"])
        self.DPRE_plot_width.setValue(self.local_variables["width"])
        self.DPRE_plot_y_label_fs.setValue(self.local_variables["y_label_fs"])
        self.DPRE_plot_dpre_ms.setValue(self.local_variables["dpre_ms"])
        self.DPRE_plot_dpre_alpha.setValue(self.local_variables["dpre_alpha"])
        self.DPRE_plot_smooth_lw.setValue(self.local_variables["smooth_lw"])
        self.DPRE_plot_x_ticks_fs.setValue(self.local_variables["x_ticks_fs"])
        self.DPRE_plot_x_ticks_pad.setValue(
            self.local_variables["x_ticks_pad"])
        self.DPRE_plot_rh_fs.setValue(self.local_variables["res_highlight_fs"])
        self.DPRE_plot_rh_y.setValue(self.local_variables["res_highlight_y"])
        self.DPRE_plot_ymax.setValue(self.local_variables["ymax"])
        # text
        self.DPRE_plot_y_label.setText(self.local_variables["y_label"])
        self.DPRE_plot_res_highlight_list.field.setText(','.join(
            list(map(str, self.local_variables["res_hl_list"]))))
        self.DPRE_plot_regions.setText(
            self.get_ranges(self.local_variables["shade_regions"]))
        # colour
        self.DPRE_plot_ref_color.get_colour(self.local_variables["ref_color"])
        self.DPRE_plot_color_init.get_colour(
            self.local_variables["color_init"])
        self.DPRE_plot_color_end.get_colour(self.local_variables["color_end"])
        self.DPRE_plot_grid_color.get_colour(
            self.local_variables["grid_color"])
        # dropdown
        self.DPRE_plot_x_ticks_fn.select(self.local_variables["x_ticks_fn"])
        self.DPRE_plot_x_ticks_weight.select(
            self.local_variables["x_ticks_weight"])
        # checked
        self.DPRE_plot_shade.setChecked(self.local_variables["shade"])
        self.DPRE_plot_res_highlight.setChecked(
            self.local_variables["res_highlight"])
 def __init__(self, parent=None, **kw):
     BasePopup.__init__(self,
                        parent,
                        title="Series General Plot Settings",
                        settings_key=["series_plot_settings"])
     self.series_subtitle_groupbox = QGroupBox()
     self.series_subtitle_groupbox_layout = QVBoxLayout()
     self.series_subtitle_groupbox.setLayout(
         self.series_subtitle_groupbox_layout)
     self.series_subtitle_groupbox.setTitle("Subtitle Settings")
     self.series_subtitle_fn = FontComboBox(self, "Subtitle Font")
     self.series_subtitle_fs = LabelledSpinBox(self,
                                               "Subtitle Font Size",
                                               minimum=0,
                                               step=1)
     self.series_subtitle_pad = LabelledDoubleSpinBox(self,
                                                      "Subtitle Padding",
                                                      minimum=-100,
                                                      maximum=100,
                                                      step=0.1)
     self.series_subtitle_weight = LabelledCombobox(self,
                                                    text="Subtitle "
                                                    "Font Weight",
                                                    items=font_weights)
     self.series_x_label_groupbox = QGroupBox()
     self.series_x_label_groupbox_layout = QVBoxLayout()
     self.series_x_label_groupbox.setLayout(
         self.series_x_label_groupbox_layout)
     self.series_x_label_groupbox.setTitle("X Label Settings")
     self.series_x_label_fn = FontComboBox(self, "X Font Label")
     self.series_x_label_fs = LabelledSpinBox(self,
                                              "X Label Font Size",
                                              minimum=0,
                                              step=1)
     self.series_x_label_pad = LabelledDoubleSpinBox(self,
                                                     "X Label Padding",
                                                     minimum=-100,
                                                     maximum=100,
                                                     step=0.1)
     self.series_x_label_weight = LabelledCombobox(self,
                                                   text="X Label F"
                                                   "ont Weight",
                                                   items=font_weights)
     self.series_y_label_groupbox = QGroupBox()
     self.series_y_label_groupbox_layout = QVBoxLayout()
     self.series_y_label_groupbox.setLayout(
         self.series_y_label_groupbox_layout)
     self.series_y_label_groupbox.setTitle("Y Label Settings")
     self.series_y_tick_groupbox = QGroupBox()
     self.series_y_tick_groupbox_layout = QVBoxLayout()
     self.series_y_tick_groupbox.setLayout(
         self.series_y_tick_groupbox_layout)
     self.series_y_tick_groupbox.setTitle("Tick Settings")
     self.series_y_label_fn = FontComboBox(self, "Y Label Font")
     self.series_y_label_fs = LabelledSpinBox(self,
                                              "Y Label Font Size",
                                              minimum=0,
                                              step=1)
     self.series_y_label_pad = LabelledDoubleSpinBox(self,
                                                     "Y Label Padding",
                                                     minimum=-100,
                                                     maximum=100,
                                                     step=0.1)
     self.series_y_label_weight = LabelledCombobox(self,
                                                   text="Y Label "
                                                   "Font Weight",
                                                   items=font_weights)
     self.series_x_ticks_pad = LabelledDoubleSpinBox(self,
                                                     "X Tick Padding",
                                                     minimum=-100,
                                                     maximum=100,
                                                     step=0.1)
     self.series_x_ticks_len = LabelledDoubleSpinBox(self,
                                                     "X Tick Length",
                                                     minimum=0,
                                                     maximum=100,
                                                     step=0.1)
     self.series_y_ticks_fn = FontComboBox(self, "Y Tick Font")
     self.series_y_ticks_fs = LabelledSpinBox(self,
                                              "Y Tick Font Size",
                                              minimum=0,
                                              step=1)
     self.series_y_ticks_rot = LabelledSpinBox(self,
                                               "Y Tick Rotation",
                                               minimum=0,
                                               maximum=360,
                                               step=1)
     self.series_y_ticks_pad = LabelledDoubleSpinBox(self,
                                                     "Y Tick Padding",
                                                     minimum=-100,
                                                     maximum=100,
                                                     step=0.1)
     self.series_y_ticks_weight = LabelledCombobox(self,
                                                   text="Y Tick "
                                                   "Font Weight",
                                                   items=font_weights)
     self.series_y_ticks_len = LabelledDoubleSpinBox(self,
                                                     "Y Tick Length",
                                                     minimum=0,
                                                     maximum=100,
                                                     step=0.1)
     self.series_y_grid_flag = LabelledCheckbox(self, "Show Y Grid")
     self.series_y_grid_color = ColourBox(self, "Y Grid Colour")
     self.series_y_grid_linestyle = LabelledCombobox(
         self, text="Y Grid "
         "Line Style", items=['-', '--', '-.', ':'])
     self.series_y_grid_linewidth = LabelledDoubleSpinBox(
         self, "Y Grid Line "
         "Width")
     self.series_y_grid_alpha = LabelledDoubleSpinBox(self,
                                                      "Y Grid Transparency",
                                                      minimum=0,
                                                      maximum=1,
                                                      step=0.1)
     self.series_vspace = LabelledDoubleSpinBox(self,
                                                "Plot Vertical Spacing",
                                                minimum=-100,
                                                maximum=100,
                                                step=0.1)
     self.theo_pre_groupbox = QGroupBox()
     self.theo_pre_groupbox_layout = QVBoxLayout()
     self.theo_pre_groupbox.setLayout(self.theo_pre_groupbox_layout)
     self.theo_pre_groupbox.setTitle("Dedicated PRE Settings")
     self.theo_pre_color = ColourBox(self, "Theoretical PRE Line Colour")
     self.theo_pre_lw = LabelledDoubleSpinBox(self,
                                              "Theoretical PRE Line Width",
                                              minimum=0,
                                              step=0.1)
     self.tag_cartoon_color = ColourBox(self, "Tag Pin Colour")
     self.tag_cartoon_lw = LabelledDoubleSpinBox(self,
                                                 "Tag Pin Line Width",
                                                 minimum=0,
                                                 step=0.1)
     self.tag_cartoon_ls = LabelledCombobox(self,
                                            "Tag Pin Line Style",
                                            items=line_styles)
     self.theo_pre_groupbox.layout().addWidget(self.theo_pre_color)
     self.theo_pre_groupbox.layout().addWidget(self.theo_pre_lw)
     self.theo_pre_groupbox.layout().addWidget(self.tag_cartoon_color)
     self.theo_pre_groupbox.layout().addWidget(self.tag_cartoon_lw)
     self.theo_pre_groupbox.layout().addWidget(self.tag_cartoon_ls)
     self.series_subtitle_groupbox.layout().addWidget(
         self.series_subtitle_fn)
     self.series_subtitle_groupbox.layout().addWidget(
         self.series_subtitle_fs)
     self.series_subtitle_groupbox.layout().addWidget(
         self.series_subtitle_pad)
     self.series_subtitle_groupbox.layout().addWidget(
         self.series_subtitle_weight)
     self.series_x_label_groupbox.layout().addWidget(self.series_x_label_fn)
     self.series_x_label_groupbox.layout().addWidget(self.series_x_label_fs)
     self.series_x_label_groupbox.layout().addWidget(
         self.series_x_label_pad)
     self.series_x_label_groupbox.layout().addWidget(
         self.series_x_label_weight)
     self.layout().addWidget(self.series_subtitle_groupbox, 0, 0, 4, 1)
     self.layout().addWidget(self.series_x_label_groupbox, 0, 1, 4, 1)
     self.layout().addWidget(self.theo_pre_groupbox, 0, 2, 4, 1)
     self.series_y_label_groupbox.layout().addWidget(self.series_y_label_fn)
     self.series_y_label_groupbox.layout().addWidget(self.series_y_label_fs)
     self.series_y_label_groupbox.layout().addWidget(
         self.series_y_label_weight)
     self.series_y_label_groupbox.layout().addWidget(
         self.series_y_label_pad)
     self.layout().addWidget(self.series_y_label_groupbox, 4, 1, 4, 1)
     self.series_y_tick_groupbox.layout().addWidget(self.series_x_ticks_pad)
     self.series_y_tick_groupbox.layout().addWidget(self.series_x_ticks_len)
     self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_fn)
     self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_fs)
     self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_rot)
     self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_pad)
     self.series_y_label_groupbox.layout().addWidget(
         self.series_y_ticks_weight)
     self.series_y_label_groupbox.layout().addWidget(
         self.series_y_ticks_len)
     self.layout().addWidget(self.series_y_tick_groupbox, 4, 0, 4, 1)
     self.series_y_grid_groupbox = QGroupBox()
     self.series_y_grid_groupbox_layout = QVBoxLayout()
     self.series_y_grid_groupbox.setLayout(
         self.series_y_grid_groupbox_layout)
     self.series_y_grid_groupbox.setTitle("Y Grid Settings")
     self.series_y_grid_groupbox.layout().addWidget(self.series_y_grid_flag)
     self.series_y_grid_groupbox.layout().addWidget(
         self.series_y_grid_color)
     self.series_y_grid_groupbox.layout().addWidget(
         self.series_y_grid_linestyle)
     self.series_y_grid_groupbox.layout().addWidget(
         self.series_y_grid_linewidth)
     self.series_y_grid_groupbox.layout().addWidget(
         self.series_y_grid_alpha)
     self.series_y_grid_groupbox.layout().addWidget(self.series_vspace)
     self.layout().addWidget(self.series_y_grid_groupbox, 4, 2, 4, 1)
     self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                       | QDialogButtonBox.Cancel
                                       | QDialogButtonBox.RestoreDefaults)
     self.buttonBox.accepted.connect(self.set_values)
     self.buttonBox.rejected.connect(self.reject)
     self.buttonBox.button(
         QDialogButtonBox.RestoreDefaults).clicked.connect(
             self.get_defaults)
     self.layout().addWidget(self.buttonBox, 8, 2, 1, 1)
     self.get_values()
class SeriesPlotPopup(BasePopup):
    """
    A popup for setting Series Plot specific settings in the Farseer-NMR
    configuration.

    Parameters:
        parent(QWidget): parent widget for popup.

    Methods:
        .get_defaults()
        .get_values()
        .set_values()
    """
    def __init__(self, parent=None, **kw):
        BasePopup.__init__(self,
                           parent,
                           title="Series General Plot Settings",
                           settings_key=["series_plot_settings"])
        self.series_subtitle_groupbox = QGroupBox()
        self.series_subtitle_groupbox_layout = QVBoxLayout()
        self.series_subtitle_groupbox.setLayout(
            self.series_subtitle_groupbox_layout)
        self.series_subtitle_groupbox.setTitle("Subtitle Settings")
        self.series_subtitle_fn = FontComboBox(self, "Subtitle Font")
        self.series_subtitle_fs = LabelledSpinBox(self,
                                                  "Subtitle Font Size",
                                                  minimum=0,
                                                  step=1)
        self.series_subtitle_pad = LabelledDoubleSpinBox(self,
                                                         "Subtitle Padding",
                                                         minimum=-100,
                                                         maximum=100,
                                                         step=0.1)
        self.series_subtitle_weight = LabelledCombobox(self,
                                                       text="Subtitle "
                                                       "Font Weight",
                                                       items=font_weights)
        self.series_x_label_groupbox = QGroupBox()
        self.series_x_label_groupbox_layout = QVBoxLayout()
        self.series_x_label_groupbox.setLayout(
            self.series_x_label_groupbox_layout)
        self.series_x_label_groupbox.setTitle("X Label Settings")
        self.series_x_label_fn = FontComboBox(self, "X Font Label")
        self.series_x_label_fs = LabelledSpinBox(self,
                                                 "X Label Font Size",
                                                 minimum=0,
                                                 step=1)
        self.series_x_label_pad = LabelledDoubleSpinBox(self,
                                                        "X Label Padding",
                                                        minimum=-100,
                                                        maximum=100,
                                                        step=0.1)
        self.series_x_label_weight = LabelledCombobox(self,
                                                      text="X Label F"
                                                      "ont Weight",
                                                      items=font_weights)
        self.series_y_label_groupbox = QGroupBox()
        self.series_y_label_groupbox_layout = QVBoxLayout()
        self.series_y_label_groupbox.setLayout(
            self.series_y_label_groupbox_layout)
        self.series_y_label_groupbox.setTitle("Y Label Settings")
        self.series_y_tick_groupbox = QGroupBox()
        self.series_y_tick_groupbox_layout = QVBoxLayout()
        self.series_y_tick_groupbox.setLayout(
            self.series_y_tick_groupbox_layout)
        self.series_y_tick_groupbox.setTitle("Tick Settings")
        self.series_y_label_fn = FontComboBox(self, "Y Label Font")
        self.series_y_label_fs = LabelledSpinBox(self,
                                                 "Y Label Font Size",
                                                 minimum=0,
                                                 step=1)
        self.series_y_label_pad = LabelledDoubleSpinBox(self,
                                                        "Y Label Padding",
                                                        minimum=-100,
                                                        maximum=100,
                                                        step=0.1)
        self.series_y_label_weight = LabelledCombobox(self,
                                                      text="Y Label "
                                                      "Font Weight",
                                                      items=font_weights)
        self.series_x_ticks_pad = LabelledDoubleSpinBox(self,
                                                        "X Tick Padding",
                                                        minimum=-100,
                                                        maximum=100,
                                                        step=0.1)
        self.series_x_ticks_len = LabelledDoubleSpinBox(self,
                                                        "X Tick Length",
                                                        minimum=0,
                                                        maximum=100,
                                                        step=0.1)
        self.series_y_ticks_fn = FontComboBox(self, "Y Tick Font")
        self.series_y_ticks_fs = LabelledSpinBox(self,
                                                 "Y Tick Font Size",
                                                 minimum=0,
                                                 step=1)
        self.series_y_ticks_rot = LabelledSpinBox(self,
                                                  "Y Tick Rotation",
                                                  minimum=0,
                                                  maximum=360,
                                                  step=1)
        self.series_y_ticks_pad = LabelledDoubleSpinBox(self,
                                                        "Y Tick Padding",
                                                        minimum=-100,
                                                        maximum=100,
                                                        step=0.1)
        self.series_y_ticks_weight = LabelledCombobox(self,
                                                      text="Y Tick "
                                                      "Font Weight",
                                                      items=font_weights)
        self.series_y_ticks_len = LabelledDoubleSpinBox(self,
                                                        "Y Tick Length",
                                                        minimum=0,
                                                        maximum=100,
                                                        step=0.1)
        self.series_y_grid_flag = LabelledCheckbox(self, "Show Y Grid")
        self.series_y_grid_color = ColourBox(self, "Y Grid Colour")
        self.series_y_grid_linestyle = LabelledCombobox(
            self, text="Y Grid "
            "Line Style", items=['-', '--', '-.', ':'])
        self.series_y_grid_linewidth = LabelledDoubleSpinBox(
            self, "Y Grid Line "
            "Width")
        self.series_y_grid_alpha = LabelledDoubleSpinBox(self,
                                                         "Y Grid Transparency",
                                                         minimum=0,
                                                         maximum=1,
                                                         step=0.1)
        self.series_vspace = LabelledDoubleSpinBox(self,
                                                   "Plot Vertical Spacing",
                                                   minimum=-100,
                                                   maximum=100,
                                                   step=0.1)
        self.theo_pre_groupbox = QGroupBox()
        self.theo_pre_groupbox_layout = QVBoxLayout()
        self.theo_pre_groupbox.setLayout(self.theo_pre_groupbox_layout)
        self.theo_pre_groupbox.setTitle("Dedicated PRE Settings")
        self.theo_pre_color = ColourBox(self, "Theoretical PRE Line Colour")
        self.theo_pre_lw = LabelledDoubleSpinBox(self,
                                                 "Theoretical PRE Line Width",
                                                 minimum=0,
                                                 step=0.1)
        self.tag_cartoon_color = ColourBox(self, "Tag Pin Colour")
        self.tag_cartoon_lw = LabelledDoubleSpinBox(self,
                                                    "Tag Pin Line Width",
                                                    minimum=0,
                                                    step=0.1)
        self.tag_cartoon_ls = LabelledCombobox(self,
                                               "Tag Pin Line Style",
                                               items=line_styles)
        self.theo_pre_groupbox.layout().addWidget(self.theo_pre_color)
        self.theo_pre_groupbox.layout().addWidget(self.theo_pre_lw)
        self.theo_pre_groupbox.layout().addWidget(self.tag_cartoon_color)
        self.theo_pre_groupbox.layout().addWidget(self.tag_cartoon_lw)
        self.theo_pre_groupbox.layout().addWidget(self.tag_cartoon_ls)
        self.series_subtitle_groupbox.layout().addWidget(
            self.series_subtitle_fn)
        self.series_subtitle_groupbox.layout().addWidget(
            self.series_subtitle_fs)
        self.series_subtitle_groupbox.layout().addWidget(
            self.series_subtitle_pad)
        self.series_subtitle_groupbox.layout().addWidget(
            self.series_subtitle_weight)
        self.series_x_label_groupbox.layout().addWidget(self.series_x_label_fn)
        self.series_x_label_groupbox.layout().addWidget(self.series_x_label_fs)
        self.series_x_label_groupbox.layout().addWidget(
            self.series_x_label_pad)
        self.series_x_label_groupbox.layout().addWidget(
            self.series_x_label_weight)
        self.layout().addWidget(self.series_subtitle_groupbox, 0, 0, 4, 1)
        self.layout().addWidget(self.series_x_label_groupbox, 0, 1, 4, 1)
        self.layout().addWidget(self.theo_pre_groupbox, 0, 2, 4, 1)
        self.series_y_label_groupbox.layout().addWidget(self.series_y_label_fn)
        self.series_y_label_groupbox.layout().addWidget(self.series_y_label_fs)
        self.series_y_label_groupbox.layout().addWidget(
            self.series_y_label_weight)
        self.series_y_label_groupbox.layout().addWidget(
            self.series_y_label_pad)
        self.layout().addWidget(self.series_y_label_groupbox, 4, 1, 4, 1)
        self.series_y_tick_groupbox.layout().addWidget(self.series_x_ticks_pad)
        self.series_y_tick_groupbox.layout().addWidget(self.series_x_ticks_len)
        self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_fn)
        self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_fs)
        self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_rot)
        self.series_y_tick_groupbox.layout().addWidget(self.series_y_ticks_pad)
        self.series_y_label_groupbox.layout().addWidget(
            self.series_y_ticks_weight)
        self.series_y_label_groupbox.layout().addWidget(
            self.series_y_ticks_len)
        self.layout().addWidget(self.series_y_tick_groupbox, 4, 0, 4, 1)
        self.series_y_grid_groupbox = QGroupBox()
        self.series_y_grid_groupbox_layout = QVBoxLayout()
        self.series_y_grid_groupbox.setLayout(
            self.series_y_grid_groupbox_layout)
        self.series_y_grid_groupbox.setTitle("Y Grid Settings")
        self.series_y_grid_groupbox.layout().addWidget(self.series_y_grid_flag)
        self.series_y_grid_groupbox.layout().addWidget(
            self.series_y_grid_color)
        self.series_y_grid_groupbox.layout().addWidget(
            self.series_y_grid_linestyle)
        self.series_y_grid_groupbox.layout().addWidget(
            self.series_y_grid_linewidth)
        self.series_y_grid_groupbox.layout().addWidget(
            self.series_y_grid_alpha)
        self.series_y_grid_groupbox.layout().addWidget(self.series_vspace)
        self.layout().addWidget(self.series_y_grid_groupbox, 4, 2, 4, 1)
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel
                                          | QDialogButtonBox.RestoreDefaults)
        self.buttonBox.accepted.connect(self.set_values)
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.button(
            QDialogButtonBox.RestoreDefaults).clicked.connect(
                self.get_defaults)
        self.layout().addWidget(self.buttonBox, 8, 2, 1, 1)
        self.get_values()

    def get_defaults(self):
        # dropdown
        self.series_subtitle_fn.select(self.defaults["subtitle_fn"])
        self.series_subtitle_weight.select(self.defaults["subtitle_weight"])
        self.series_x_label_fn.select(self.defaults["x_label_fn"])
        self.series_x_label_weight.select(self.defaults["x_label_weight"])
        self.series_y_label_fn.select(self.defaults["y_label_fn"])
        self.series_y_label_weight.select(self.defaults["y_label_weight"])
        self.series_y_ticks_fn.select(self.defaults["y_ticks_fn"])
        self.series_y_ticks_weight.select(self.defaults["y_ticks_weight"])
        self.series_y_grid_linestyle.select(self.defaults["y_grid_linestyle"])
        self.tag_cartoon_ls.select(self.defaults["tag_cartoon_ls"])
        # value
        self.series_subtitle_fs.setValue(self.defaults["subtitle_fs"])
        self.series_subtitle_pad.setValue(self.defaults["subtitle_pad"])
        self.series_x_label_fs.setValue(self.defaults["x_label_fs"])
        self.series_x_label_pad.setValue(self.defaults["x_label_pad"])
        self.series_y_label_fs.setValue(self.defaults["y_label_fs"])
        self.series_y_label_pad.setValue(self.defaults["y_label_pad"])
        self.series_x_ticks_pad.setValue(self.defaults["x_ticks_pad"])
        self.series_x_ticks_len.setValue(self.defaults["x_ticks_len"])
        self.series_y_ticks_fs.setValue(self.defaults["y_ticks_fs"])
        self.series_y_ticks_rot.setValue(self.defaults["y_ticks_rot"])
        self.series_y_ticks_pad.setValue(self.defaults["y_ticks_pad"])
        self.series_y_ticks_len.setValue(self.defaults["y_ticks_len"])
        self.series_y_grid_linewidth.setValue(
            self.defaults["y_grid_linewidth"])
        self.series_y_grid_alpha.setValue(self.defaults["y_grid_alpha"])
        self.theo_pre_lw.setValue(self.defaults["theo_pre_lw"])
        self.tag_cartoon_lw.setValue(self.defaults["tag_cartoon_lw"])
        # checked
        self.series_y_grid_flag.setChecked(self.defaults["y_grid_flag"])
        # colour
        self.series_y_grid_color.get_colour(self.defaults["y_grid_color"])
        self.theo_pre_color.get_colour(self.defaults["theo_pre_color"])
        self.tag_cartoon_color.get_colour(self.defaults["tag_cartoon_color"])

    def set_values(self):
        # dropdown
        self.local_variables["subtitle_fn"] = str(
            self.series_subtitle_fn.fields.currentText())
        self.local_variables["subtitle_weight"] = str(
            self.series_subtitle_weight.fields.currentText())
        self.local_variables["x_label_fn"] = str(
            self.series_x_label_fn.fields.currentText())
        self.local_variables["x_label_weight"] = str(
            self.series_x_label_weight.fields.currentText())
        self.local_variables["y_label_fn"] = str(
            self.series_y_label_fn.fields.currentText())
        self.local_variables["y_label_weight"] = str(
            self.series_y_label_weight.fields.currentText())
        self.local_variables["y_ticks_fn"] = str(
            self.series_y_ticks_fn.fields.currentText())
        self.local_variables["y_ticks_weight"] = str(
            self.series_y_ticks_weight.fields.currentText())
        self.local_variables["y_grid_linestyle"] = str(
            self.series_y_grid_linestyle.fields.currentText())
        self.local_variables[
            "tag_cartoon_ls"] = self.tag_cartoon_ls.fields.currentText()
        # value
        self.local_variables[
            "subtitle_fs"] = self.series_subtitle_fs.field.value()
        self.local_variables[
            "subtitle_pad"] = self.series_subtitle_pad.field.value()
        self.local_variables[
            "x_label_fs"] = self.series_x_label_fs.field.value()
        self.local_variables[
            "x_label_pad"] = self.series_x_label_pad.field.value()
        self.local_variables[
            "y_label_fs"] = self.series_y_label_fs.field.value()
        self.local_variables[
            "y_label_pad"] = self.series_y_label_pad.field.value()
        self.local_variables[
            "x_ticks_pad"] = self.series_x_ticks_pad.field.value()
        self.local_variables[
            "x_ticks_len"] = self.series_x_ticks_len.field.value()
        self.local_variables[
            "y_ticks_fs"] = self.series_y_ticks_fs.field.value()
        self.local_variables[
            "y_ticks_rot"] = self.series_y_ticks_rot.field.value()
        self.local_variables[
            "y_ticks_pad"] = self.series_y_ticks_pad.field.value()
        self.local_variables[
            "y_ticks_len"] = self.series_y_ticks_len.field.value()
        self.local_variables[
            "y_grid_linewidth"] = self.series_y_grid_linewidth.field.value()
        self.local_variables[
            "y_grid_alpha"] = self.series_y_grid_alpha.field.value()
        self.local_variables["theo_pre_lw"] = self.theo_pre_lw.field.value()
        self.local_variables[
            "tag_cartoon_lw"] = self.tag_cartoon_lw.field.value()
        # colours
        self.local_variables["y_grid_color"] = str(
            self.series_y_grid_color.fields.currentText())
        self.local_variables[
            "theo_pre_color"] = self.theo_pre_color.fields.currentText()
        self.local_variables[
            "tag_cartoon_color"] = self.tag_cartoon_color.fields.currentText()
        # checked
        self.local_variables[
            "y_grid_flag"] = self.series_y_grid_flag.isChecked()
        self.accept()

    def get_values(self):
        # select
        self.series_subtitle_fn.select(self.local_variables["subtitle_fn"])
        self.series_subtitle_weight.select(
            self.local_variables["subtitle_weight"])
        self.series_x_label_fn.select(self.local_variables["x_label_fn"])
        self.series_x_label_weight.select(
            self.local_variables["x_label_weight"])
        self.series_y_label_fn.select(self.local_variables["y_label_fn"])
        self.series_y_label_weight.select(
            self.local_variables["y_label_weight"])
        self.series_y_ticks_fn.select(self.local_variables["y_ticks_fn"])
        self.series_y_ticks_weight.select(
            self.local_variables["y_ticks_weight"])
        self.series_y_grid_linestyle.select(
            self.local_variables["y_grid_linestyle"])
        self.tag_cartoon_ls.select(self.local_variables["tag_cartoon_ls"])
        # value
        self.series_subtitle_fs.setValue(self.local_variables["subtitle_fs"])
        self.series_subtitle_pad.setValue(self.local_variables["subtitle_pad"])
        self.series_x_label_fs.setValue(self.local_variables["x_label_fs"])
        self.series_x_label_pad.setValue(self.local_variables["x_label_pad"])
        self.series_y_label_fs.setValue(self.local_variables["y_label_fs"])
        self.series_y_label_pad.setValue(self.local_variables["y_label_pad"])
        self.series_x_ticks_pad.setValue(self.local_variables["x_ticks_pad"])
        self.series_x_ticks_len.setValue(self.local_variables["x_ticks_len"])
        self.series_y_ticks_fs.setValue(self.local_variables["y_ticks_fs"])
        self.series_y_ticks_rot.setValue(self.local_variables["y_ticks_rot"])
        self.series_y_ticks_pad.setValue(self.local_variables["y_ticks_pad"])
        self.series_y_ticks_len.setValue(self.local_variables["y_ticks_len"])
        self.series_y_grid_linewidth.setValue(
            self.local_variables["y_grid_linewidth"])
        self.series_y_grid_alpha.setValue(self.local_variables["y_grid_alpha"])
        self.theo_pre_lw.setValue(self.local_variables["theo_pre_lw"])
        self.tag_cartoon_lw.setValue(self.local_variables["tag_cartoon_lw"])
        # colour
        self.series_y_grid_color.get_colour(
            self.local_variables["y_grid_color"])
        self.theo_pre_color.get_colour(self.local_variables["theo_pre_color"])
        self.tag_cartoon_color.get_colour(
            self.local_variables["tag_cartoon_color"])
        # checked
        self.series_y_grid_flag.setChecked(self.local_variables["y_grid_flag"])