Python qtpy.QtCore.QSize() Examples

The following are 26 code examples of qtpy.QtCore.QSize(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qtpy.QtCore , or try the search function .
Example #1
Source File: channels.py    From conda-manager with MIT License 6 votes vote down vote up
def setup(self):
        for channel in sorted(self._channels):
            item = ListWidgetItemChannels(channel, self.list)
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)

            if channel in self._active_channels:
                item.setCheckState(Qt.Checked)
            else:
                item.setCheckState(Qt.Unchecked)

            self.list.addItem(item)
            item.setSizeHint(QSize(item.sizeHint().width(), self._height()))

        self.list.setCurrentRow(0)
        self.refresh()
        self.set_tab_order() 
Example #2
Source File: spinbox.py    From pyrpl with GNU General Public License v3.0 6 votes vote down vote up
def wheelEvent(self, event):
        """
        Handle mouse wheel event. No distinction between linear and log.
        :param event:
        :return:
        """
        if self.MOUSE_WHEEL_ACTIVATED:
            nsteps = int(event.delta() / 120)
            func = self.step_up if nsteps > 0 else self.step_down
            for i in range(abs(nsteps)):
                func(single_increment=True)


    # def sizeHint(self): #doesn t do anything, probably need to change
    #    # sizePolicy
    #    return QtCore.QSize(200, 20) 
Example #3
Source File: icon_browser.py    From qtawesome with MIT License 6 votes vote down vote up
def resizeEvent(self, event):
        """
        Re-implemented to re-calculate the grid size to provide scaling icons

        Parameters
        ----------
        event : QtCore.QEvent
        """
        width = self.viewport().width() - 30
        # The minus 30 above ensures we don't end up with an item width that
        # can't be drawn the expected number of times across the view without
        # being wrapped. Without this, the view can flicker during resize
        tileWidth = width / VIEW_COLUMNS
        iconWidth = int(tileWidth * 0.8)

        self.setGridSize(QtCore.QSize(tileWidth, tileWidth))
        self.setIconSize(QtCore.QSize(iconWidth, iconWidth))

        return super().resizeEvent(event) 
Example #4
Source File: chart.py    From Pyslvs-UI with GNU Affero General Public License v3.0 6 votes vote down vote up
def __init__(
        self,
        title: str,
        algorithm_data: Sequence[Mapping[str, Any]],
        parent: QWidget
    ):
        """Add three tabs of chart."""
        super(ChartDialog, self).__init__(parent)
        self.setWindowTitle("Chart")
        self.setWindowFlags(self.windowFlags() | Qt.WindowMaximizeButtonHint)
        self.setSizeGripEnabled(True)
        self.setModal(True)
        self.setMinimumSize(QSize(800, 600))
        self.title = title
        self.algorithm_data = algorithm_data
        # Widgets
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(6, 6, 6, 6)
        self.tab_widget = QTabWidget(self)
        self.__set_chart("F-G Plot", 0, 1, 'Generation', 'Fitness')
        self.__set_chart("G-T Plot", 2, 0, 'Time', 'Generation')
        self.__set_chart("F-T Plot", 2, 1, 'Time', 'Fitness')
        main_layout.addWidget(self.tab_widget) 
Example #5
Source File: graph_view.py    From pyflowgraph with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, parent=None):
        super(GraphView, self).__init__(parent)
        self.setObjectName('graphView')

        self.__graphViewWidget = parent

        self.setRenderHint(QtGui.QPainter.Antialiasing)
        self.setRenderHint(QtGui.QPainter.TextAntialiasing)

        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        # Explicitly set the scene rect. This ensures all view parameters will be explicitly controlled
        # in the event handlers of this class.
        size = QtCore.QSize(600, 400);
        self.resize(size)
        self.setSceneRect(-size.width() * 0.5, -size.height() * 0.5, size.width(), size.height())

        self.setAcceptDrops(True)
        self.reset() 
