Python PyQt5.QtCore.QSize() Examples

The following are code examples for showing how to use PyQt5.QtCore.QSize(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: pyqimageview   Author: nevion   File: widget.py    MIT License 6 votes vote down vote up
def mousePressEvent(self, event):
        QGraphicsView.mousePressEvent(self, event)
        button = event.button()
        modifier = event.modifiers()

        #pan
        if modifier == Qt.ControlModifier and button == Qt.LeftButton:
            self.start_drag = event.pos()
            self.panning = True

        #initiate/show ROI selection
        if modifier == Qt.ShiftModifier and button == Qt.LeftButton:
            self.start_drag = event.pos()
            if self.rubberBand is None:
                self.rubberBand = QRubberBand(QRubberBand.Rectangle, self.viewport())
            self.rubberBand.setGeometry(QRect(self.start_drag, QSize()))
            self.rubberBand.show() 
Example 2
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 6 votes vote down vote up
def _readjust_size_policies(self):
        size_hint: QSize = self.centralWidget().sizeHint()
        width_hint, height_hint = size_hint.width(), size_hint.height()

        # TODO: remember the largest width hint, use it in order to prevent back and forth resizing when
        # TODO: the content changes?

        docked_tb = \
            self._tool_window_manager.select_widgets(current_location=ToolWindowLocation.TOP) + \
            self._tool_window_manager.select_widgets(current_location=ToolWindowLocation.BOTTOM)

        docked_lr = \
            self._tool_window_manager.select_widgets(current_location=ToolWindowLocation.LEFT) + \
            self._tool_window_manager.select_widgets(current_location=ToolWindowLocation.RIGHT)

        self.centralWidget().setMaximumHeight(height_hint if len(docked_tb) else QWIDGETSIZE_MAX)
        self.centralWidget().setMaximumWidth(width_hint if len(docked_lr) else QWIDGETSIZE_MAX) 
Example 3
Project: Lector   Author: BasioMeusPuga   File: library.py    GNU General Public License v3.0 6 votes vote down vote up
def generate_proxymodels(self):
        self.itemProxyModel = ItemProxyModel()
        self.itemProxyModel.setSourceModel(self.libraryModel)
        self.itemProxyModel.setSortCaseSensitivity(False)
        s = QtCore.QSize(160, 250)  # Set icon sizing here
        self.main_window.listView.setIconSize(s)
        self.main_window.listView.setModel(self.itemProxyModel)

        self.tableProxyModel = TableProxyModel(
            self.main_window.temp_dir.path(),
            self.main_window.tableView.horizontalHeader(),
            self.main_window.settings['consider_read_at'])
        self.tableProxyModel.setSourceModel(self.libraryModel)
        self.tableProxyModel.setSortCaseSensitivity(False)
        self.main_window.tableView.setModel(self.tableProxyModel)

        self.update_proxymodels() 
Example 4
Project: SpriteMator   Author: rafaelvasco   File: widgets.py    Apache License 2.0 6 votes vote down vote up
def __init__(self, label=None):

        super(Button, self).__init__()

        self._bgColor = QColor(51, 51, 51)
        self._activeBgColor = QColor(21, 21, 21)
        self._labelSize = QSize()
        self._size = QSize()
        self._iconSize = QSize()
        self._icon = None
        self._tooltip = None
        self._padding = 8
        self._idlePixmap = None
        self._checkedPixmap = None

        if label is not None:
            self.setText(label) 
Example 5
Project: eddy   Author: obdasystems   File: palette.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, item):
        """
        Initialize the palette button.
        :type item: Item
        """
        super().__init__()
        self.item = item
        self.startPos = None
        self.setCheckable(True)
        self.setContentsMargins(0, 0, 0, 0)
        self.setIcon(self.iconFor(item))
        self.setIconSize(QtCore.QSize(60, 44))

    #############################################
    #   EVENTS
    ################################# 
Example 6
Project: eddy   Author: obdasystems   File: palette.py    GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, paintEvent):
        """
        Perform the painting of the button in the palette.
        :type paintEvent: QPaintEvent
        """
        icon = self.icon()
        painter = QtGui.QPainter(self)
        if self.isChecked():
            painter.setBrush(QtGui.QBrush(QtGui.QColor(66, 165, 245)))
            painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(66, 165, 245)), 1.0))
            painter.drawRect(0, 0, 60, 44)
        painter.setOpacity(1.0 if self.isEnabled() else 0.33)
        painter.drawPixmap(0, 0, icon.pixmap(QtCore.QSize(60, 44)))

    #############################################
    #   INTERFACE
    ################################# 
