Esempio n. 1
0
    def create_traceback_box(self):
        """
        Creates a special box for the exception dialog that contains the
        traceback information and returns it.

        """

        # Create a traceback box
        traceback_box = GW.QWidget()
        traceback_box.setHidden(True)

        # Create layout
        layout = GL.QVBoxLayout(traceback_box)
        layout.setContentsMargins(0, 0, 0, 0)

        # Add a horizontal line to the layout
        layout.addSeparator()

        # Format the traceback
        tb_str = self.format_traceback()

        # Add a textedit to the layout
        tb_text_box = GW.QTextEdit(traceback_box)
        tb_text_box.setMinimumHeight(100)
        tb_text_box.setFocusPolicy(QC.Qt.NoFocus)
        tb_text_box.setReadOnly(True)
        tb_text_box.setText(tb_str)
        layout.addWidget(tb_text_box)

        # Create a 'show traceback' button
        self.tb_labels = ['Hide Traceback...', 'Show Traceback...']

        # Return traceback box
        return (traceback_box)
Esempio n. 2
0
    def init(self):
        # Register all figure formats
        self.register_formats()

        # Create a layout
        layout = GL.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # Create a tab widget
        tab_widget = GW.QTabWidget(browse_tabs=True)
        tab_widget.setTabBar(GW.EditableTabBar())
        tab_widget.setMovable(True)
        tab_widget.setTabsClosable(True)

        # Connect tab widget signals
        tab_widget.tabTextChanged.connect(self.set_tab_name)
        tab_widget.tabCloseRequested.connect(self.close_tab)

        # Add tab widget to layout
        self.tab_widget = tab_widget
        layout.addWidget(self.tab_widget)

        # Add all actions to the proper menus and toolbars
        self.add_actions()

        # Add a tab to the plugin
        self.add_tab()
Esempio n. 3
0
    def init(self, item_types, layout):
        """
        Sets up the items box after it has been initialized.

        """

        # Set the height of a single entry
        self.entry_height = 24

        # Create empty list of items
        self.items = []

        # Obtain the proper layout
        if layout in ('h', 'horizontal', 'r', 'row'):
            layout = GL.QHBoxLayout(self)
        elif layout in ('v', 'vertical', 'c', 'col', 'column'):
            layout = GL.QVBoxLayout(self)
        else:
            raise ValueError
        layout.setContentsMargins(0, 0, 0, 0)

        # Initialize all items
        for item_type in item_types:
            # Create item
            item = GW.type_box_dict.get(item_type, item_type)()

            # Add item to items list and layout
            self.items.append(item)
            layout.addWidget(item)

        # Save the number of items
        self.N = len(self.items)
Esempio n. 4
0
    def init(self, n, layout):
        """
        Sets up the multi-radiobutton after it has been initialized.

        """

        # Check what type of n has been provided
        if isinstance(n, INT_TYPES):
            # If n is an integer, set all names to empty strings
            names = [''] * n
        elif hasattr(n, '__iter__') and not isinstance(n, STR_TYPES):
            # Else, n must be an iterable of names
            names = list(map(str, n))
            n = len(n)
        else:
            raise TypeError

        # Check what type of layout has been provided
        if isinstance(layout, STR_TYPES):
            # If layout is a string, it is either 'horizontal' or 'vertical'
            if layout in ('h', 'horizontal', 'r', 'row'):
                layout = GL.QHBoxLayout(self)
            elif layout in ('v', 'vertical', 'c', 'col', 'column'):
                layout = GL.QVBoxLayout(self)
            else:
                raise ValueError
        else:
            # Else, layout is a tuple specifying the number of rows and columns
            n_rows, n_cols = layout
            layout = GL.QGridLayout(self)

        # Set contents margins of layout
        layout.setContentsMargins(0, 0, 0, 0)

        # Initialize empty list of radiobuttons
        self.buttons = []

        # Create buttons iterator
        if isinstance(layout, QW.QGridLayout):
            iterator = zip(names, np.ndindex(n_rows, n_cols))
        else:
            iterator = zip(names, repeat(()))

        # Create all requested radiobuttons
        for item in iterator:
            # Create radiobutton
            button = GW.QRadioButton(item[0])

            # Add button to list and layout
            self.buttons.append(button)
            layout.addWidget(button, *item[1])

        # Save the number of radiobuttons
        self.N = len(self.buttons)

        # Save the names
        self.names = names[:self.N]
