Python PyQt5.QtCore.QSize() Examples

The following are 30 code examples for showing how to use PyQt5.QtCore.QSize(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtCore , or try the search function .

Example 1
Project: qutebrowser   Author: qutebrowser   File: test_miscwidgets.py    License: GNU General Public License v3.0 6 votes vote down vote up
def test_read_size(self, config, width, height, position, expected_size,
                       state_config, splitter, fake_inspector, caplog):
        if config is not None:
            state_config['inspector'] = {position.name: config}

        splitter.resize(width, height)
        assert splitter.size() == QSize(width, height)

        with caplog.at_level(logging.ERROR):
            splitter.set_inspector(fake_inspector, position)

        assert splitter._preferred_size == expected_size

        if config == {'left': 'verybig'}:
            assert caplog.messages == ["Could not read inspector size: "
                                       "invalid literal for int() with "
                                       "base 10: 'verybig'"] 
Example 2
Project: qutebrowser   Author: qutebrowser   File: completionwidget.py    License: GNU General Public License v3.0 6 votes vote down vote up
def sizeHint(self):
        """Get the completion size according to the config."""
        # Get the configured height/percentage.
        confheight = str(config.val.completion.height)
        if confheight.endswith('%'):
            perc = int(confheight.rstrip('%'))
            height = self.window().height() * perc // 100
        else:
            height = int(confheight)
        # Shrink to content size if needed and shrinking is enabled
        if config.val.completion.shrink:
            contents_height = (
                self.viewportSizeHint().height() +
                self.horizontalScrollBar().sizeHint().height())
            if contents_height <= height:
                height = contents_height
        # The width isn't really relevant as we're expanding anyways.
        return QSize(-1, height) 
Example 3
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: breathing_phrase_list_wt.py    License: GNU General Public License v3.0 6 votes vote down vote up
def update_gui(self, i_event_source=mc.mc_global.EventSource.undefined):
        self.updating_gui_bool = True

        # If the list is now empty, disabling buttons
        # If the list is no longer empty, enable buttons
        self.set_button_states(mc.model.PhrasesM.is_empty())

        # List
        self.list_widget.clear()
        for l_phrase in mc.model.PhrasesM.get_all():
            # self.list_widget.addItem(l_collection.title_str)
            custom_label = CustomQLabel(l_phrase.title, l_phrase.id)
            list_item = QtWidgets.QListWidgetItem()
            list_item.setSizeHint(QtCore.QSize(list_item.sizeHint().width(), mc_global.LIST_ITEM_HEIGHT_INT))
            self.list_widget.addItem(list_item)
            self.list_widget.setItemWidget(list_item, custom_label)

        if i_event_source == mc.mc_global.EventSource.breathing_phrase_deleted:
            self.update_selected(0)
        else:
            self.update_selected()

        self.updating_gui_bool = False 
Example 4
Project: Lector   Author: BasioMeusPuga   File: library.py    License: 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 5
Project: phidl   Author: amccaugh   File: quickplotter.py    License: 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 6
Project: dunya-desktop   Author: MTG   File: table.py    License: 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 7
Project: detection   Author: xsyann   File: window_ui.py    License: GNU General Public License v2.0 6 votes vote down vote up
def widgetClassifierDisplay(self):
        """Create classifier display widget.
        """
        self.colorPicker = QPushButton('')
        self.colorPicker.setMaximumSize(QtCore.QSize(16, 16))
        self.shapeCBox = QComboBox(self)
        self.fillCBox = QComboBox(self)
        self.fillPath = QPushButton('...')
        self.fillPath.setMaximumWidth(40)
        self.showName = QCheckBox(self.tr('Show Name'))

        hbox = QHBoxLayout()
        hbox.addWidget(QLabel(self.tr('Shape')))
        hbox.addWidget(self.shapeCBox)
        hbox.addWidget(self.fillCBox)
        hbox.addWidget(self.fillPath)
        hbox.addWidget(self.colorPicker)
        hbox.addStretch(1)

        vbox = QVBoxLayout()
        vbox.addWidget(self.showName)
        vbox.addLayout(hbox)
        return vbox 
Example 8
Project: detection   Author: xsyann   File: window_ui.py    License: GNU General Public License v2.0 6 votes vote down vote up
def widgetGlobalParam(self):
        """Create global parameters widget.
        """
        hbox = QHBoxLayout()
        self.displayCBox = QComboBox(self)
        self.bgCBox = QComboBox(self)
        self.bgColorPicker = QPushButton('')
        self.bgColorPicker.setMaximumSize(QtCore.QSize(16, 16))
        self.bgPathButton = QPushButton('...')
        self.bgPathButton.setMaximumWidth(45)
        hbox.addWidget(QLabel(self.tr('Display')))
        hbox.addWidget(self.displayCBox)
        hbox.addStretch(1)
        hbox.addWidget(QLabel(self.tr('Background')))
        hbox.addWidget(self.bgCBox)
        hbox.addWidget(self.bgColorPicker)
        hbox.addWidget(self.bgPathButton)

        self.equalizeHist = QCheckBox(self.tr('Equalize histogram'))

        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(self.equalizeHist)
        return vbox 
Example 9
Project: persepolis   Author: persepolisdm   File: about.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, persepolis_setting):
        super().__init__(persepolis_setting)

        self.persepolis_setting = persepolis_setting

        # setting window size and position
        size = self.persepolis_setting.value(
            'AboutWindow/size', QSize(545, 375))
        position = self.persepolis_setting.value(
            'AboutWindow/position', QPoint(300, 300))

        # read translators.txt files.
        # this file contains all translators.
        f = QFile(':/translators.txt')

        f.open(QIODevice.ReadOnly | QFile.Text)
        f_text = QTextStream(f).readAll()
        f.close()

        self.translators_textEdit.insertPlainText(f_text)



        self.resize(size)
        self.move(position) 