Example 7
Project: eddy   Author: obdasystems   File: overview.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, plugin):
        """
        Initialize the Overview.
        :type plugin: Overview
        """
        super().__init__(plugin.parent())
        self.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
        self.setMinimumSize(QtCore.QSize(216, 216))
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setOptimizationFlags(QtWidgets.QGraphicsView.DontAdjustForAntialiasing)
        self.setOptimizationFlags(QtWidgets.QGraphicsView.DontSavePainterState)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setViewportUpdateMode(QtWidgets.QGraphicsView.NoViewportUpdate)
        self._mousePressed = False
        self._view = None

    #############################################
    #   PROPERTIES
    ################################# 
Example 8
Project: phidl   Author: amccaugh   File: quickplotter.py    MIT License 6 votes vote down vote up
def mousePressEvent(self, event):
        super(QGraphicsView, self).mousePressEvent(event)
        #==============================================================================
        #  Zoom to rectangle, from
        #  https://wiki.python.org/moin/PyQt/Selecting%20a%20region%20of%20a%20widget
        #==============================================================================
        if event.button() == Qt.RightButton:
            self._mousePressed = Qt.RightButton
            self._rb_origin = QPoint(event.pos())
            self.rubberBand.setGeometry(QRect(self._rb_origin, QSize()))
            self.rubberBand.show()
         #==============================================================================
        # Mouse panning, taken from
        # http://stackoverflow.com/a/15043279
        #==============================================================================
        elif event.button() == Qt.MidButton:
            self._mousePressed = Qt.MidButton
            self._mousePressedPos = event.pos()
            self.setCursor(QtCore.Qt.ClosedHandCursor)
            self._dragPos = event.pos() 
Example 9
Project: dunya-desktop   Author: MTG   File: table.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent):
        QDialog.__init__(self, parent=parent)
        self.setMinimumSize(QSize(1200, 600))
        layout = QVBoxLayout(self)

        self.label_collection = QLabel()
        self.label_collection.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.label_collection)

        self.lineedit_filter = QLineEdit(self)
        layout.addWidget(self.lineedit_filter)

        self.coll_table = TableViewCollections(self)
        layout.addWidget(self.coll_table)

        self.model = CollectionTableModel()

        self.proxy_model = SortFilterProxyModel()
        self.proxy_model.setSourceModel(self.model)
        self.proxy_model.setFilterKeyColumn(-1)

        self.coll_table.setModel(self.proxy_model)

        # signals
        self.lineedit_filter.textChanged.connect(self._lineedit_changed) 
Example 10
Project: plexdesktop   Author: coryo   File: delegates.py    GNU General Public License v3.0 6 votes vote down vote up
def placeholder_thumb_generator(title, size=150):
    """Returns a QPixmap of size with the first letter of each word in title"""
    initials = ' '.join([x[0] for x in title.split(' ') if len(x) > 2])
    key = 'placeholder' + initials
    img = QtGui.QPixmapCache.find(key)
    if img:
        return img
    qsize = QtCore.QSize(size, size)
    circle_color = QtGui.QColor(50, 50, 50)
    text_color = QtGui.QColor(75, 75, 75)
    rect = QtCore.QRect(QtCore.QPoint(0, 0), QtCore.QPoint(size, size))
    center = QtCore.QPoint(size / 2, size / 2)
    img = QtGui.QPixmap(qsize)
    img.fill(QtCore.Qt.transparent)
    p = QtGui.QPainter(img)
    p.setFont(QtGui.QFont('Open Sans', size / 4, weight=QtGui.QFont.Bold))
    p.setBrush(QtGui.QBrush(circle_color))
    p.setPen(circle_color)
    p.setRenderHint(QtGui.QPainter.Antialiasing, True)
    p.drawEllipse(center, size / 2 - 1, size / 2 - 1)
    p.setPen(text_color)
    p.drawText(rect, QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter, initials)
    QtGui.QPixmapCache.insert(key, img)
    return img 