Esempio n. 5
0
    def init(self):
        """
        Sets up the entries box after it has been initialized.

        """

        # Set the height of a single entry
        self.entry_height = 24

        # Create empty dict of non-generic entry types
        self.entry_types = {}

        # Create empty dict of entry defaults
        self.entry_defaults = {}

        # Create empty set of banned entry names
        self.banned_names = sset()

        # Create the box_layout
        box_layout = GL.QVBoxLayout(self)
        box_layout.setContentsMargins(0, 0, 0, 0)

        # Create the entries_grid
        entries_grid = GL.QGridLayout()
        entries_grid.setContentsMargins(0, 0, 0, 0)
        entries_grid.setColumnStretch(1, 1)
        entries_grid.setColumnStretch(2, 2)
        box_layout.addLayout(entries_grid)
        self.entries_grid = entries_grid

        # Add a header
        entries_grid.addWidget(GW.QLabel(""), 0, 0)
        entries_grid.addWidget(GW.QLabel("Entry name"), 0, 1)
        entries_grid.addWidget(GW.QLabel("Entry value"), 0, 2)

        # Add an 'Add'-button
        add_but = GW.QToolButton()
        add_but.setFixedSize(self.entry_height, self.entry_height)
        add_but.setToolTip("Add new entry")
        get_modified_signal(add_but).connect(self.add_entry)
        box_layout.addWidget(add_but)

        # If this theme has an 'add' icon, use it
        if QG.QIcon.hasThemeIcon('add'):
            add_but.setIcon(QG.QIcon.fromTheme('add'))
        # Else, use a simple plus
        else:
            add_but.setText('+')

        # Set size policy
        self.setSizePolicy(QW.QSizePolicy.Preferred, QW.QSizePolicy.Fixed)

        # Set a minimum width for the first column
        self.entries_grid.setColumnMinimumWidth(0, self.entry_height)
Esempio n. 6
0
    def init(self, item_type):
        """
        Sets up the items box after it has been initialized.

        """

        # Obtain the item_box
        if item_type is None:
            self.item_box = GW.LongGenericBox
        else:
            self.item_box = GW.type_box_dict.get(item_type, item_type)

        # Set the height of a single item
        self.entry_height = 24

        # Create the box_layout
        box_layout = GL.QVBoxLayout(self)
        box_layout.setContentsMargins(0, 0, 0, 0)

        # Create the items_layout
        items_layout = GL.QVBoxLayout()
        items_layout.setContentsMargins(0, 0, 0, 0)
        box_layout.addLayout(items_layout)
        self.items_layout = items_layout

        # Add an 'Add'-button
        add_but = GW.QToolButton()
        add_but.setFixedSize(self.entry_height, self.entry_height)
        add_but.setToolTip("Add new item")
        get_modified_signal(add_but).connect(self.add_item)
        box_layout.addWidget(add_but)

        # If this theme has an 'add' icon, use it
        if QG.QIcon.hasThemeIcon('add'):
            add_but.setIcon(QG.QIcon.fromTheme('add'))
        # Else, use a simple plus
        else:
            add_but.setText('+')

        # Set size policy
        self.setSizePolicy(QW.QSizePolicy.Preferred, QW.QSizePolicy.Fixed)
Esempio n. 7
0
    def init(self):
        # Create a layout
        layout = GL.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # Initialize figure
        self.figure, self.canvas, self.manager, self.options, self.toolbar =\
            self.create_figure()

        # Add figure toolbar to layout
        layout.addWidget(self.toolbar)

        # Add a separator
        layout.addSeparator()

        # Add figure canvas to layout
        layout.addWidget(self.canvas)
Esempio n. 8
0
    def init(self):
        # Create layout
        layout = GL.QVBoxLayout(self)

        # Create 'General' group box
        general_group = GW.QGroupBox("General")
        layout.addWidget(general_group)
        general_layout = GL.QFormLayout(general_group)

        # Add combobox for language-settings
        language_box = LocaleComboBox('language')
        language_box.addItems(
            list({QC.QLocale.system().language(), QC.QLocale.English}))
        language_box.setToolTip("Set the language used for representing "
                                "strings and values.")
        self.add_config_entry('language', language_box, True)
        general_layout.addRow("Language", language_box)
