示例#1
0
文件: combobox.py 项目: 1313e/GuiPy
    def init(self, editable, sep):
        """
        Sets up the dual combobox after it has been initialized.

        """

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

        # Create two comboboxes with the provided editability
        # LEFT
        left_box = EditableComboBox() if editable[0] else GW.QComboBox()
        box_layout.addWidget(left_box)
        self.left_box = left_box

        # RIGHT
        right_box = EditableComboBox() if editable[1] else GW.QComboBox()
        box_layout.addWidget(right_box)
        self.right_box = right_box

        # If sep is not None, create label and add it
        if sep is not None:
            sep_label = GW.QLabel(sep)
            sep_label.setSizePolicy(QW.QSizePolicy.Fixed, QW.QSizePolicy.Fixed)
            box_layout.insertWidget(1, sep_label)
示例#2
0
文件: general.py 项目: 1313e/GuiPy
    def init(self):
        # Create layout
        layout = GL.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # Create combobox
        combobox = GW.QComboBox()
        layout.addWidget(combobox)
        self.combobox = combobox
示例#3
0
文件: combobox.py 项目: 1313e/GuiPy
    def func():
        # Obtain the proper combobox
        if editable:
            combobox = EditableComboBox(parent=parent)
        else:
            combobox = GW.QComboBox(parent=parent)

        # Add items
        combobox.addItems(items)

        # Return combobox
        return (combobox)
示例#4
0
    def create_plots_tab(self):
        # Create a tab
        tab = GW.BaseBox()
        get_modified_signal(tab).connect(self.enable_apply_button)

        # Create layout
        layout = GL.QFormLayout(tab)

        # PLOT
        # Create a plot picker layout
        plot_layout = GL.QHBoxLayout()
        layout.addRow(plot_layout)

        # Create a label
        plot_label = GW.QLabel("Plot")
        plot_label.setSizePolicy(QW.QSizePolicy.Fixed, QW.QSizePolicy.Fixed)
        plot_layout.addWidget(plot_label)

        # Create a combobox for choosing an existing plot
        plot_entries = GW.QComboBox()
        plot_entries.setToolTip("Select the plot entry you wish to edit")
        plot_layout.addWidget(plot_entries)
        get_modified_signal(plot_entries).disconnect(tab.modified)
        self.plot_entries = plot_entries

        # Add a toolbutton for adding a new plot entry
        add_but = GW.QToolButton()
        add_but.setToolTip("Add new plot entry")
        get_modified_signal(add_but).connect(self.add_entry)
        plot_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('+')

        # Add a separator
        layout.addSeparator()

        # Add a stacked widget here for dividing the plots
        plot_pages = GW.QStackedWidget()
        get_modified_signal(plot_entries,
                            int).connect(plot_pages.setCurrentIndex)
        layout.addRow(plot_pages)
        self.plot_pages = plot_pages

        # Return tab
        return (tab, "Plots")
示例#5
0
文件: plot_entry.py 项目: 1313e/GuiPy
    def create_entry_layout(self):
        # Create layout
        layout = GL.QFormLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        self.layout = layout

        # Create a name editor layout
        name_layout = GL.QHBoxLayout()
        layout.addRow('Name', name_layout)

        # Create entry name editor
        name_box = GW.QLineEdit()
        name_box.setToolTip("Name of this plot entry")
        set_box_value(name_box, self.name)
        get_modified_signal(name_box).connect(self.entryNameChanged)
        name_layout.addWidget(name_box)
        get_modified_signal(name_box).disconnect(self.modified)
        self.name_box = name_box

        # Add a toolbutton for deleting this plot entry
        del_but = GW.QToolButton()
        del_but.setToolTip("Delete this plot entry")
        get_modified_signal(del_but).connect(self.entryRemoveRequested)
        name_layout.addWidget(del_but)

        # If this theme has a 'remove' icon, use it
        if QG.QIcon.hasThemeIcon('remove'):
            del_but.setIcon(QG.QIcon.fromTheme('remove'))
        # Else, use a standard icon
        else:
            del_but.setIcon(del_but.style().standardIcon(
                QW.QStyle.SP_DialogCloseButton))

        # Create a combobox for choosing a plot type
        plot_types = GW.QComboBox()
        plot_types.addItems(PLOT_TYPES['2D'])
        plot_types.setToolTip("Select the plot type you wish to use for this "
                              "plot entry")
        set_box_value(plot_types, -1)
        get_modified_signal(plot_types).connect(self.set_plot_type)
        layout.addRow('Type', plot_types)
        self.plot_types = plot_types

        # Add a separator
        layout.addSeparator()

        # Create a dummy entry to start off
        self.plot_entry = GW.QWidget()
        layout.addRow(self.plot_entry)