Example 11
Project: plexdesktop   Author: coryo   File: hubtree.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent=None):
        super().__init__(parent)
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.context_menu)
        self.setItemsExpandable(False)
        self.doubleClicked.connect(self.double_click)
        self.setIconSize(QtCore.QSize(36, 36))
        self.setAlternatingRowColors(True)
        self.setIndentation(10)
        self._model = None

        self._worker_thread = QtCore.QThread(self)
        self._worker = plexdesktop.workers.HubWorker()
        self._worker.moveToThread(self._worker_thread)
        self._worker.result_ready.connect(self._add_container)
        self.request_container.connect(self._worker.run)
        self._worker_thread.start()
        self.delegate = plexdesktop.delegates.ListDelegate(self)
        self.setItemDelegate(self.delegate)
        self.goto_hub.connect(self.load_hub) 
Example 12
Project: bigquerylayers   Author: smandaric   File: utilities.py    GNU General Public License v3.0 5 votes vote down vote up
def get_qgis_app():
    """ Start one QGIS application to test against.

    :returns: Handle to QGIS app, canvas, iface and parent. If there are any
        errors the tuple members will be returned as None.
    :rtype: (QgsApplication, CANVAS, IFACE, PARENT)

    If QGIS is already running the handle to that app will be returned.
    """

    try:
        from PyQt5 import QtGui, QtCore
        from qgis.core import QgsApplication
        from qgis.gui import QgsMapCanvas
        from .qgis_interface import QgisInterface
    except ImportError:
        return None, None, None, None

    global QGIS_APP  # pylint: disable=W0603

    if QGIS_APP is None:
        gui_flag = True  # All test will run qgis in gui mode
        #noinspection PyPep8Naming
        QGIS_APP = QgsApplication(sys.argv, gui_flag)
        # Make sure QGIS_PREFIX_PATH is set in your env if needed!
        QGIS_APP.initQgis()
        s = QGIS_APP.showSettings()
        LOGGER.debug(s)

    global PARENT  # pylint: disable=W0603
    if PARENT is None:
        #noinspection PyPep8Naming
        PARENT = QtGui.QWidget()

    global CANVAS  # pylint: disable=W0603
    if CANVAS is None:
        #noinspection PyPep8Naming
        CANVAS = QgsMapCanvas(PARENT)
        CANVAS.resize(QtCore.QSize(400, 400))

    global IFACE  # pylint: disable=W0603
    if IFACE is None:
        # QgisInterface is a stub implementation of the QGIS plugin interface
        #noinspection PyPep8Naming
        IFACE = QgisInterface(CANVAS)

    return QGIS_APP, CANVAS, IFACE, PARENT 
Example 13
Project: Adfly-Bot   Author: vkpdeveloper   File: main.py    MIT License 5 votes vote down vote up
def initWindow(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.top, self.left, self.width, self.height)
        self.setWindowIcon(QIcon(self.iconName))
        self.setStyleSheet("background:white")
        # self.setAutoFillBackground(True)
        # p = self.palette()
        # p.setColor(self.backgroundRole(), Qt.white)
        # self.setPalette(p)
        App.setMinimumSize(self, QSize(400, 400))
        App.setMaximumSize(self, QSize(400, 400))
        self.uiComponet()
        self.show() 
Example 14
Project: openocd-svd   Author: esynr3z   File: ui_widgets.py    MIT License 5 votes vote down vote up
def __init__(self, svd_reg):
        QWidget.__init__(self)
        self.svd = svd_reg
        self.horiz_layout = QHBoxLayout(self)
        self.horiz_layout.setContentsMargins(0, 0, 0, 0)
        self.horiz_layout.setSpacing(0)
        self.nedit_val = NumEdit(32)
        self.nedit_val.editingFinished.connect(self.handle_reg_value_changed)
        self.nedit_val.setMinimumSize(QtCore.QSize(320, 20))
        self.nedit_val.setMaximumSize(QtCore.QSize(16777215, 20))
        self.nedit_val.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed))
        self.horiz_layout.addWidget(self.nedit_val)
        self.btn_read = QPushButton(self)
        self.btn_read.setText("R")
        self.btn_read.setMaximumSize(QtCore.QSize(25, 20))
        self.horiz_layout.addWidget(self.btn_read)
        self.btn_write = QPushButton(self)
        self.btn_write.setText("W")
        self.btn_write.setMaximumSize(QtCore.QSize(25, 20))
        self.horiz_layout.addWidget(self.btn_write)
        self.fields = {}
        for field in self.svd["fields"]:
            self.fields[field["name"]] = FieldEdit(field)
            self.fields[field["name"]].valueChanged.connect(self.handle_field_value_changed)
        self.__opt_autowrite = False

    # -- Slots -- 
