Python PyQt5.QtWidgets.QSizePolicy.Expanding() Examples

The following are 19 code examples of PyQt5.QtWidgets.QSizePolicy.Expanding(). 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 PyQt5.QtWidgets.QSizePolicy , or try the search function .
Example #1
Source File: addition.py    From MusicBox with MIT License 7 votes vote down vote up
def __init__(self, parent=None):
        super(SearchLineEdit, self).__init__()
        self.setObjectName("SearchLine")
        self.parent = parent
        self.setMinimumSize(218, 20)
        with open('QSS/searchLine.qss', 'r') as f:
            self.setStyleSheet(f.read())

        self.button = QPushButton(self)
        self.button.setMaximumSize(13, 13)
        self.button.setCursor(QCursor(Qt.PointingHandCursor))

        self.setTextMargins(3, 0, 19, 0)

        self.spaceItem = QSpacerItem(150, 10, QSizePolicy.Expanding)

        self.mainLayout = QHBoxLayout()
        self.mainLayout.addSpacerItem(self.spaceItem)
        # self.mainLayout.addStretch(1)
        self.mainLayout.addWidget(self.button)
        self.mainLayout.addSpacing(10)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.mainLayout) 
Example #2
Source File: messageview.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent=None):
        super().__init__(parent)
        self._messages = []  # type: typing.MutableSequence[Message]
        self._vbox = QVBoxLayout(self)
        self._vbox.setContentsMargins(0, 0, 0, 0)
        self._vbox.setSpacing(0)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        self._clear_timer = QTimer()
        self._clear_timer.timeout.connect(self.clear_messages)
        config.instance.changed.connect(self._set_clear_timer_interval)

        self._last_text = None 
Example #3
Source File: collectionEditor.py    From openMotor with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, buttons=False):
        super(CollectionEditor, self).__init__(QWidget(parent))

        self.preferences = None

        self.propertyEditors = {}
        self.setLayout(QVBoxLayout())
        self.layout().setSpacing(0)

        self.form = QFormLayout()
        self.layout().addLayout(self.form)

        self.stats = QVBoxLayout()
        self.layout().addLayout(self.stats)


        self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.layout().addItem(self.verticalSpacer)

        self.buttons = buttons
        if self.buttons:
            self.addButtons() 
Example #4
Source File: videosliderwidget.py    From vidcutter with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, slider: VideoSlider):
        super(VideoSliderWidget, self).__init__(parent)
        self.parent = parent
        self.slider = slider
        self.loaderEffect = OpacityEffect()
        self.loaderEffect.setEnabled(False)
        self.setGraphicsEffect(self.loaderEffect)
        self.setContentsMargins(0, 0, 0, 0)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.layout().setStackingMode(QStackedLayout.StackAll)
        self.genlabel = QLabel(self.parent)
        self.genlabel.setContentsMargins(0, 0, 0, 14)
        self.genlabel.setPixmap(QPixmap(':/images/generating-thumbs.png'))
        self.genlabel.setAlignment(Qt.AlignCenter)
        self.genlabel.hide()
        sliderLayout = QGridLayout()
        sliderLayout.setContentsMargins(0, 0, 0, 0)
        sliderLayout.setSpacing(0)
        sliderLayout.addWidget(self.slider, 0, 0)
        sliderLayout.addWidget(self.genlabel, 0, 0)
        sliderWidget = QWidget(self.parent)
        sliderWidget.setLayout(sliderLayout)
        self.addWidget(sliderWidget) 
Example #5
Source File: framerate_viewer.py    From stytra with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, acc, inertia=0.985):
        super().__init__()
        self.acc = acc
        self.g_fps = self.acc.goal_framerate
        self.fps = None
        self.fps_inertia_max = None
        self.fps_inertia_min = None
        self.inertia = inertia
        self.set_fps = False
        self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.indicator_color = (40, 230, 150)
        self.indicator_shadow_color = (17, 147, 91)
        self.error_indicator_color = (230, 40, 0)
        self.error_indicator_shadow_color = (170, 30, 0) 
Example #6
Source File: control_buttons.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
def newButton(self, icon):
        button = QIconPushButton(self)
        button.setFocusPolicy(Qt.NoFocus)
        button.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Expanding)
        button.setIcon(icon)
        button.setIconSize(QSize(32, 32))
        return button 