示例#6
0
    def init(self):
        # Install event filter to catch events that should close the popup
        self.installEventFilter(self)

        # Set dialog flags
        self.setWindowFlags(QC.Qt.Popup | QC.Qt.FramelessWindowHint)

        # Create a form layout
        layout = GL.QFormLayout(self)

        # Add a label stating the base name of the column
        self.base_name_label = GW.QLabel("")
        self.base_name_label.setAlignment(QC.Qt.AlignCenter)
        layout.addRow(self.base_name_label)

        # Create a n_val label
        n_val_box = GW.QLabel()
        n_val_box.setToolTip("Number of values in this column")

        # Add it to the layout
        layout.addRow("# of values", n_val_box)
        self.n_val_box = n_val_box

        # Create a name line-edit
        name_box = GW.QLineEdit()
        name_box.setToolTip("Set a custom name for this column or leave empty "
                            "to use its default name")
        get_modified_signal(name_box).connect(self.column_name_changed)

        # Add it to the layout
        layout.addRow("Name", name_box)
        self.name_box = name_box

        # Create a dtype combobox
        dtype_box = GW.QComboBox()
        dtype_box.setToolTip("Set the data type for this column")
        dtype_box.addItems(self.model.dtypes.values())
        dtype_box.popup_hidden.connect(lambda: name_box.setFocus(True))

        # Add it to the layout
        layout.addRow("Data type", dtype_box)
        self.dtype_box = dtype_box
示例#7
0
文件: genericbox.py 项目: 1313e/GuiPy
    def init(self):
        """
        Sets up the generic value box after it has been initialized.

        """

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

        # Create a combobox for the type
        type_box = GW.QComboBox()
        type_box.addItems(sorted([x.__name__ for x in self.supported_types]))
        type_box.setSizePolicy(QW.QSizePolicy.Fixed, QW.QSizePolicy.Fixed)
        set_box_value(type_box, -1)
        get_modified_signal(type_box).connect(self.create_value_box)
        box_layout.addWidget(type_box)
        self.type_box = type_box

        # Create a default value box
        value_box = GW.QWidget()
        box_layout.addWidget(value_box)
        self.value_box = value_box