Example 15
Project: openocd-svd   Author: esynr3z   File: ui_about.py    MIT License 5 votes vote down vote up
def setupUi(self, AboutDialog):
        AboutDialog.setObjectName("AboutDialog")
        AboutDialog.setWindowModality(QtCore.Qt.NonModal)
        AboutDialog.resize(350, 200)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(AboutDialog.sizePolicy().hasHeightForWidth())
        AboutDialog.setSizePolicy(sizePolicy)
        AboutDialog.setMinimumSize(QtCore.QSize(350, 200))
        AboutDialog.setMaximumSize(QtCore.QSize(350, 200))
        AboutDialog.setModal(False)
        self.verticalLayout = QtWidgets.QVBoxLayout(AboutDialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.lab_version = QtWidgets.QLabel(AboutDialog)
        self.lab_version.setAlignment(QtCore.Qt.AlignCenter)
        self.lab_version.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse)
        self.lab_version.setObjectName("lab_version")
        self.verticalLayout.addWidget(self.lab_version)
        self.label_2 = QtWidgets.QLabel(AboutDialog)
        self.label_2.setAlignment(QtCore.Qt.AlignCenter)
        self.label_2.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse)
        self.label_2.setObjectName("label_2")
        self.verticalLayout.addWidget(self.label_2)
        self.label_3 = QtWidgets.QLabel(AboutDialog)
        self.label_3.setAlignment(QtCore.Qt.AlignCenter)
        self.label_3.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse)
        self.label_3.setObjectName("label_3")
        self.verticalLayout.addWidget(self.label_3)
        self.buttonBox = QtWidgets.QDialogButtonBox(AboutDialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)

        self.retranslateUi(AboutDialog)
        self.buttonBox.clicked['QAbstractButton*'].connect(AboutDialog.close)
        QtCore.QMetaObject.connectSlotsByName(AboutDialog) 
Example 16
Project: idasec   Author: RobinDavid   File: static_opaque_analysis.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def make_progress_bar(self, parent):
        horizontalLayout_2 = QtWidgets.QHBoxLayout()
        horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.loading_stat = QtWidgets.QLabel(parent)
        horizontalLayout_2.addWidget(self.loading_stat)
        self.progressbar_loading = QtWidgets.QProgressBar(parent)
        horizontalLayout_2.addWidget(self.progressbar_loading)
        self.stop_button = QtWidgets.QPushButton(parent)
        self.stop_button.setMaximumSize(QtCore.QSize(50, 30))
        self.stop_button.setText("stop")
        horizontalLayout_2.addWidget(self.stop_button)
        self.stop_button.clicked.connect(self.stop_button_clicked)
        return horizontalLayout_2 