Esempio n. 9
0
    def init(self):
        # Create layout
        layout = GL.QVBoxLayout(self)

        # COLORMAPS
        # Create 'Colormaps' group box
        colormaps_group = GW.QGroupBox('Import colormaps')
        layout.addWidget(colormaps_group)
        colormaps_layout = GL.QFormLayout(colormaps_group)

        # Add label with explaining text
        cmaps_label = GW.QLabel(
            "You can import several Python packages that register colormaps in"
            " <u>matplotlib</u> before a figure is created. Packages that are "
            "not installed are ignored. Please provide each package separated "
            "by a comma, like: <i>cmasher, cmocean</i>")
        colormaps_layout.addRow(cmaps_label)

        # Create box for setting the colormap packages that must be imported
        cmap_pkg_box = GW.QLineEdit()
        colormaps_layout.addRow("Packages:", cmap_pkg_box)
        self.add_config_entry('cmap_packages', cmap_pkg_box, True)

        # RCPARAMS
        # Create 'rcParams' group box
        rcParams_group = GW.QGroupBox('rcParams')
        layout.addWidget(rcParams_group)
        rcParams_layout = GL.QVBoxLayout(rcParams_group)

        # Add label with explaining text
        rcParams_label = GW.QLabel(
            "You can modify most of the <u>rcParams</u> used in "
            "<u>matplotlib</u> below. Adding an entry will override the value "
            "for that specific parameter for every figure created.<br>"
            "See <a href=\"%s\">here</a> for an overview with descriptions of "
            "each parameter." %
            ("https://matplotlib.org/tutorials/introductory/customizing.html"))
        rcParams_layout.addWidget(rcParams_label)

        # Add separator
        rcParams_layout.addSeparator()

        # Create entries_box
        entries_box = GW.EntriesBox()
        rcParams_layout.addWidget(entries_box)
        self.add_config_entry('rcParams', entries_box)

        # Create list of all prefixes that should be skipped
        prefix_skip = ('_internal', 'agg', 'animation', 'backend',
                       'boxplot.bootstrap', 'datapath', 'docstring',
                       'figure.figsize', 'figure.max_open_warning',
                       'image.aspect', 'image.composite_image', 'image.origin',
                       'interactive', 'keymap', 'lines.color', 'mpl_toolkits',
                       'path', 'pdf', 'pgf', 'ps', 'savefig', 'svg',
                       'text.kerning_factor', 'tk', 'toolbar', 'verbose',
                       'webagg')

        # Create a combobox factory for text weights
        text_weight_box = create_combobox(
            ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400',
             '500', '600', '700', '800', '900'])

        # Create dict of all rcParams that use specific widgets
        key_widgets = {
            'axes.autolimit_mode': create_combobox(['data', 'round_numbers']),
            'axes.axisbelow': lambda: BoolComboBox([True, 'line', False]),
            'axes.edgecolor': GW.ColorBox,
            'axes.facecolor': GW.ColorBox,
            'axes.formatter.limits': lambda: GW.ItemsBox([int]*2),
            'axes.formatter.min_exponent': GW.QSpinBox,
            'axes.formatter.offset_threshold': GW.QSpinBox,
            'axes.formatter.use_locale': GW.QCheckBox,
            'axes.formatter.use_mathtext': GW.QCheckBox,
            'axes.formatter.useoffset': GW.QCheckBox,
            'axes.grid': GW.QCheckBox,
            'axes.grid.axes': create_combobox(['major', 'minor', 'both']),
            'axes.grid.which': create_combobox(['major', 'minor', 'both']),
            'axes.labelcolor': GW.ColorBox,
            'axes.labelpad': GW.FontSizeBox,
            'axes.labelsize': GW.FontSizeBox,
            'axes.labelweight': text_weight_box,
            'axes.linewidth': GW.FontSizeBox,
            'axes.prop_cycle': lambda: GW.GenericItemsBox(
                lambda: GW.ColorBox(False)),
            'axes.spines.bottom': GW.QCheckBox,
            'axes.spines.left': GW.QCheckBox,
            'axes.spines.right': GW.QCheckBox,
            'axes.spines.top': GW.QCheckBox,
            'axes.titlecolor': lambda: AutoToggleBox(GW.ColorBox(), 'auto'),
            'axes.titlelocation': create_combobox(['left', 'center', 'right']),
            'axes.titlepad': GW.FontSizeBox,
            'axes.titlesize': GW.FontSizeBox,
            'axes.titleweight': text_weight_box,
            'axes.unicode_minus': GW.QCheckBox,
            'axes.xmargin': UnitySpinBox,
            'axes.ymargin': UnitySpinBox,
            'axes3d.grid': GW.QCheckBox,
            'boxplot.boxprops.color': GW.ColorBox,
            'boxplot.boxprops.linestyle': GW.LineStyleBox,
            'boxplot.boxprops.linewidth': GW.FontSizeBox,
            'boxplot.capprops.color': GW.ColorBox,
            'boxplot.capprops.linestyle': GW.LineStyleBox,
            'boxplot.capprops.linewidth': GW.FontSizeBox,
            'boxplot.flierprops.color': GW.ColorBox,
            'boxplot.flierprops.linestyle': GW.LineStyleBox,
            'boxplot.flierprops.linewidth': GW.FontSizeBox,
            'boxplot.flierprops.marker': GW.MarkerStyleBox,
            'boxplot.flierprops.markeredgecolor': lambda: AutoToggleBox(
                GW.ColorBox(), 'none'),
            'boxplot.flierprops.markeredgewidth': GW.FontSizeBox,
            'boxplot.flierprops.markerfacecolor': lambda: AutoToggleBox(
                GW.ColorBox(), 'none'),
            'boxplot.flierprops.markersize': GW.FontSizeBox,
            'boxplot.meanline': GW.QCheckBox,
            'boxplot.meanprops.color': GW.ColorBox,
            'boxplot.meanprops.linestyle': GW.LineStyleBox,
            'boxplot.meanprops.linewidth': GW.FontSizeBox,
            'boxplot.meanprops.marker': GW.MarkerStyleBox,
            'boxplot.meanprops.markeredgecolor': lambda: AutoToggleBox(
                GW.ColorBox(), 'none'),
            'boxplot.meanprops.markerfacecolor': lambda: AutoToggleBox(
                GW.ColorBox(), 'none'),
            'boxplot.meanprops.markersize': GW.FontSizeBox,
            'boxplot.medianprops.color': GW.ColorBox,
            'boxplot.medianprops.linestyle': GW.LineStyleBox,
            'boxplot.medianprops.linewidth': GW.FontSizeBox,
            'boxplot.notch': GW.QCheckBox,
            'boxplot.showbox': GW.QCheckBox,
            'boxplot.showcaps': GW.QCheckBox,
            'boxplot.showfliers': GW.QCheckBox,
            'boxplot.showmeans': GW.QCheckBox,
            'boxplot.vertical': GW.QCheckBox,
            'boxplot.whiskerprops.color': GW.ColorBox,
            'boxplot.whiskerprops.linestyle': GW.LineStyleBox,
            'boxplot.whiskerprops.linewidth': GW.FontSizeBox,
            'boxplot.whiskers': GW.FloatLineEdit,
            'contour.corner_mask': lambda: BoolComboBox(
                [True, False, 'legacy']),
            'contour.negative_linestyle': GW.LineStyleBox,
            'date.autoformatter.day': GW.QLineEdit,
            'date.autoformatter.hour': GW.QLineEdit,
            'date.autoformatter.microsecond': GW.QLineEdit,
            'date.autoformatter.minute': GW.QLineEdit,
            'date.autoformatter.month': GW.QLineEdit,
            'date.autoformatter.second': GW.QLineEdit,
            'date.autoformatter.year': GW.QLineEdit,
            'errorbar.capsize': GW.FloatLineEdit,
            'figure.autolayout': GW.QCheckBox,
            'figure.constrained_layout.h_pad': UnitySpinBox,
            'figure.constrained_layout.hspace': UnitySpinBox,
            'figure.constrained_layout.use': GW.QCheckBox,
            'figure.constrained_layout.w_pad': UnitySpinBox,
            'figure.constrained_layout.wspace': UnitySpinBox,
            'figure.dpi': GW.FloatLineEdit,
            'figure.edgecolor': GW.ColorBox,
            'figure.facecolor': GW.ColorBox,
            'figure.frameon': GW.QCheckBox,
            'figure.subplot.bottom': UnitySpinBox,
            'figure.subplot.hspace': UnitySpinBox,
            'figure.subplot.left': UnitySpinBox,
            'figure.subplot.right': UnitySpinBox,
            'figure.subplot.top': UnitySpinBox,
            'figure.subplot.wspace': UnitySpinBox,
            'figure.titlesize': GW.FontSizeBox,
            'figure.titleweight': text_weight_box,
            'font.cursive': lambda: GW.GenericItemsBox(GW.QFontComboBox),
            'font.family': lambda: GW.GenericItemsBox(GW.QFontComboBox),
            'font.fantasy': lambda: GW.GenericItemsBox(GW.QFontComboBox),
            'font.monospace': lambda: GW.GenericItemsBox(GW.QFontComboBox),
            'font.sans-serif': lambda: GW.GenericItemsBox(GW.QFontComboBox),
            'font.serif': lambda: GW.GenericItemsBox(GW.QFontComboBox),
            'font.size': GW.FontSizeBox,
            'font.stretch': create_combobox(
                ['ultra-condensed', 'extra-condensed', 'condensed',
                 'semi-condensed', 'normal', 'semi-expanded', 'expanded',
                 'extra-expanded', 'ultra-expanded', 'wider', 'narrower']),
            'font.style': create_combobox(['normal', 'italic', 'oblique']),
            'font.variant': create_combobox(['normal', 'small-caps']),
            'font.weight': text_weight_box,
            'grid.alpha': UnitySpinBox,
            'grid.color': GW.ColorBox,
            'grid.linestyle': GW.LineStyleBox,
            'grid.linewidth': GW.FontSizeBox,
            'hatch.color': GW.ColorBox,
            'hatch.linewidth': GW.FontSizeBox,
            'hist.bins': get_n_bins_box,
            'image.cmap': GW.ColorMapBox,
            'image.interpolation': create_combobox(
                ['none', 'antialiased', 'nearest', 'bilinear', 'bicubic',
                 'spline16', 'spline36', 'hanning', 'hamming', 'hermite',
                 'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel',
                 'mitchell', 'sinc', 'lanczos']),
            'image.lut': GW.IntLineEdit,
            'image.resample': GW.QCheckBox,
            'legend.borderaxespad': GW.FontSizeBox,
            'legend.borderpad': GW.FontSizeBox,
            'legend.columnspacing': GW.FontSizeBox,
            'legend.edgecolor': GW.ColorBox,
            'legend.facecolor': lambda: AutoToggleBox(
                GW.ColorBox(), 'inherit'),
            'legend.fancybox': GW.QCheckBox,
            'legend.fontsize': GW.FontSizeBox,
            'legend.framealpha': UnitySpinBox,
            'legend.frameon': GW.QCheckBox,
            'legend.handleheight': GW.FontSizeBox,
            'legend.handlelength': GW.FontSizeBox,
            'legend.handletextpad': GW.FontSizeBox,
            'legend.labelspacing': GW.FontSizeBox,
            'legend.loc': create_combobox(mpl.legend.Legend.codes.keys()),
            'legend.markerscale': GW.FloatLineEdit,
            'legend.numpoints': GW.IntLineEdit,
            'legend.scatterpoints': GW.IntLineEdit,
            'legend.shadow': GW.QCheckBox,
            'legend.title_fontsize': lambda: AutoToggleBox(
                GW.FontSizeBox(), None),
            'lines.antialiased': GW.QCheckBox,
            'lines.dash_capstyle': create_combobox(
                ['butt', 'projecting', 'round']),
            'lines.dash_joinstyle': create_combobox(
                ['bevel', 'miter', 'round']),
            'lines.dashdot_pattern': lambda: GW.ItemsBox([float]*4),
            'lines.dashed_pattern': lambda: GW.ItemsBox([float]*2),
            'lines.dotted_pattern': lambda: GW.ItemsBox([float]*2),
            'lines.linestyle': GW.LineStyleBox,
            'lines.linewidth': GW.FontSizeBox,
            'lines.marker': GW.MarkerStyleBox,
            'lines.markeredgecolor': lambda: AutoToggleBox(
                GW.ColorBox(), 'auto'),
            'lines.markeredgewidth': GW.FontSizeBox,
            'lines.markerfacecolor': lambda: AutoToggleBox(
                GW.ColorBox(), 'auto'),
            'lines.markersize': GW.FontSizeBox,
            'lines.scale_dashes': GW.QCheckBox,
            'lines.solid_capstyle': create_combobox(
                ['butt', 'projecting', 'round']),
            'lines.solid_joinstyle': create_combobox(
                ['bevel', 'miter', 'round']),
            'markers.fillstyle': create_combobox(
                ['full', 'left', 'right', 'bottom', 'top', 'none']),
            'mathtext.bf': GW.QLineEdit,
            'mathtext.cal': GW.QLineEdit,
            'mathtext.default': GW.QLineEdit,
            'mathtext.fallback_to_cm': GW.QCheckBox,
            'mathtext.fontset': create_combobox(
                ['dejavusans', 'cm', 'stix', 'stixsans', 'custom']),
            'mathtext.it': GW.QLineEdit,
            'mathtext.rm': GW.QLineEdit,
            'mathtext.sf': GW.QLineEdit,
            'mathtext.tt': GW.QLineEdit,
            'patch.antialiased': GW.QCheckBox,
            'patch.edgecolor': GW.ColorBox,
            'patch.facecolor': GW.ColorBox,
            'patch.force_edgecolor': GW.QCheckBox,
            'patch.linewidth': GW.FontSizeBox,
            'polaraxes.grid': GW.QCheckBox,
            'scatter.edgecolors': lambda: AutoToggleBox(
                GW.ColorBox(), 'face'),
            'scatter.marker': GW.MarkerStyleBox,
            'text.antialiased': GW.QCheckBox,
            'text.color': GW.ColorBox,
            'text.hinting': create_combobox(
                ['either', 'native', 'auto', 'none']),
            'text.hinting_factor': GW.IntLineEdit,
            'text.latex.preamble': GW.QLineEdit,
            'text.latex.preview': GW.QCheckBox,
            'text.usetex': GW.QCheckBox,
            'timezone': GW.QLineEdit,
            'xtick.alignment': create_combobox(['left', 'center', 'right']),
            'xtick.bottom': GW.QCheckBox,
            'xtick.color': GW.ColorBox,
            'xtick.direction': create_combobox(['in', 'out', 'inout']),
            'xtick.labelbottom': GW.QCheckBox,
            'xtick.labelsize': GW.FontSizeBox,
            'xtick.labeltop': GW.QCheckBox,
            'xtick.major.bottom': GW.QCheckBox,
            'xtick.major.pad': GW.FontSizeBox,
            'xtick.major.size': GW.FontSizeBox,
            'xtick.major.top': GW.QCheckBox,
            'xtick.major.width': GW.FontSizeBox,
            'xtick.minor.bottom': GW.QCheckBox,
            'xtick.minor.pad': GW.FontSizeBox,
            'xtick.minor.size': GW.FontSizeBox,
            'xtick.minor.top': GW.QCheckBox,
            'xtick.minor.visible': GW.QCheckBox,
            'xtick.minor.width': GW.FontSizeBox,
            'xtick.top': GW.QCheckBox,
            'ytick.alignment': create_combobox(
                ['left_baseline', 'center_baseline', 'right_baseline']),
            'ytick.color': GW.ColorBox,
            'ytick.direction': create_combobox(['in', 'out', 'inout']),
            'ytick.labelleft': GW.QCheckBox,
            'ytick.labelright': GW.QCheckBox,
            'ytick.labelsize': GW.FontSizeBox,
            'ytick.left': GW.QCheckBox,
            'ytick.major.left': GW.QCheckBox,
            'ytick.major.pad': GW.FontSizeBox,
            'ytick.major.right': GW.QCheckBox,
            'ytick.major.size': GW.FontSizeBox,
            'ytick.major.width': GW.FontSizeBox,
            'ytick.minor.left': GW.QCheckBox,
            'ytick.minor.pad': GW.FontSizeBox,
            'ytick.minor.right': GW.QCheckBox,
            'ytick.minor.size': GW.FontSizeBox,
            'ytick.minor.visible': GW.QCheckBox,
            'ytick.minor.width': GW.FontSizeBox,
            'ytick.right': GW.QCheckBox}

        # Initialize empty dict of entry_types
        entry_types = sdict()

        # Loop over all rcParams and determine what widget to use
        for key, value in rcParamsDefault.items():
            # Check if key starts with anything in prefix_skip
            if key.startswith(prefix_skip):
                # If so, continue
                continue

            # Obtain proper box
            box = key_widgets.get(key, GW.LongGenericBox)

            # If key is 'axes.prop_cycle', obtain the proper value
            if(key == 'axes.prop_cycle'):
                value = value.by_key()['color']

            # Add box to entry_types dict with default value
            entry_types[key] = (box, value)

        # Add all rcParams entries to the box
        entries_box.addEntryTypes(entry_types)
