예제 #1
0
파일: data.py 프로젝트: 1313e/GuiPy
    def multi_data_box(self):
        """
        Creates a widget box for setting the data for multiple 'DataND' props
        and returns it.

        """

        # Make a tab widget for holding data tabs
        tab_widget = MultiDataTabWidget()
        self.tab_widget = tab_widget

        # Create add button for tabs
        add_but = GW.QToolButton()
        add_but.setToolTip("Add additional data set")
        tab_widget.setCornerWidget(add_but, QC.Qt.TopRightCorner)

        # 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('+')

        # Connect tab widget signals
        get_modified_signal(add_but).connect(self.add_data_box)
        tab_widget.tabCloseRequested.connect(self.remove_data_box)

        # Add initial data box
        self.add_data_box()

        # Return box
        return (tab_widget, )
예제 #2
0
파일: entriesbox.py 프로젝트: 1313e/GuiPy
    def add_entry(self):
        """
        Adds a new entry to the entries box.

        """

        # Create a combobox with the name of the entry
        name_box = self.get_entry_name_box()
        name_box.setToolTip("Select or type name for this entry")
        name_box.addItems(self.entry_types.keys())
        set_box_value(name_box, -1)
        get_modified_signal(name_box).connect(
            lambda: self.create_value_box(name_box))

        # Create a 'Delete'-button
        del_but = GW.QToolButton()
        del_but.setFixedSize(self.entry_height, self.entry_height)
        del_but.setToolTip("Delete this entry")
        get_modified_signal(del_but).connect(
            lambda: self.remove_entry(name_box))

        # 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))

        # Add a new row to the grid layout
        next_row = self.entries_grid.getItemPosition(
            self.entries_grid.count() - 1)[0] + 1
        self.entries_grid.addWidget(del_but, next_row, 0)
        self.entries_grid.addWidget(name_box, next_row, 1)
        self.entries_grid.addWidget(GW.QLabel(), next_row, 2)
예제 #3
0
파일: entriesbox.py 프로젝트: 1313e/GuiPy
    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)
예제 #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, 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)
예제 #7
0
    def add_item(self):
        """
        Adds a new item to the items box.

        """

        # Create an item layout
        item_layout = GL.QHBoxLayout()
        item_layout.setContentsMargins(0, 0, 0, 0)

        # Create a generic box for this item
        item_box = self.item_box()
        item_box.setToolTip("Set value of this item")
        get_modified_signal(item_box).connect(self.modified)

        # Create a 'Delete'-button
        del_but = GW.QToolButton()
        del_but.setFixedSize(self.entry_height, self.entry_height)
        del_but.setToolTip("Delete this item")
        get_modified_signal(del_but).connect(
            lambda: self.remove_item(item_layout))

        # 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))

        # Add a new row to the items layout
        item_layout.addWidget(del_but)
        item_layout.addWidget(item_box)
        self.items_layout.addLayout(item_layout)

        # Emit signal if item_box is not LongGenericBox
        if not isinstance(item_box, GW.LongGenericBox):
            self.modified.emit()
예제 #8
0
파일: data_table.py 프로젝트: 1313e/GuiPy
    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)