Example 17
Project: pymovie   Author: bob-anderson-ok   File: aperturesFileTagDialog.py    MIT License 5 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(600, 102)
        Dialog.setMinimumSize(QtCore.QSize(400, 0))
        Dialog.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.gridLayout = QtWidgets.QGridLayout(Dialog)
        self.gridLayout.setObjectName("gridLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.apertureGroupTagEdit = QtWidgets.QLineEdit(Dialog)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.apertureGroupTagEdit.setFont(font)
        self.apertureGroupTagEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.apertureGroupTagEdit.setMaxLength(80)
        self.apertureGroupTagEdit.setObjectName("apertureGroupTagEdit")
        self.verticalLayout.addWidget(self.apertureGroupTagEdit)
        self.horizontalLayout.addLayout(self.verticalLayout)
        self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
        self.buttonBox.setOrientation(QtCore.Qt.Vertical)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setCenterButtons(True)
        self.buttonBox.setObjectName("buttonBox")
        self.horizontalLayout.addWidget(self.buttonBox)
        self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example 18
Project: pymovie   Author: bob-anderson-ok   File: ocrProfileNameDialog.py    MIT License 5 votes vote down vote up
def setupUi(self, ocrNameDialog):
        ocrNameDialog.setObjectName("ocrNameDialog")
        ocrNameDialog.resize(859, 203)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(ocrNameDialog.sizePolicy().hasHeightForWidth())
        ocrNameDialog.setSizePolicy(sizePolicy)
        ocrNameDialog.setMinimumSize(QtCore.QSize(0, 0))
        ocrNameDialog.setMaximumSize(QtCore.QSize(16777215, 300))
        self.gridLayout = QtWidgets.QGridLayout(ocrNameDialog)
        self.gridLayout.setObjectName("gridLayout")
        self.label = QtWidgets.QLabel(ocrNameDialog)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
        self.profileNameEdit = QtWidgets.QLineEdit(ocrNameDialog)
        self.profileNameEdit.setObjectName("profileNameEdit")
        self.gridLayout.addWidget(self.profileNameEdit, 1, 0, 1, 1)
        self.buttonBox = QtWidgets.QDialogButtonBox(ocrNameDialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1)

        self.retranslateUi(ocrNameDialog)
        self.buttonBox.accepted.connect(ocrNameDialog.accept)
        self.buttonBox.rejected.connect(ocrNameDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(ocrNameDialog) 
Example 19
Project: pymovie   Author: bob-anderson-ok   File: apertureNameDialog.py    MIT License 5 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(609, 84)
        Dialog.setMinimumSize(QtCore.QSize(600, 0))
        Dialog.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.gridLayout = QtWidgets.QGridLayout(Dialog)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.apertureNameEdit = QtWidgets.QLineEdit(Dialog)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.apertureNameEdit.setFont(font)
        self.apertureNameEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.apertureNameEdit.setMaxLength(80)
        self.apertureNameEdit.setObjectName("apertureNameEdit")
        self.verticalLayout.addWidget(self.apertureNameEdit)
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
        self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
        self.buttonBox.setOrientation(QtCore.Qt.Vertical)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 0, 1, 1, 1)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example 20
Project: social_mind   Author: byeongkyu   File: QVTKRenderWindowInteractor.py    Apache License 2.0 5 votes vote down vote up
def sizeHint(self):
        return QSize(400, 400) 
Example 21
Project: HippMapp3r   Author: mgoubran   File: gui.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None, *args, **kwargs):
        self.tabSize = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
        QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs) 
Example 22
Project: cct   Author: awacha   File: subtractionparameterdelegate.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def sizeHint(self, option: QtWidgets.QStyleOptionViewItem, index: QtCore.QModelIndex) -> QtCore.QSize:
        sb = QtWidgets.QDoubleSpinBox()
        sb.setFrame(False)
        try:
            return QtCore.QSize(int(sb.sizeHint().width() * 4), sb.sizeHint().height())
        finally:
            sb.destroy() 
Example 23
Project: PyLSS   Author: gmrandazzo   File: gui_aboutdialog.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def setupUi(self, AboutDialog):
        AboutDialog.setObjectName("AboutDialog")
        AboutDialog.resize(339, 106)
        self.gridLayout = QtWidgets.QGridLayout(AboutDialog)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(AboutDialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.label_2 = QtWidgets.QLabel(AboutDialog)
        self.label_2.setOpenExternalLinks(True)
        self.label_2.setObjectName("label_2")
        self.verticalLayout.addWidget(self.label_2)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.closeButton = QtWidgets.QPushButton(AboutDialog)
        self.closeButton.setMaximumSize(QtCore.QSize(110, 32))
        self.closeButton.setObjectName("closeButton")
        self.horizontalLayout.addWidget(self.closeButton)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)

        self.retranslateUi(AboutDialog)
        QtCore.QMetaObject.connectSlotsByName(AboutDialog) 