Example #7
Source File: page_widget.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
def init_layout(self):
        for row in range(0, self.__rows):
            self.layout().setRowStretch(row, 1)
            # item = QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
            # self.layout().addItem(item, row, 0)

        for column in range(0, self.__columns):
            self.layout().setColumnStretch(column, 1)
            # item = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
            # self.layout().addItem(item, 0, column) 
Example #8
Source File: __main__.py    From vidcutter with GNU General Public License v3.0 5 votes vote down vote up
def init_scale(self) -> None:
        screen_size = qApp.desktop().availableGeometry(-1)
        self.scale = 'LOW' if screen_size.width() <= 1024 else 'NORMAL'
        self.setMinimumSize(self.get_size(self.scale))
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) 
Example #9
Source File: tabbedbrowser.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *, win_id, private, parent=None):
        if private:
            assert not qtutils.is_single_process()
        super().__init__(parent)
        self.widget = tabwidget.TabWidget(win_id, parent=self)
        self._win_id = win_id
        self._tab_insert_idx_left = 0
        self._tab_insert_idx_right = -1
        self.shutting_down = False
        self.widget.tabCloseRequested.connect(self.on_tab_close_requested)
        self.widget.new_tab_requested.connect(
            self.tabopen)  # type: ignore[arg-type]
        self.widget.currentChanged.connect(self._on_current_changed)
        self.cur_fullscreen_requested.connect(self.widget.tabBar().maybe_hide)
        self.widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-65223
        if qtutils.version_check('5.10', compiled=False):
            self.cur_load_finished.connect(self._leave_modes_on_load)
        else:
            self.cur_load_started.connect(self._leave_modes_on_load)

        # This init is never used, it is immediately thrown away in the next
        # line.
        self._undo_stack = (
            collections.deque()
        )  # type: typing.MutableSequence[typing.MutableSequence[UndoEntry]]
        self._update_stack_size()
        self._filter = signalfilter.SignalFilter(win_id, self)
        self._now_focused = None
        self.search_text = None
        self.search_options = {}  # type: typing.Mapping[str, typing.Any]
        self._local_marks = {
        }  # type: typing.MutableMapping[QUrl, typing.MutableMapping[str, int]]
        self._global_marks = {
        }  # type: typing.MutableMapping[str, typing.Tuple[int, QUrl]]
        self.default_window_icon = self.widget.window().windowIcon()
        self.is_private = private
        self.tab_deque = TabDeque()
        config.instance.changed.connect(self._on_config_changed)
        quitter.instance.shutting_down.connect(self.shutdown) 
Example #10
Source File: magicbox.py    From FeelUOwn with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, app, parent=None):
        super().__init__(parent)

        self._app = app
        self.setPlaceholderText('搜索歌曲、歌手、专辑、用户')
        self.setToolTip('直接输入文字可以进行过滤,按 Enter 可以搜索\n'
                        '输入 >>> 前缀之后,可以执行 Python 代码\n'
                        '输入 # 前缀之后,可以过滤表格内容\n'
                        '输入 > 前缀可以执行 fuo 命令(未实现,欢迎 PR)')
        self.setFont(QFontDatabase.systemFont(QFontDatabase.FixedFont))
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.setFixedHeight(32)
        self.setFrame(False)
        self.setAttribute(Qt.WA_MacShowFocusRect, 0)
        self.setTextMargins(5, 0, 0, 0)

        self._timer = QTimer(self)
        self._cmd_text = None
        self._mode = 'cmd'  # 详见 _set_mode 函数
        self._timer.timeout.connect(self.__on_timeout)

        self.textChanged.connect(self.__on_text_edited)
        # self.textEdited.connect(self.__on_text_edited)
        self.returnPressed.connect(self.__on_return_pressed)

        self._app.hotkey_mgr.register(
            [QKeySequence('Ctrl+F'), QKeySequence(':'), QKeySequence('Alt+x')],
            self.setFocus
        ) 
Example #11
Source File: CameraWidget.py    From vidpipe with GNU General Public License v3.0 5 votes vote down vote up
def setCamera( self, cameraDevice ):
        self._cameraDevice = cameraDevice
        self._cameraDevice.newFrame.connect( self._onNewFrame )

        w, h = self._cameraDevice.frameSize
        self.setMinimumSize(w, h)
        self.setMaximumSize( 960, 1280)
        #self.setSizePolicy( QSizePolicy.Fixed, QSizePolicy.Fixed )
        self.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding ) 