Esempio n. 10
0
    def init(self):
        """
        Sets up the dialog used for setting the configuration in *GuiPy*.

        """

        # Set properties of configuration dialog
        self.setWindowTitle(self.NAME.replace('&', ''))
        self.setWindowFlags(
            QC.Qt.MSWindowsOwnDC |
            QC.Qt.Dialog |
            QC.Qt.WindowTitleHint |
            QC.Qt.WindowSystemMenuHint |
            QC.Qt.WindowCloseButtonHint)

        # Create a window layout
        layout = GL.QVBoxLayout(self)

        # Create a splitter widget for this window
        splitter = GW.QSplitter()
        splitter.setChildrenCollapsible(False)
        layout.addWidget(splitter)

        # Create a contents widget
        contents = GW.QListWidget()
        contents.setMovement(GW.QListView.Static)
        contents.setSpacing(1)
        splitter.addWidget(contents)
        splitter.setStretchFactor(0, 1)
        self.contents = contents

        # Create a sections widget
        sections = GW.QStackedWidget()
        splitter.addWidget(sections)
        splitter.setStretchFactor(1, 4)
        self.sections = sections

        # Connect signals
        contents.currentRowChanged.connect(sections.setCurrentIndex)

        # Create empty dict of config pages
        self.config_pages = sdict()

        # Add a buttonbox
        button_box = QW.QDialogButtonBox()
        button_box.clicked.connect(self.buttonWasPressed)
        layout.addWidget(button_box)
        self.button_box = button_box

        # Add an 'Ok' button
        ok_but = button_box.addButton(button_box.Ok)
        ok_but.setToolTip("Apply current changes and close the configuration "
                          "window")

        # Add a 'Cancel' button
        cancel_but = button_box.addButton(button_box.Cancel)
        cancel_but.setToolTip("Discard current changes and close the "
                              "configuration window")
        self.cancel_but = cancel_but

        # Add an 'Apply' button
        apply_but = button_box.addButton(button_box.Apply)
        apply_but.setToolTip("Apply current configuration changes")
        self.apply_but = apply_but
        self.disable_apply_button()

        # Add a 'Reset' button
        reset_but = button_box.addButton(button_box.Reset)
        reset_but.setToolTip("Reset configuration values to defaults")

        # Create a slot dict for all buttons
        self.slot_dict = {
            button_box.AcceptRole: [
                self.apply_options,
                self.close],
            button_box.RejectRole: [
                self.discard_options,
                self.close],
            button_box.ApplyRole: [
                self.apply_options],
            button_box.ResetRole: [
                self.reset_options]}

        # Set the size of the dialog
        self.resize(800, 600)