Example 24
Project: PyLSS   Author: gmrandazzo   File: gui_plotmaps.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def setupUi(self, PlotMaps):
        PlotMaps.setObjectName("PlotMaps")
        PlotMaps.resize(811, 654)
        self.gridLayout = QtWidgets.QGridLayout(PlotMaps)
        self.gridLayout.setObjectName("gridLayout")
        self.label_4 = QtWidgets.QLabel(PlotMaps)
        self.label_4.setObjectName("label_4")
        self.gridLayout.addWidget(self.label_4, 0, 0, 1, 1)
        spacerItem = QtWidgets.QSpacerItem(358, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem, 0, 1, 1, 1)
        self.modelBox = QtWidgets.QComboBox(PlotMaps)
        self.modelBox.setMinimumSize(QtCore.QSize(260, 26))
        self.modelBox.setObjectName("modelBox")
        self.gridLayout.addWidget(self.modelBox, 0, 2, 1, 1)
        self.plotterBox = QtWidgets.QGroupBox(PlotMaps)
        self.plotterBox.setMinimumSize(QtCore.QSize(551, 311))
        self.plotterBox.setObjectName("plotterBox")
        self.gridLayout.addWidget(self.plotterBox, 1, 0, 1, 4)
        spacerItem1 = QtWidgets.QSpacerItem(932, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem1, 2, 0, 1, 3)
        self.closeButton = QtWidgets.QPushButton(PlotMaps)
        self.closeButton.setMaximumSize(QtCore.QSize(110, 32))
        self.closeButton.setObjectName("closeButton")
        self.gridLayout.addWidget(self.closeButton, 2, 3, 1, 1)
        self.closeButton.raise_()
        self.plotterBox.raise_()

        self.retranslateUi(PlotMaps)
        QtCore.QMetaObject.connectSlotsByName(PlotMaps) 
Example 25
Project: PyQt-multifunctional-uart-helper   Author: IronSublimate   File: uart.py    MIT License 5 votes vote down vote up
def com_receive_image(self, cb_index, extra_bytes_len) -> (QBitmap, tuple):
        if len(self.img_rx_data) == 0:
            self.img_rx_data = self.readAll()
            # print(type(self.imgrxData))
            if self.img_rx_data[:2] != b'\x01\xfe':  # 不是图像的起始位
                self.img_rx_data.clear()
                return None
            else:
                # self.imgrxData=self.imgrxData[2:]
                return None
        else:
            self.img_rx_data += self.readAll()
        # if self.imgrxData[:2]==b'\x01\xfe' and self.imgrxData[-2:]==b'\xfe\x01':
        if len(self.img_rx_data) >= self.totalImgSize + 2 + extra_bytes_len:  # 校验位两位,其余14位为传的数据
            self.clear()
            # cb_index = selfboBox_imgType.currentIndex()
            extra_data = tuple(
                bytes(self.img_rx_data[2:2 + extra_bytes_len]))  # 14位额外数据
            # print(type( self.label_img.extra_data[0]))
            # print(self.label_img.extra_data)
            if cb_index == 0:  # 二值化图像
                self.img = QBitmap.fromData(QSize(self.imgWidth, self.imgHeight),
                                            bytes(self.img_rx_data[2 + extra_bytes_len:]),
                                            QImage.Format_Mono)
            elif cb_index == 1:  # 灰度图像
                # imgbytes = bytes(self.imgrxData[2:])
                # self.img = QImage(imgbytes, self.imgWidth,self.imgHeight, QImage.Format_Mono)
                imgbytes = bytes([255 if int.from_bytes(b, 'little') > 0 else 0 for b in
                                  self.img_rx_data[2 + extra_bytes_len:]])
                self.img = QBitmap.fromImage(
                    QImage(imgbytes, self.imgWidth, self.imgHeight, QImage.Format_Grayscale8))
                # import numpy as np
                # a=np.frombuffer(bytes(self.imgrxData[2:]),dtype=np.uint8)*128
                # imgbytes=bytes(a)
            # OpenCVUse.process(imgbytes, self.imgHeight, self.imgWidth)
            # self.label_img.setPixmap(self.img)
            self.img_rx_data.clear()
            return self.img, extra_data

    # 串口其他模式处理函数 
Example 26
Project: Lector   Author: BasioMeusPuga   File: __main__.py    GNU General Public License v3.0 5 votes vote down vote up
def resizeEvent(self, event=None):
        if event:
            # This implies a vertical resize event only
            # We ain't about that lifestyle
            if event.oldSize().width() == event.size().width():
                return

        # The hackiness of this hack is just...
        default_size = 170  # This is size of the QIcon (160 by default) +
                            # minimum margin needed between thumbnails

        # for n icons, the n + 1th icon will appear at > n +1.11875
        # First, calculate the number of images per row
        i = self.listView.viewport().width() / default_size
        rem = i - int(i)
        if rem >= .21875 and rem <= .9999:
            num_images = int(i)
        else:
            num_images = int(i) - 1

        # The rest is illustrated using informative variable names
        space_occupied = num_images * default_size
        # 12 is the scrollbar width
        # Larger numbers keep reduce flickering but also increase
        # the distance from the scrollbar
        space_left = (
            self.listView.viewport().width() - space_occupied - 19)
        try:
            layout_extra_space_per_image = space_left // num_images
            self.listView.setGridSize(
                QtCore.QSize(default_size + layout_extra_space_per_image, 250))
            self.start_culling_timer()
        except ZeroDivisionError:  # Initial resize is ignored
            return 