Example 10
Project: pyleecan   Author: Eomys   File: WBarOut.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self, parent=None):
        """Initialize the widget
        """
        # Main widget setup
        QWidget.__init__(self, parent)
        self.u = gui_option.unit
        self.setTitle(self.tr("Output"))
        self.setMinimumSize(QSize(200, 0))
        self.setObjectName("g_output")
        self.layout = QVBoxLayout(self)
        self.layout.setObjectName("layout")

        # The widget is composed of 3 QLabel in a vertical layout
        self.out_Sbar = QLabel(self)
        self.out_Sbar.setObjectName("out_Sbar")
        self.layout.addWidget(self.out_Sbar)

        self.out_Sslot = QLabel(self)
        self.out_Sslot.setObjectName("out_Sslot")
        self.layout.addWidget(self.out_Sslot)

        self.out_ratio = QLabel(self)
        self.out_ratio.setMinimumSize(QSize(140, 0))
        self.out_ratio.setObjectName("out_ratio")
        self.layout.addWidget(self.out_ratio) 
Example 11
Project: pkmeter   Author: pkkid   File: pkmixins.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def attribute_bgsize(self, value):
        try:
            bgsize = value.lower()
            self.bgsize = bgsize if bgsize == 'fit' else QtCore.QSize(*map(int, bgsize.split(',')))
        except:
            log.exception('Invalid background size: %s', value) 
Example 12
Project: simnibs   Author: simnibs   File: electrodeGUI.py    License: GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        return QtCore.QSize(50, 50) 
Example 13
Project: simnibs   Author: simnibs   File: electrodeGUI.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        return QtCore.QSize(450, 450) 
Example 14
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        return QtCore.QSize(1200,1000) 
Example 15
Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def minumumSizeHint(self):
        return QtCore.QSize(500, 500) 
Example 16
Project: simnibs   Author: simnibs   File: head_model_OGL.py    License: GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        return QtCore.QSize(300, 300) 
Example 17
Project: idasec   Author: RobinDavid   File: static_opaque_analysis.py    License: 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 18
Project: qutebrowser   Author: qutebrowser   File: fixtures.py    License: GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        return QSize(1, self.fontMetrics().height()) 
Example 19
Project: qutebrowser   Author: qutebrowser   File: test_miscwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        return QSize(23, 42) 
Example 20
Project: qutebrowser   Author: qutebrowser   File: test_miscwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_size_hint(self, container):
        assert container.sizeHint() == QSize(23, 42) 