Example #6
Source File: rotatable.py    From Pyslvs-UI with GNU Affero General Public License v3.0 6 votes vote down vote up
def __init__(self, parent: QWidget):
        super(QRotatableView, self).__init__(parent)
        scene = QGraphicsScene(self)
        self.setScene(scene)
        self.dial = QDial()
        self.dial.setMinimumSize(QSize(150, 150))
        self.dial.setSingleStep(100)
        self.dial.setPageStep(100)
        self.dial.setInvertedAppearance(True)
        self.dial.setWrapping(True)
        self.dial.setNotchTarget(0.1)
        self.dial.setNotchesVisible(True)
        self.dial.valueChanged.connect(self.__value_changed)
        self.set_maximum(360)
        graphics_item = scene.addWidget(self.dial)
        graphics_item.setRotation(-90)
        # make the QGraphicsView invisible.
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setFixedHeight(self.dial.height())
        self.setFixedWidth(self.dial.width())
        self.setStyleSheet("border: 0px;") 
Example #7
Source File: color.py    From Pyslvs-UI with GNU Affero General Public License v3.0 5 votes vote down vote up
def color_icon(name: str, size: int = 20) -> QIcon:
    """Get color block as QIcon by name."""
    color_block = QPixmap(QSize(size, size))
    color_block.fill(color_qt(name))
    return QIcon(color_block)


# Target path color: (line, dot) 
Example #8
Source File: search.py    From conda-manager with MIT License 5 votes vote down vote up
def sizeHint(self):
        return QSize(200, self._pixmap_icon.height())

    # Public api
    # ---------- 
Example #9
Source File: channels.py    From conda-manager with MIT License 5 votes vote down vote up
def add_channel(self):
        item = ListWidgetItemChannels('', self.list)
        item.setFlags(item.flags() | Qt.ItemIsEditable |
                      Qt.ItemIsUserCheckable)
        item.setCheckState(Qt.Unchecked)
        self.list.addItem(item)
        item.setSizeHint(QSize(item.sizeHint().width(), self._height()))
        self.list.setCurrentRow(self.list.count()-1)
        self.list.editItem(item)
        self.refresh() 
Example #10
Source File: packages.py    From conda-manager with MIT License 5 votes vote down vote up
def sizeHint(self):
        return QSize(0, 0) 
Example #11
Source File: packages.py    From conda-manager with MIT License 5 votes vote down vote up
def sizeHint(self):
        return QSize(0, 0) 
Example #12
Source File: helperwidgets.py    From conda-manager with MIT License 5 votes vote down vote up
def set_icon_size(self, width, height):
        self.button_icon.setMaximumSize(QSize(width, height))
        self.setStyleSheet('LineEditSearch '
                           '{{padding-right: {0}px;}}'.format(width)) 
Example #13
Source File: lockbox_widget.py    From pyrpl with GNU General Public License v3.0 5 votes vote down vote up
def tabSizeHint(self, index):
        """
        Tab '+' and 'inputs' are smaller since they don't have a close button
        """
        size = super(MyTabBar, self).tabSizeHint(index)
        #if index==0 or index==self.parent().count() - 1:
        #    return QtCore.QSize(size.width() - 15, size.height())
        #else:
        return size 
Example #14
Source File: yml_editor.py    From pyrpl with GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        return QtCore.QSize(500,500) 
Example #15
Source File: console_widget.py    From qtconsole with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def sizeHint(self):
        """ Reimplemented to suggest a size that is 80 characters wide and
            25 lines high.
        """
        font_metrics = QtGui.QFontMetrics(self.font)
        margin = (self._control.frameWidth() +
                  self._control.document().documentMargin()) * 2
        style = self.style()
        splitwidth = style.pixelMetric(QtWidgets.QStyle.PM_SplitterWidth)

        # Note 1: Despite my best efforts to take the various margins into
        # account, the width is still coming out a bit too small, so we include
        # a fudge factor of one character here.
        # Note 2: QFontMetrics.maxWidth is not used here or anywhere else due
        # to a Qt bug on certain Mac OS systems where it returns 0.
        width = font_metrics.boundingRect(' ').width() * self.console_width + margin
        width += style.pixelMetric(QtWidgets.QStyle.PM_ScrollBarExtent)

        if self.paging == 'hsplit':
            width = width * 2 + splitwidth

        height = font_metrics.height() * self.console_height + margin
        if self.paging == 'vsplit':
            height = height * 2 + splitwidth

        return QtCore.QSize(int(width), int(height))

    #---------------------------------------------------------------------------
    # 'ConsoleWidget' public interface
    #--------------------------------------------------------------------------- 