Example 27
Project: Lector   Author: BasioMeusPuga   File: metadatadialog.py    GNU General Public License v3.0 5 votes vote down vote up
def load_cover(self, cover, use_as_is=False):
        if use_as_is:
            image_pixmap = cover
        else:
            image_pixmap = cover.pixmap(QtCore.QSize(140, 205))

        graphics_scene = PliantQGraphicsScene(self)
        graphics_scene.addPixmap(image_pixmap)
        self.coverView.setScene(graphics_scene) 
Example 28
Project: Lector   Author: BasioMeusPuga   File: dockwidgets.py    GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        return QtCore.QSize(self.adjusted_size, 32) 
Example 29
Project: Lector   Author: BasioMeusPuga   File: toolbars.py    GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        return QtCore.QSize(self.adjusted_size, 32) 
Example 30
Project: Lector   Author: BasioMeusPuga   File: toolbars.py    GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        return QtCore.QSize(self.adjusted_size, 32) 
Example 31
Project: Lector   Author: BasioMeusPuga   File: toolbars.py    GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        return QtCore.QSize(36, 30) 
Example 32
Project: SpriteMator   Author: rafaelvasco   File: widgets.py    Apache License 2.0 5 votes vote down vote up
def sizeHint(self):

        return QSize(200, 25) 
Example 33
Project: SpriteMator   Author: rafaelvasco   File: animation_manager_widget.py    Apache License 2.0 5 votes vote down vote up
def sizeHint(self):

        return QSize(self._frameSize, self._frameSize) 
Example 34
Project: SpriteMator   Author: rafaelvasco   File: color_picker_widget.py    Apache License 2.0 5 votes vote down vote up
def sizeHint(self):

        return QSize(223, 17)


# ----------------------------------------------------------------------------- 
Example 35
Project: SpriteMator   Author: rafaelvasco   File: color_picker_widget.py    Apache License 2.0 5 votes vote down vote up
def sizeHint(self):

        return QSize(223, 223)


# ----------------------------------------------------------------------------- 
Example 36
Project: SpriteMator   Author: rafaelvasco   File: color_picker_widget.py    Apache License 2.0 5 votes vote down vote up
def sizeHint(self):

        return QSize(223, 30) 
Example 37
Project: SpriteMator   Author: rafaelvasco   File: options_bar_widget.py    Apache License 2.0 5 votes vote down vote up
def sizeHint(self):
        return QSize(0, 26) 
Example 38
Project: eddy   Author: obdasystems   File: palette.py    GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """
        Returns the recommended size for this widget.
        :rtype: QtCore.QSize
        """
        return QtCore.QSize(216, 342) 
Example 39
Project: eddy   Author: obdasystems   File: ontology_explorer.py    GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """
        Returns the recommended size for this widget.
        :rtype: QtCore.QSize
        """
        return QtCore.QSize(216, 266) 
Example 40
Project: eddy   Author: obdasystems   File: project_explorer.py    GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """
        Returns the recommended size for this widget.
        :rtype: QtCore.QSize
        """
        return QtCore.QSize(216, 266) 
Example 41
Project: eddy   Author: obdasystems   File: Explanation_explorer.py    GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """
        Returns the recommended size for this widget.
        :rtype: QtCore.QSize
        """
        return QtCore.QSize(216, 266) 
Example 42
Project: eddy   Author: obdasystems   File: Unsatisfiable_Entity_Explorer.py    GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """
        Returns the recommended size for this widget.
        :rtype: QtCore.QSize
        """
        return QtCore.QSize(216, 266) 