Example 21
Project: qutebrowser   Author: qutebrowser   File: test_miscwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_adjust_size(self, old_window_size, preferred_size,
                         new_window_size, exp_inspector_size,
                         position, splitter, fake_inspector, qtbot):
        def resize(dim):
            size = (QSize(dim, 666) if splitter.orientation() == Qt.Horizontal
                    else QSize(666, dim))
            splitter.resize(size)
            if splitter.size() != size:
                pytest.skip("Resizing window failed")

        splitter.set_inspector(fake_inspector, position)
        splitter.show()
        resize(old_window_size)

        handle_width = 4
        splitter.setHandleWidth(handle_width)

        splitter_idx = 1
        if position in [inspector.Position.left, inspector.Position.top]:
            splitter_pos = preferred_size - handle_width//2
        else:
            splitter_pos = old_window_size - preferred_size - handle_width//2
        splitter.moveSplitter(splitter_pos, splitter_idx)

        resize(new_window_size)

        sizes = splitter.sizes()
        inspector_size = sizes[splitter._inspector_idx]
        main_size = sizes[splitter._main_idx]
        exp_main_size = new_window_size - exp_inspector_size

        exp_main_size -= handle_width // 2
        exp_inspector_size -= handle_width // 2

        assert (inspector_size, main_size) == (exp_inspector_size,
                                               exp_main_size) 
Example 22
Project: qutebrowser   Author: qutebrowser   File: downloadview.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """Return sizeHint based on the view contents."""
        idx = self.model().last_index()
        bottom = self.visualRect(idx).bottom()
        if bottom != -1:
            margins = self.contentsMargins()
            height = (bottom + margins.top() + margins.bottom() +
                      2 * self.spacing())
            size = QSize(0, height)
        else:
            size = QSize(0, 0)
        qtutils.ensure_valid(size)
        return size 
Example 23
Project: qutebrowser   Author: qutebrowser   File: miscwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def minimumSizeHint(self):
        """Return a sensible size."""
        return QSize(8, 8) 
Example 24
Project: qutebrowser   Author: qutebrowser   File: miscwidgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """Get the size of the underlying widget."""
        if self._widget is None:
            return QSize()
        return self._widget.sizeHint() 
Example 25
Project: qutebrowser   Author: qutebrowser   File: progress.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """Set the height to the text height."""
        width = super().sizeHint().width()
        height = self.fontMetrics().height()
        return QSize(width, height) 
Example 26
Project: qutebrowser   Author: qutebrowser   File: command.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self) -> QSize:
        """Dynamically calculate the needed size."""
        height = super().sizeHint().height()
        text = self.text()
        if not text:
            text = 'x'
        width = self.fontMetrics().width(text)
        return QSize(width, height) 
Example 27
Project: qutebrowser   Author: qutebrowser   File: messageview.py    License: GNU General Public License v3.0 5 votes vote down vote up
def sizeHint(self):
        """Get the proposed height for the view."""
        height = sum(label.sizeHint().height() for label in self._messages)
        # The width isn't really relevant as we're expanding anyways.
        return QSize(-1, height) 
Example 28
Project: mindfulness-at-the-computer   Author: mindfulness-at-the-computer   File: rest_action_list_wt.py    License: GNU General Public License v3.0 5 votes vote down vote up
def update_gui(self):
        self.updating_gui_bool = True

        self.list_widget.clear()
        for rest_action in model.RestActionsM.get_all():
            rest_action_title_cll = RestQLabel(rest_action.title, rest_action.id)
            list_item = QtWidgets.QListWidgetItem()
            list_item.setSizeHint(QtCore.QSize(list_item.sizeHint().width(), mc.mc_global.LIST_ITEM_HEIGHT_INT))
            self.list_widget.addItem(list_item)
            self.list_widget.setItemWidget(list_item, rest_action_title_cll)

        # self.update_gui_details()

        self.updating_gui_bool = False 
Example 29
Project: malss   Author: canard0328   File: nonscroll_table.py    License: MIT License 5 votes vote down vote up
def _getQTableWidgetSize(self):
        w = self._getQTableWidgetWidth()
        h = self._getQTableWidgetHeight()
        return QSize(w, h) 
Example 30
Project: Lector   Author: BasioMeusPuga   File: __main__.py    License: 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