Esempio n. 11
0
    def init(self, import_func=None):
        # Create a layout
        layout = GL.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # Create a dimensions layout
        dimensions_layout = GL.QHBoxLayout()
        layout.addLayout(dimensions_layout)

        # Add a label to this layout
        dimensions_layout.addWidget(GW.QLabel('Dimensions: '))

        # Create dual spinbox for setting n_rows and n_cols
        dimensions_box = GW.DualSpinBox((int, int), "X")
        dimensions_layout.addWidget(dimensions_box)
        n_rows_box, n_cols_box = dimensions_box[:]
        n_rows_box.setRange(0, 9999999)
        n_rows_box.setToolTip("Number of rows in this data table (max. %i)" %
                              (n_rows_box.maximum()))
        n_cols_box.setRange(0, 702)
        n_cols_box.setToolTip(
            "Number of columns in this data table (max. %i)" %
            (n_cols_box.maximum()))
        self.dimensions_box = dimensions_box

        # Create a layout for applying or reverting the dimensions
        buttons_layout = GL.QHBoxLayout()
        buttons_layout.setContentsMargins(0, 0, 0, 0)
        buttons_layout.setSpacing(0)
        dimensions_layout.addLayout(buttons_layout)

        # If this theme has a 'cancel' icon, use it
        if QG.QIcon.hasThemeIcon('cancel'):
            rev_icon = QG.QIcon.fromTheme('cancel')
        # Else, use a standard icon
        else:
            rev_icon = self.style().standardIcon(
                QW.QStyle.SP_DialogCancelButton)

        # Create a revert toolbutton
        rev_but = GW.QToolButton()
        rev_but.setToolTip("Revert to current data table dimensions")
        rev_but.setIcon(rev_icon)
        get_modified_signal(rev_but).connect(self.revert_table_dimensions)
        buttons_layout.addWidget(rev_but)

        # If this theme has an 'apply' icon, use it
        if QG.QIcon.hasThemeIcon('apply'):
            app_icon = QG.QIcon.fromTheme('apply')
        # Else, use a standard icon
        else:
            app_icon = self.style().standardIcon(
                QW.QStyle.SP_DialogApplyButton)

        # Create an apply toolbutton
        app_but = GW.QToolButton()
        app_but.setToolTip("Apply new data table dimensions")
        app_but.setIcon(app_icon)
        get_modified_signal(app_but).connect(self.apply_table_dimensions)
        buttons_layout.addWidget(app_but)

        # Add a stretcher
        dimensions_layout.addStretch()

        # Create the DataTableView object
        self.view = DataTableView(self, import_func)

        # Set initial values of the spinboxes
        self.revert_table_dimensions()

        # Connect signals from data table view
        self.view.model().rowCountChanged.connect(
            lambda x: set_box_value(n_rows_box, x))
        self.view.model().columnCountChanged.connect(
            lambda x: set_box_value(n_cols_box, x))
        self.view.model().lastColumnRemoved.connect(
            lambda: n_rows_box.setEnabled(False))
        self.view.model().firstColumnInserted.connect(
            lambda: n_rows_box.setEnabled(True))

        # Add data_table to the layout
        layout.addWidget(self.view)