Example #12
Source File: PlotCanvas.py    From CNNArt with Apache License 2.0 5 votes vote down vote up
def __init__(self, parent=None, width=5, height=4, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)
        self.axes = fig.add_subplot(111)

        FigureCanvas.__init__(self, fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self,
                                   QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
        self.plot() 
Example #13
Source File: mplwidget.py    From pySPM with Apache License 2.0 5 votes vote down vote up
def __init__(self):
		self.fig = Figure()
		FigureCanvas.__init__(self, self.fig)
		FigureCanvas.setSizePolicy(self,
			QSizePolicy.Expanding,
			QSizePolicy.Expanding)
		FigureCanvas.updateGeometry(self) 
Example #14
Source File: mplwidget.py    From pySPM with Apache License 2.0 5 votes vote down vote up
def __init__(self):
		self.fig = Figure()
		FigureCanvas.__init__(self, self.fig)
		FigureCanvas.setSizePolicy(self,
			QSizePolicy.Expanding,
			QSizePolicy.Expanding)
		FigureCanvas.updateGeometry(self) 
Example #15
Source File: completionwidget.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *,
                 cmd: 'command.Command',
                 win_id: int,
                 parent: QWidget = None) -> None:
        super().__init__(parent)
        self.pattern = None  # type: typing.Optional[str]
        self._win_id = win_id
        self._cmd = cmd
        self._active = False

        config.instance.changed.connect(self._on_config_changed)

        self._delegate = completiondelegate.CompletionItemDelegate(self)
        self.setItemDelegate(self._delegate)
        self.setStyle(QStyleFactory.create('Fusion'))
        stylesheet.set_register(self)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.setHeaderHidden(True)
        self.setAlternatingRowColors(True)
        self.setIndentation(0)
        self.setItemsExpandable(False)
        self.setExpandsOnDoubleClick(False)
        self.setAnimated(False)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        # WORKAROUND
        # This is a workaround for weird race conditions with invalid
        # item indexes leading to segfaults in Qt.
        #
        # Some background: http://bugs.quassel-irc.org/issues/663
        # The proposed fix there was later reverted because it didn't help.
        self.setUniformRowHeights(True)
        self.hide()
        # FIXME set elidemode
        # https://github.com/qutebrowser/qutebrowser/issues/118 
Example #16
Source File: collectionEditor.py    From openMotor with GNU General Public License v3.0 5 votes vote down vote up
def loadProperties(self, obj):
        self.cleanup()
        for prop in obj.props:
            self.propertyEditors[prop] = PropertyEditor(self, obj.props[prop], self.preferences)
            self.propertyEditors[prop].valueChanged.connect(self.propertyUpdate)
            label = QLabel(obj.props[prop].dispName + ':')
            label.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
            self.form.addRow(label, self.propertyEditors[prop])
        if self.buttons:
            self.applyButton.show()
            self.cancelButton.show()
        self.propertyUpdate() 
Example #17
Source File: mainwindow.py    From qutebrowser with GNU General Public License v3.0 4 votes vote down vote up
def _update_overlay_geometry(self, widget, centered, padding):
        """Reposition/resize the given overlay."""
        if not widget.isVisible():
            return

        size_hint = widget.sizeHint()
        if widget.sizePolicy().horizontalPolicy() == QSizePolicy.Expanding:
            width = self.width() - 2 * padding
            left = padding
        else:
            width = min(size_hint.width(), self.width() - 2 * padding)
            left = (self.width() - width) // 2 if centered else 0

        height_padding = 20
        status_position = config.val.statusbar.position
        if status_position == 'bottom':
            if self.status.isVisible():
                status_height = self.status.height()
                bottom = self.status.geometry().top()
            else:
                status_height = 0
                bottom = self.height()
            top = self.height() - status_height - size_hint.height()
            top = qtutils.check_overflow(top, 'int', fatal=False)
            topleft = QPoint(left, max(height_padding, top))
            bottomright = QPoint(left + width, bottom)
        elif status_position == 'top':
            if self.status.isVisible():
                status_height = self.status.height()
                top = self.status.geometry().bottom()
            else:
                status_height = 0
                top = 0
            topleft = QPoint(left, top)
            bottom = status_height + size_hint.height()
            bottom = qtutils.check_overflow(bottom, 'int', fatal=False)
            bottomright = QPoint(left + width,
                                 min(self.height() - height_padding, bottom))
        else:
            raise ValueError("Invalid position {}!".format(status_position))

        rect = QRect(topleft, bottomright)
        log.misc.debug('new geometry for {!r}: {}'.format(widget, rect))
        if rect.isValid():
            widget.setGeometry(rect) 