Example #16
Source File: __init__.py    From qtawesome with MIT License 5 votes vote down vote up
def setIconSize(self, size):
        """
        set icon size

        Parameters
        ----------
        size: QtCore.QSize
            size of the icon
        """
        self._size = size 
Example #17
Source File: __init__.py    From qtawesome with MIT License 5 votes vote down vote up
def __init__(self, *names, **kwargs):
        super().__init__(parent=kwargs.get('parent'))
        self._icon = None
        self._size = QtCore.QSize(16, 16)
        self.setIcon(icon(*names, **kwargs)) 
Example #18
Source File: DepotClientViewModel.py    From P4VFX with MIT License 5 votes vote down vote up
def data(self, index, role):
        column = index.column()
        if not index.isValid():
            return None
        if role == QtCore.Qt.DisplayRole:
            item = index.internalPointer()
            return item.data[column]
        elif role == QtCore.Qt.SizeHintRole:
            return QtCore.QSize(20, 20)
        elif role == QtCore.Qt.DecorationRole:
            if column == 1:
                itemType = index.internalPointer().data[column]
                isDeleted = index.internalPointer().data[3] == 'delete'

                if isDeleted:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0104.png'))

                # Try to figure out which icon is most applicable to the item
                if itemType == "Folder":
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0059.png'))
                elif "binary" in itemType:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0315.png'))
                elif "text" in itemType:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0027.png'))
                else:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0106.png'))
            else:
                return None

        return None 
Example #19
Source File: DepotClientViewModel.py    From P4VFX with MIT License 5 votes vote down vote up
def data(self, index, role):
        column = index.column()
        if not index.isValid():
            return None
        if role == QtCore.Qt.DisplayRole:
            item = index.internalPointer()
            return item.data[column]
        elif role == QtCore.Qt.SizeHintRole:
            return QtCore.QSize(20, 20)
        elif role == QtCore.Qt.DecorationRole:
            if column == 1:
                itemType = index.internalPointer().data[column]
                isDeleted = index.internalPointer().data[3] == 'delete'

                if isDeleted:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0104.png'))

                # Try to figure out which icon is most applicable to the item
                if itemType == "Folder":
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0059.png'))
                elif "binary" in itemType:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0315.png'))
                elif "text" in itemType:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0027.png'))
                else:
                    return QtGui.QIcon(os.path.join(interop.getIconPath(), 'File0106.png'))
            else:
                return None

        return None 
Example #20
Source File: qt_dict_table.py    From napari with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def sizeHint(self):
        """Return (width, height) of the table"""
        width = sum(map(self.columnWidth, range(self.columnCount()))) + 25
        height = self.rowHeight(0) * (self.rowCount() + 1)
        return QSize(width, height) 
Example #21
Source File: utils.py    From napari with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def square_pixmap(size):
    """Create a white/black hollow square pixmap. For use as labels cursor."""
    pixmap = QPixmap(QSize(size, size))
    pixmap.fill(Qt.transparent)
    painter = QPainter(pixmap)
    painter.setPen(Qt.white)
    painter.drawRect(0, 0, size - 1, size - 1)
    painter.setPen(Qt.black)
    painter.drawRect(1, 1, size - 3, size - 3)
    painter.end()
    return pixmap 
Example #22
Source File: misc.py    From argos with GNU General Public License v3.0 5 votes vote down vote up
def resizeEvent(self, event):
        """ Resizes the details box if present (i.e. when 'Show Details' button was clicked)
        """
        result = super(ResizeDetailsMessageBox, self).resizeEvent(event)

        details_box = self.findChild(QtWidgets.QTextEdit)
        if details_box is not None:
            #details_box.setFixedSize(details_box.sizeHint())
            details_box.setFixedSize(QtCore.QSize(self.detailsBoxWidth, self.detailBoxHeight))

        return result 