Example 43
Project: pdash   Author: CPChain   File: gif.py    GNU General Public License v3.0 5 votes vote down vote up
def ui(self):
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setAlignment(Qt.AlignCenter)
        label = QLabel('', self)
        movie = QtGui.QMovie(self.path)
        movie.setCacheMode(QtGui.QMovie.CacheAll)
        movie.setSpeed(80)
        movie.setScaledSize(QSize(self.width_, self.height_))
        label.setMovie(movie)
        movie.start()
        layout.addWidget(label)
        self.setContentsMargins(0, 0, 0, 0)
        return layout 
Example 44
Project: BBoxEE   Author: persts   File: export_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, icon_size, parent=None):
        """Class init function."""
        QtWidgets.QWidget.__init__(self, parent)
        self.setupUi(self)
        self.base_data = {}
        self.masks = {}
        self.label_map = {}

        self.globber = Globber()
        self.globber.finished.connect(self.display)
        self.globber.init_progress.connect(self.init_progress_bar)
        self.globber.progress.connect(self.progressBar.setValue)

        size = QtCore.QSize(icon_size, icon_size)
        self.pb_select_directory.setIconSize(size)
        self.pb_select_directory.setIcon(QtGui.QIcon(':/icons/folder.svg'))
        self.pb_select_directory.clicked.connect(self.load_annotation_files)

        self.pb_export.clicked.connect(self.export_preflight)

        (self.tw_files.
            setSelectionBehavior(QtWidgets.
                                 QAbstractItemView.SelectRows))
        (self.tw_files.
            selectionModel().
            selectionChanged.
            connect(self.selection_changed))
        (self.tw_files.
            horizontalHeader().
            setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch))

        (self.tw_remap.
            horizontalHeader().
            setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch))
        self.tw_remap.cellChanged.connect(self.update_label_map)

        self.cb_truncated.stateChanged.connect(self.exclude_changed)
        self.cb_occluded.stateChanged.connect(self.exclude_changed)
        self.cb_difficult.stateChanged.connect(self.exclude_changed) 
Example 45
Project: hpimon   Author: jjnurminen   File: hpimon.py    MIT License 5 votes vote down vote up
def sizeHint(self):
        return QtCore.QSize(self.diam, self.diam) 
Example 46
Project: dunya-desktop   Author: MTG   File: general_design.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_main_window(self):
        """Sets the size policies of the main window"""
        self.resize(1000, 750)
        size_policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(size_policy)
        self.setMinimumSize(QtCore.QSize(1000, 750))

        # main window icon
        self.setWindowIcon(QIcon(DUNYA_ICON))
        self.setWindowTitle('Dunya Desktop') 
Example 47
Project: dunya-desktop   Author: MTG   File: general_design.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_status_bar(self):
        self.statusbar.setMinimumSize(QtCore.QSize(0, 18))
        font = QFont()
        font.setPointSize(9)
        self.statusbar.setFont(font) 
Example 48
Project: dunya-desktop   Author: MTG   File: histogram.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super(HistogramDialog, self).__init__()
        self.setMinimumSize(QSize(500, 325))
        self.setContentsMargins(0, 0, 0, 0)

        self.hist_widget = pg.PlotWidget(self)
        l = QVBoxLayout(self)
        l.addWidget(self.hist_widget)
        l.setContentsMargins(0, 0, 0, 0) 
Example 49
Project: dunya-desktop   Author: MTG   File: dockwidget.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_widget(self):
        """Sets the size policies."""
        size_policy = QSizePolicy(QSizePolicy.MinimumExpanding,
                                  QSizePolicy.Preferred)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(size_policy)
        self.setMaximumSize(QSize(500, 16777215)) 
Example 50
Project: dunya-desktop   Author: MTG   File: dockwidget.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_frame(self):
        """Sets the size policies of the frame."""
        size_policy = QSizePolicy(QSizePolicy.MinimumExpanding,
                                  QSizePolicy.Preferred)
        # size_policy.setHorizontalStretch(0)
        # size_policy.setVerticalStretch(0)
        # size_policy.setHeightForWidth(
        #    self.frame_collection.sizePolicy().hasHeightForWidth())
        self.frame_collection.setSizePolicy(size_policy)
        # self.frame_collection.setMinimumSize(QSize(0, 200))
        # self.frame_collection.setMaximumSize(QSize(16777215, 200))
        # self.frame_collection.setBaseSize(QSize(10, 10))
        self.frame_collection.setFrameShape(QFrame.Box)
        # self.frame_collection.setFrameShadow(QFrame.Raised)