Example #18
Source File: matplotlibwidget.py    From CNNArt with Apache License 2.0 4 votes vote down vote up
def __init__(self, parent=None, width=15, height=15):

        plt.rcParams['font.family'] = ['SimHei']
        plt.rcParams['axes.unicode_minus'] = False

        self.fig = plt.figure(figsize=(width, height),dpi=100)
        #self.openfile_name=''
        self.model = {}

        self.w_count=0
        self.f_count=0
        self.s_count=0
        self.layerWeights = {}  # {layer name: weights value}
        self.edgesInLayerName = [] #(input layer name, output layer name)
        self.allLayerNames = []
        self.axesDict = {}

        self.activations = {}
        self.weights ={}
        self.totalWeights=0
        self.totalWeightsSlices =0
        self.chosenWeightNumber =0
        self.chosenWeightSliceNumber =0
        self.indW =0

        self.subset_selection = {}
        self.subset_selection2 = {}

        self.chosenLayerName=[]

        self.ind =0
        self.indFS =0
        self.nrows = 0
        self.ncols = 0
        self.totalPatches = 0
        self.totalPatchesSlices = 0

        # subset selection parameters
        self.totalSS =0
        self.ssResult={}
        self.chosenSSNumber =0
        # self.alpha=0.19
        # self.Gamma=0.0000001

        self.oncrollStatus=''


        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self,QSizePolicy.Expanding,QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self) 
Example #19
Source File: titlebar.py    From equant with GNU General Public License v2.0 4 votes vote down vote up
def _initViews(self):
        self.setFixedHeight(TITLE_BAR_HEIGHT)

        palette = self.palette()
        palette.setColor(palette.Window, QColor(240, 240, 240))
        self.setPalette(palette)
        # 布局
        layout = QHBoxLayout(self, spacing=0)
        layout.setContentsMargins(0, 0, 0, 0)
        # 窗口图标
        self.iconLabel = QLabel(self, objectName='iconLabel')
        # 窗口标题
        self.titleLabel = QLabel(self, objectName='titleLabel')
        self.titleLabel.setMargin(5)

        # 利用webdings字体来显示图标
        font = self.font() or QFont()
        font.setFamily('Webdings')
        # 最小化按钮
        self.buttonMinimum = QPushButton('0', self, font=font, objectName='buttonMinimum')
        # 最大化/还原按钮
        self.buttonMaximum = QPushButton('1', self, font=font, objectName='buttonMaximum')
        # 关闭按钮
        self.buttonClose = QPushButton('r', self, font=font, objectName='buttonClose')

        self.theseSelect = QPushButton()
        self.theseSelect.setObjectName("theseSelect")
        self.theseSelect.setIcon(QIcon("icon/whitethese.png"))
        self.theseSelect.clicked.connect(self._theseCallback)

        self.buttonMinimum.setFixedSize(TITLE_BUTTON_SIZE, TITLE_BUTTON_SIZE)
        self.buttonMaximum.setFixedSize(TITLE_BUTTON_SIZE, TITLE_BUTTON_SIZE)
        self.buttonClose.setFixedSize(TITLE_BUTTON_SIZE, TITLE_BUTTON_SIZE)

        self.iconLabel.setFixedSize(TITLE_LABEL_SIZE, TITLE_LABEL_SIZE)
        self.titleLabel.setFixedHeight(TITLE_LABEL_SIZE)
        self.iconLabel.setAlignment(Qt.AlignCenter)
        self.titleLabel.setAlignment(Qt.AlignCenter)

        self.buttonMinimum.clicked.connect(self.win.showMinimized)
        self.buttonMaximum.clicked.connect(self.showMaximized)
        self.buttonClose.clicked.connect(self.closeWindow)

        layout.addWidget(self.iconLabel)
        layout.addWidget(self.titleLabel)
        # 中间伸缩条
        layout.addSpacerItem(QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))

        layout.addWidget(self.theseSelect)
        layout.addWidget(self.buttonMinimum)
        layout.addWidget(self.buttonMaximum)
        layout.addWidget(self.buttonClose)
        layout.setSpacing(2)
        # self.setHeight()