Esempio n. 12
0
    def init(self):
        # Initialize empty dict of options
        self.options_dict = {}

        # Install event filter
        self.installEventFilter(self)

        # Set dialog properties
        # TODO: Figure out how to make the menu modal without it moving
        # automatically to the center on Linux
        self.setWindowTitle("Figure options")
        self.setWindowModality(QC.Qt.ApplicationModal)
        self.setWindowFlags(QC.Qt.MSWindowsOwnDC | QC.Qt.Dialog
                            | QC.Qt.WindowTitleHint
                            | QC.Qt.WindowSystemMenuHint
                            | QC.Qt.WindowCloseButtonHint)

        # Create a layout
        layout = GL.QVBoxLayout(self)

        # Add the options tabs to it
        self.options_tabs = self.create_options_tabs()
        layout.addWidget(self.options_tabs)

        # Add stretch
        layout.addStretch()

        # Add a buttonbox
        button_box = QW.QDialogButtonBox()
        button_box.clicked.connect(self.buttonWasPressed)
        layout.addWidget(button_box)
        self.button_box = button_box

        # Add an 'Ok' button
        ok_but = button_box.addButton(button_box.Ok)
        ok_but.setToolTip("Apply current changes and close the figure options "
                          "menu")

        # Add a 'Cancel' button
        cancel_but = button_box.addButton(button_box.Cancel)
        cancel_but.setToolTip("Discard current changes and close the figure "
                              "options menu")
        self.cancel_but = cancel_but

        # Add an 'Apply' button
        apply_but = button_box.addButton(button_box.Apply)
        apply_but.setToolTip("Apply current figure options")
        self.apply_but = apply_but
        self.disable_apply_button()

        # Add a 'Refresh' button
        refresh_but = button_box.addButton('Refresh', button_box.ActionRole)
        refresh_but.setToolTip("Refresh figure using current figure options "
                               "without applying them")

        # Create a slot dict for all buttons
        self.slot_dict = {
            button_box.AcceptRole:
            [self.refresh_figure, self.apply_options, self.close],
            button_box.RejectRole:
            [self.discard_options, self.refresh_figure, self.close],
            button_box.ApplyRole: [self.apply_options],
            button_box.ActionRole: [self.refresh_figure]
        }