Example #23
Source File: matplotlibwidget.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        return QtCore.QSize(10, 10) 
Example #24
Source File: matplotlibwidget.py    From pylustrator with GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        w, h = self.get_width_height()
        return QtCore.QSize(w, h) 
Example #25
Source File: targets_ui.py    From Pyslvs-UI with GNU Affero General Public License v3.0 4 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(346, 309)
        Dialog.setSizeGripEnabled(True)
        Dialog.setModal(True)
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.main_label = QtWidgets.QLabel(Dialog)
        self.main_label.setObjectName("main_label")
        self.verticalLayout_4.addWidget(self.main_label)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.other_label = QtWidgets.QLabel(Dialog)
        self.other_label.setObjectName("other_label")
        self.verticalLayout_3.addWidget(self.other_label)
        self.other_list = QtWidgets.QListWidget(Dialog)
        self.other_list.setObjectName("other_list")
        self.verticalLayout_3.addWidget(self.other_list)
        self.horizontalLayout.addLayout(self.verticalLayout_3)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.targets_add = QtWidgets.QPushButton(Dialog)
        self.targets_add.setMaximumSize(QtCore.QSize(30, 16777215))
        self.targets_add.setObjectName("targets_add")
        self.verticalLayout.addWidget(self.targets_add)
        self.other_add = QtWidgets.QPushButton(Dialog)
        self.other_add.setMaximumSize(QtCore.QSize(30, 16777215))
        self.other_add.setObjectName("other_add")
        self.verticalLayout.addWidget(self.other_add)
        self.horizontalLayout.addLayout(self.verticalLayout)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.targets_label = QtWidgets.QLabel(Dialog)
        self.targets_label.setObjectName("targets_label")
        self.verticalLayout_2.addWidget(self.targets_label)
        self.targets_list = QtWidgets.QListWidget(Dialog)
        self.targets_list.setObjectName("targets_list")
        self.verticalLayout_2.addWidget(self.targets_list)
        self.horizontalLayout.addLayout(self.verticalLayout_2)
        self.verticalLayout_4.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem)
        self.button_box = QtWidgets.QDialogButtonBox(Dialog)
        self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.button_box.setObjectName("button_box")
        self.horizontalLayout_2.addWidget(self.button_box)
        self.verticalLayout_4.addLayout(self.horizontalLayout_2)

        self.retranslateUi(Dialog)
        self.button_box.accepted.connect(Dialog.accept)
        self.button_box.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example #26
Source File: mainwindow.py    From qtconsole with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def closeEvent(self, event):
        """ Forward the close event to every tabs contained by the windows
        """
        if self.tab_widget.count() == 0:
            # no tabs, just close
            event.accept()
            return
        # Do Not loop on the widget count as it change while closing
        title = self.window().windowTitle()
        cancel = QtWidgets.QMessageBox.Cancel
        okay = QtWidgets.QMessageBox.Ok
        accept_role = QtWidgets.QMessageBox.AcceptRole

        if self.confirm_exit:
            if self.tab_widget.count() > 1:
                msg = "Close all tabs, stop all kernels, and Quit?"
            else:
                msg = "Close console, stop kernel, and Quit?"
            info = "Kernels not started here (e.g. notebooks) will be left alone."
            closeall = QtWidgets.QPushButton("&Quit", self)
            closeall.setShortcut('Q')
            box = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Question,
                                    title, msg)
            box.setInformativeText(info)
            box.addButton(cancel)
            box.addButton(closeall, QtWidgets.QMessageBox.YesRole)
            box.setDefaultButton(closeall)
            box.setEscapeButton(cancel)
            pixmap = QtGui.QPixmap(self._app.icon.pixmap(QtCore.QSize(64,64)))
            box.setIconPixmap(pixmap)
            reply = box.exec_()
        else:
            reply = okay

        if reply == cancel:
            event.ignore()
            return
        if reply == okay or reply == accept_role:
            while self.tab_widget.count() >= 1:
                # prevent further confirmations:
                widget = self.active_frontend
                widget._confirm_exit = False
                self.close_tab(widget)
            event.accept()