示例#8
0
    def create_figure_tab(self):
        # Create a tab
        tab = GW.BaseBox()
        get_modified_signal(tab).connect(self.enable_apply_button)

        # Create layout
        layout = GL.QFormLayout(tab)

        # Make line edit for title
        title_box = GW.FigureLabelBox()
        title_box[0].setToolTip("Figure title")
        title_box[1].setToolTip("Title size")
        set_box_value(title_box, ('', {
            'fontsize': rcParams['figure.titlesize']
        }))
        self.add_options_entry(title_box)
        self.refreshing_figure.connect(
            lambda: self.axis.set_title(*get_box_value(title_box, str, dict)))
        layout.addRow("Title", title_box)
        self.title_box = title_box

        # X-AXIS
        # Create a group box for the X-axis
        x_axis_group = GW.QGroupBox("X-axis")
        layout.addRow(x_axis_group)
        x_axis_layout = GL.QFormLayout(x_axis_group)

        # Make a box for setting the label on the x-axis
        x_label_box = GW.FigureLabelBox()
        x_label_box[0].setToolTip("Label of the X-axis")
        x_label_box[1].setToolTip("Label size")
        set_box_value(x_label_box, ('', {
            'fontsize': rcParams['axes.labelsize']
        }))
        self.add_options_entry(x_label_box)
        self.refreshing_figure.connect(lambda: self.axis.set_xlabel(
            *get_box_value(x_label_box, str, dict)))
        x_axis_layout.addRow("Label", x_label_box)
        self.x_label_box = x_label_box

        # Make a box for setting the range on the x-axis
        # TODO: Allow for a small formula or cell range to be given instead?
        x_range_box = GW.DualLineEdit((float, float),
                                      r"<html>&le; X &le;</html>")
        x_min_box, x_max_box = x_range_box[:]
        x_min_box.setToolTip("Minimum value of the X-axis")
        x_max_box.setToolTip("Maximum value of the X-axis")
        set_box_value(x_range_box, self.axis.get_xlim())

        # Connect signals for x_range_box
        self.refreshing_figure.connect(
            lambda: self.axis.set_xlim(*get_box_value(x_range_box), auto=None))
        self.axis.callbacks.connect(
            'xlim_changed', lambda x: set_box_value(x_range_box, x.get_xlim()))

        # Make togglebox for enabling/disabling the use of this range
        x_range_togglebox = GW.ToggleBox(
            x_range_box, tooltip="Check to manually set the X-axis range")
        self.add_options_entry(x_range_togglebox)
        x_axis_layout.addRow("Range", x_range_togglebox)

        # Connect signals for x_range_togglebox
        self.refreshing_figure.connect(lambda: self.axis.set_autoscalex_on(
            not get_box_value(x_range_togglebox, bool)))

        # Make a box for setting the scale on the x-axis
        x_scale_box = GW.QComboBox()
        x_scale_box.addItems(['linear', 'log', 'symlog', 'logit'])
        x_scale_box.setToolTip("Value scale of the X-axis")
        self.add_options_entry(x_scale_box)
        self.refreshing_figure.connect(
            lambda: self.axis.set_xscale(get_box_value(x_scale_box)))
        x_axis_layout.addRow("Scale", x_scale_box)

        # Y-AXIS
        # Create a group box for the Y-axis
        y_axis_group = GW.QGroupBox("Y-axis")
        layout.addRow(y_axis_group)
        y_axis_layout = GL.QFormLayout(y_axis_group)

        # Make a box for setting the label on the y-axis
        y_label_box = GW.FigureLabelBox()
        y_label_box[0].setToolTip("Label of the Y-axis")
        y_label_box[1].setToolTip("Label size")
        set_box_value(y_label_box, ('', {
            'fontsize': rcParams['axes.labelsize']
        }))
        self.add_options_entry(y_label_box)
        self.refreshing_figure.connect(lambda: self.axis.set_ylabel(
            *get_box_value(y_label_box, str, dict)))
        y_axis_layout.addRow("Label", y_label_box)
        self.y_label_box = y_label_box

        # Make a box for setting the range on the y-axis
        y_range_box = GW.DualLineEdit((float, float),
                                      r"<html>&le; Y &le;</html>")
        y_min_box, y_max_box = y_range_box[:]
        y_min_box.setToolTip("Minimum value of the Y-axis")
        y_max_box.setToolTip("Maximum value of the Y-axis")
        set_box_value(y_range_box, self.axis.get_ylim())

        # Connect signals for y_range_box
        self.refreshing_figure.connect(
            lambda: self.axis.set_ylim(*get_box_value(y_range_box), auto=None))
        self.axis.callbacks.connect(
            'ylim_changed', lambda y: set_box_value(y_range_box, y.get_ylim()))

        # Make togglebox for enabling/disabling the use of this range
        y_range_togglebox = GW.ToggleBox(
            y_range_box, tooltip="Check to manually set the Y-axis range")
        self.add_options_entry(y_range_togglebox)
        y_axis_layout.addRow("Range", y_range_togglebox)

        # Connect signals for y_range_togglebox
        self.refreshing_figure.connect(lambda: self.axis.set_autoscaley_on(
            not get_box_value(y_range_togglebox, bool)))

        # Make a box for setting the scale on the y-axis
        y_scale_box = GW.QComboBox()
        y_scale_box.addItems(['linear', 'log', 'symlog', 'logit'])
        y_scale_box.setToolTip("Value scale of the Y-axis")
        self.add_options_entry(y_scale_box)
        self.refreshing_figure.connect(
            lambda: self.axis.set_yscale(get_box_value(y_scale_box)))
        y_axis_layout.addRow("Scale", y_scale_box)

        # PROPS
        # Create a group box for figure properties
        props_group = GW.QGroupBox("Properties")
        layout.addRow(props_group)
        props_layout = GL.QFormLayout(props_group)

        # Make a combobox for choosing the location of the legend
        legend_loc_box = GW.QComboBox()
        legend_loc_box.addItems(mpl.legend.Legend.codes.keys())
        legend_loc_box.setToolTip("Location of the figure legend")
        set_box_value(legend_loc_box, rcParams['legend.loc'])

        # Make a togglebox for using a legend
        legend_togglebox = GW.ToggleBox(
            legend_loc_box,
            "Legend",
            tooltip="Toggle the use of a figure legend")
        self.add_options_entry(legend_togglebox)
        props_layout.addRow(legend_togglebox)
        self.legend_togglebox = legend_togglebox

        # Return tab
        return (tab, "Figure")