示例#1
0
    def get_box_value(self):
        """
        Returns the current width and height of this figsize box and returns
        it.

        Returns
        -------
        figsize : tuple
            A tuple containing the width and height values of the figsize,
            formatted as `(width, height)`.

        """

        return ((get_box_value(self.width_box),
                 get_box_value(self.height_box)))
示例#2
0
    def save_value(self):
        """
        Qt slot that saves the current value of this options entry.

        """

        self._value = get_box_value(self._box)
示例#3
0
    def get_box_value(self):
        """
        Returns the current value of the kwargs dict page.

        Returns
        -------
        page_dict : dict
            A dict containing all valid entries that are currently on this
            kwargs dict page. Any invalid entries (banned or empty ones) are
            ignored.

        """

        # Create an empty dict to hold the values in
        page_dict = sdict()

        # Loop over all items in grid and save them to page_dict
        for row in range(1, self.kwargs_grid.rowCount()):
            # Obtain item that should contain the entry_type in this row
            entry_type_item = self.kwargs_grid.itemAtPosition(row, 1)

            # If entry_type_item is None, this row contains no items
            if entry_type_item is None:
                continue

            # Obtain the entry_type
            entry_type = get_box_value(entry_type_item.widget())

            # If the entry_type is empty or banned, skip this row
            if not entry_type or entry_type in self.banned_entries:
                continue

            # Obtain the value of the corresponding field box
            field_value = get_box_value(
                self.kwargs_grid.itemAtPosition(row, 2).widget())

            # Add this to the dict
            page_dict[entry_type] = field_value

        # Return page_dict
        return(page_dict)
示例#4
0
    def get_box_value(self):
        """
        Returns the current value of the field box.

        Returns
        -------
        value : bool, float, int or str
            The current value of this default box.

        """

        return (get_box_value(self.value_box))
示例#5
0
    def get_box_value(self):
        """
        Returns the current colormap of the colormap box.

        Returns
        -------
        cmap : :obj:`~matplotlib.colors.Colormap` object
            The currently selected colormap.

        """

        # Obtain the value
        colormap = get_box_value(self.cmaps_box)

        # Convert to matplotlib colormap
        cmap = cm.get_cmap(colormap)

        # Return it
        return (cmap)
示例#6
0
    def get_box_value(self):
        """
        Returns the current (valid) color value of the color combobox.

        Returns
        -------
        color : str
            The current valid matplotlib color value.

        """

        # Obtain the value
        color = get_box_value(self.color_combobox)

        # Try to convert this to QColor
        try:
            self.convert_to_qcolor(color)
        # If this fails, return the default color
        except ValueError:
            return (self.default_color)
        # Else, return the retrieved color
        else:
            return (color)
示例#7
0
    def set_box_value(self, page_dict):
        """
        Sets the current value of the kwargs dict page to `page_dict`.

        Parameters
        ----------
        page_dict : dict
            A dict containing all entries that this kwargs dict page must have.
            Current entries that are also in `page_dict` will be reused,
            otherwise they are deleted.

        """

        # Make empty dict containing all current valid entries
        cur_entry_dict = sdict()

        # Remove all entries from kwargs_grid
        for row in range(1, self.kwargs_grid.rowCount()):
            # Obtain item that should contain the entry_type in this row
            entry_type_item = self.kwargs_grid.itemAtPosition(row, 1)

            # If entry_type_item is None, this row contains no items
            if entry_type_item is None:
                continue

            # Obtain the entry_type
            entry_type = get_box_value(entry_type_item.widget())

            # Delete this entry if not in page_dict or if it is not allowed
            if(entry_type not in page_dict or not entry_type or
               entry_type in self.banned_entries):
                self.remove_editable_entry(entry_type_item.widget())
                continue

            # If this entry appears multiple times, delete its previous entry
            if entry_type in cur_entry_dict:
                for item in cur_entry_dict[entry_type]:
                    item.widget().close()
                    del item
                cur_entry_dict.pop(entry_type)

            # Add this entry to cur_entry_dict
            cur_entry_dict[entry_type] =\
                [self.kwargs_grid.takeAt(3) for _ in range(3)]

        # Loop over all items in page_dict and act accordingly
        for row, (entry_type, field_value) in enumerate(page_dict.items(), 1):
            # Check if this entry_type already existed
            if entry_type in cur_entry_dict:
                # If so, put it back into kwargs_grid
                for col, item in enumerate(cur_entry_dict[entry_type]):
                    self.kwargs_grid.addItem(item, row, col)
            else:
                # If not, add it to kwargs_grid
                self.add_editable_entry()

                # Set this new entry to the proper type
                set_box_value(self.kwargs_grid.itemAtPosition(row, 1).widget(),
                              entry_type)

            # Set the value of the corresponding field
            set_box_value(self.kwargs_grid.itemAtPosition(row, 2).widget(),
                          field_value)