• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python qtutils.check_overflow函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qutebrowser.utils.qtutils.check_overflow函数的典型用法代码示例。如果您正苦于以下问题:Python check_overflow函数的具体用法?Python check_overflow怎么用?Python check_overflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_overflow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_bad_values_fatal

 def test_bad_values_fatal(self):
     """Test values which are outside bounds with fatal=True."""
     for ctype, vals in self.BAD_VALUES.items():
         for (val, _) in vals:
             with self.subTest(ctype=ctype, val=val):
                 with self.assertRaises(OverflowError):
                     qtutils.check_overflow(val, ctype)
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:7,代码来源:test_qtutils.py


示例2: start

 def start(self, msec=None):
     """Extend start to check for overflows."""
     if msec is not None:
         qtutils.check_overflow(msec, 'int')
         super().start(msec)
     else:
         super().start()
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:7,代码来源:usertypes.py


示例3: _update_overlay_geometry

    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 = size_hint.width()
            left = (self.width() - size_hint.width()) / 2 if centered else 0

        height_padding = 20
        status_position = config.get('ui', 'status-position')
        if status_position == 'bottom':
            top = self.height() - self.status.height() - size_hint.height()
            top = qtutils.check_overflow(top, 'int', fatal=False)
            topleft = QPoint(left, max(height_padding, top))
            bottomright = QPoint(left + width, self.status.geometry().top())
        elif status_position == 'top':
            topleft = QPoint(left, self.status.geometry().bottom())
            bottom = self.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)
开发者ID:shaggytwodope,项目名称:qutebrowser,代码行数:33,代码来源:mainwindow.py


示例4: check_overflow

def check_overflow(arg, ctype):
    """Check if the given argument is in bounds for the given type.

    Args:
        arg: The argument to check
        ctype: The C/Qt type to check as a string.
    """
    try:
        qtutils.check_overflow(arg, ctype)
    except OverflowError:
        raise cmdexc.CommandError("Numeric argument is too large for internal {} " "representation.".format(ctype))
开发者ID:rumpelsepp,项目名称:qutebrowser,代码行数:11,代码来源:cmdutils.py


示例5: check_overflow

def check_overflow(arg: int, ctype: str) -> None:
    """Check if the given argument is in bounds for the given type.

    Args:
        arg: The argument to check.
        ctype: The C++/Qt type to check as a string ('int'/'int64').
    """
    try:
        qtutils.check_overflow(arg, ctype)
    except OverflowError:
        raise CommandError("Numeric argument is too large for internal {} "
                           "representation.".format(ctype))
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:12,代码来源:cmdutils.py


示例6: _get_overlay_position

 def _get_overlay_position(self, height):
     """Get the position for a full-width overlay with the given height."""
     status_position = config.get('ui', 'status-position')
     if status_position == 'bottom':
         top = self.height() - self.status.height() - height
         top = qtutils.check_overflow(top, 'int', fatal=False)
         topleft = QPoint(0, top)
         bottomright = self.status.geometry().topRight()
     elif status_position == 'top':
         topleft = self.status.geometry().bottomLeft()
         bottom = self.status.height() + height
         bottom = qtutils.check_overflow(bottom, 'int', fatal=False)
         bottomright = QPoint(self.width(), bottom)
     else:
         raise ValueError("Invalid position {}!".format(status_position))
     return QRect(topleft, bottomright)
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:16,代码来源:mainwindow.py


示例7: resize_completion

 def resize_completion(self):
     """Adjust completion according to config."""
     if not self._completion.isVisible():
         # It doesn't make sense to resize the completion as long as it's
         # not shown anyways.
         return
     # Get the configured height/percentage.
     confheight = str(config.get("completion", "height"))
     if confheight.endswith("%"):
         perc = int(confheight.rstrip("%"))
         height = self.height() * perc / 100
     else:
         height = int(confheight)
     # Shrink to content size if needed and shrinking is enabled
     if config.get("completion", "shrink"):
         contents_height = (
             self._completion.viewportSizeHint().height()
             + self._completion.horizontalScrollBar().sizeHint().height()
         )
         if contents_height <= height:
             height = contents_height
     else:
         contents_height = -1
     # hpoint now would be the bottom-left edge of the widget if it was on
     # the top of the main window.
     topleft_y = self.height() - self.status.height() - height
     topleft_y = qtutils.check_overflow(topleft_y, "int", fatal=False)
     topleft = QPoint(0, topleft_y)
     bottomright = self.status.geometry().topRight()
     rect = QRect(topleft, bottomright)
     log.misc.debug("completion rect: {}".format(rect))
     if rect.isValid():
         self._completion.setGeometry(rect)
开发者ID:forkbong,项目名称:qutebrowser,代码行数:33,代码来源:mainwindow.py


示例8: test_bad_values_nonfatal

 def test_bad_values_nonfatal(self):
     """Test values which are outside bounds with fatal=False."""
     for ctype, vals in self.BAD_VALUES.items():
         for (val, replacement) in vals:
             with self.subTest(ctype=ctype, val=val):
                 newval = qtutils.check_overflow(val, ctype, fatal=False)
                 self.assertEqual(newval, replacement)
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:7,代码来源:test_qtutils.py


示例9: resize_completion

 def resize_completion(self):
     """Adjust completion according to config."""
     # Get the configured height/percentage.
     confheight = str(config.get('completion', 'height'))
     if confheight.endswith('%'):
         perc = int(confheight.rstrip('%'))
         height = self.height() * perc / 100
     else:
         height = int(confheight)
     # Shrink to content size if needed and shrinking is enabled
     if config.get('completion', 'shrink'):
         contents_height = (
             self._completion.viewportSizeHint().height() +
             self._completion.horizontalScrollBar().sizeHint().height())
         if contents_height <= height:
             height = contents_height
     else:
         contents_height = -1
     # hpoint now would be the bottom-left edge of the widget if it was on
     # the top of the main window.
     topleft_y = self.height() - self.status.height() - height
     topleft_y = qtutils.check_overflow(topleft_y, 'int', fatal=False)
     topleft = QPoint(0, topleft_y)
     bottomright = self.status.geometry().topRight()
     rect = QRect(topleft, bottomright)
     if rect.isValid():
         self._completion.setGeometry(rect)
开发者ID:iggy,项目名称:qutebrowser,代码行数:27,代码来源:mainwindow.py


示例10: check_overflow

def check_overflow(arg, ctype):
    """Check if the given argument is in bounds for the given type.

    Args:
        arg: The argument to check
        ctype: The C/Qt type to check as a string.

    Raise:
        CommandError if the argument is out of bounds.
        ValueError if the given ctype is unknown.
    """
    # FIXME we somehow should have nicer exceptions...
    try:
        qtutils.check_overflow(arg, ctype)
    except OverflowError:
        raise cmdexc.CommandError(
            "Numeric argument is too large for internal {} "
            "representation.".format(ctype))
开发者ID:har5ha,项目名称:qutebrowser,代码行数:18,代码来源:cmdutils.py


示例11: set_http_cache_size

    def set_http_cache_size(self):
        """Initialize the HTTP cache size for the given profile."""
        size = config.val.content.cache.size
        if size is None:
            size = 0
        else:
            size = qtutils.check_overflow(size, 'int', fatal=False)

        # 0: automatically managed by QtWebEngine
        self._profile.setHttpCacheMaximumSize(size)
开发者ID:fiete201,项目名称:qutebrowser,代码行数:10,代码来源:webenginesettings.py


示例12: resize_completion

 def resize_completion(self):
     """Adjust completion according to config."""
     if not self._completion.isVisible():
         # It doesn't make sense to resize the completion as long as it's
         # not shown anyways.
         return
     # Get the configured height/percentage.
     confheight = str(config.get('completion', 'height'))
     if confheight.endswith('%'):
         perc = int(confheight.rstrip('%'))
         height = self.height() * perc / 100
     else:
         height = int(confheight)
     # Shrink to content size if needed and shrinking is enabled
     if config.get('completion', 'shrink'):
         contents_height = (
             self._completion.viewportSizeHint().height() +
             self._completion.horizontalScrollBar().sizeHint().height())
         if contents_height <= height:
             height = contents_height
     else:
         contents_height = -1
     status_position = config.get('ui', 'status-position')
     if status_position == 'bottom':
         top = self.height() - self.status.height() - height
         top = qtutils.check_overflow(top, 'int', fatal=False)
         topleft = QPoint(0, top)
         bottomright = self.status.geometry().topRight()
     elif status_position == 'top':
         topleft = self.status.geometry().bottomLeft()
         bottom = self.status.height() + height
         bottom = qtutils.check_overflow(bottom, 'int', fatal=False)
         bottomright = QPoint(self.width(), bottom)
     else:
         raise ValueError("Invalid position {}!".format(status_position))
     rect = QRect(topleft, bottomright)
     log.misc.debug('completion rect: {}'.format(rect))
     if rect.isValid():
         self._completion.setGeometry(rect)
开发者ID:meles5,项目名称:qutebrowser,代码行数:39,代码来源:mainwindow.py


示例13: to_perc

 def to_perc(self, x=None, y=None):
     if x is None and y == 0:
         self.top()
     elif x is None and y == 100:
         self.bottom()
     else:
         for val, orientation in [(x, Qt.Horizontal), (y, Qt.Vertical)]:
             if val is not None:
                 val = qtutils.check_overflow(val, 'int', fatal=False)
                 frame = self._widget.page().mainFrame()
                 m = frame.scrollBarMaximum(orientation)
                 if m == 0:
                     continue
                 frame.setScrollBarValue(orientation, int(m * val / 100))
开发者ID:swalladge,项目名称:qutebrowser,代码行数:14,代码来源:webkittab.py


示例14: _update_overlay_geometry

    def _update_overlay_geometry(self, widget=None):
        """Reposition/resize the given overlay.

        If no widget is given, reposition/resize all overlays.
        """
        if widget is None:
            for w, _signal in self._overlays:
                self._update_overlay_geometry(w)
            return

        if not widget.isVisible():
            return

        size_hint = widget.sizeHint()
        if widget.sizePolicy().horizontalPolicy() == QSizePolicy.Expanding:
            width = self.width()
        else:
            width = size_hint.width()

        status_position = config.get("ui", "status-position")
        if status_position == "bottom":
            top = self.height() - self.status.height() - size_hint.height()
            top = qtutils.check_overflow(top, "int", fatal=False)
            topleft = QPoint(0, top)
            bottomright = QPoint(width, self.status.geometry().top())
        elif status_position == "top":
            topleft = self.status.geometry().bottomLeft()
            bottom = self.status.height() + size_hint.height()
            bottom = qtutils.check_overflow(bottom, "int", fatal=False)
            bottomright = QPoint(width, 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)
开发者ID:lahwaacz,项目名称:qutebrowser,代码行数:37,代码来源:mainwindow.py


示例15: reposition_keyhint

 def reposition_keyhint(self):
     """Adjust keyhint according to config."""
     if not self._keyhint.isVisible():
         return
     # Shrink the window to the shown text and place it at the bottom left
     width = self._keyhint.width()
     height = self._keyhint.height()
     topleft_y = self.height() - self.status.height() - height
     topleft_y = qtutils.check_overflow(topleft_y, "int", fatal=False)
     topleft = QPoint(0, topleft_y)
     bottomright = self.status.geometry().topLeft() + QPoint(width, 0)
     rect = QRect(topleft, bottomright)
     log.misc.debug("keyhint rect: {}".format(rect))
     if rect.isValid():
         self._keyhint.setGeometry(rect)
开发者ID:forkbong,项目名称:qutebrowser,代码行数:15,代码来源:mainwindow.py


示例16: _scroll_percent

    def _scroll_percent(self, perc=None, count=None, orientation=None):
        """Inner logic for scroll_percent_(x|y).

        Args:
            perc: How many percent to scroll, or None
            count: How many percent to scroll, or None
            orientation: Qt.Horizontal or Qt.Vertical
        """
        if perc is None and count is None:
            perc = 100
        elif perc is None:
            perc = count
        perc = qtutils.check_overflow(perc, 'int', fatal=False)
        frame = self._current_widget().page().currentFrame()
        m = frame.scrollBarMaximum(orientation)
        if m == 0:
            return
        frame.setScrollBarValue(orientation, int(m * perc / 100))
开发者ID:andor44,项目名称:qutebrowser,代码行数:18,代码来源:commands.py


示例17: test_bad_values_nonfatal

 def test_bad_values_nonfatal(self, ctype, val, repl):
     """Test values which are outside bounds with fatal=False."""
     newval = qtutils.check_overflow(val, ctype, fatal=False)
     assert newval == repl
开发者ID:t-wissmann,项目名称:qutebrowser,代码行数:4,代码来源:test_qtutils.py


示例18: test_bad_values_fatal

 def test_bad_values_fatal(self, ctype, val):
     """Test values which are outside bounds with fatal=True."""
     with pytest.raises(OverflowError):
         qtutils.check_overflow(val, ctype)
开发者ID:t-wissmann,项目名称:qutebrowser,代码行数:4,代码来源:test_qtutils.py


示例19: test_good_values

 def test_good_values(self, ctype, val):
     """Test values which are inside bounds."""
     qtutils.check_overflow(val, ctype)
开发者ID:t-wissmann,项目名称:qutebrowser,代码行数:3,代码来源:test_qtutils.py


示例20: delta

 def delta(self, x=0, y=0):
     qtutils.check_overflow(x, 'int')
     qtutils.check_overflow(y, 'int')
     self._widget.page().mainFrame().scroll(x, y)
开发者ID:swalladge,项目名称:qutebrowser,代码行数:4,代码来源:webkittab.py



注:本文中的qutebrowser.utils.qtutils.check_overflow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python qtutils.deserialize函数代码示例发布时间:2022-05-26
下一篇:
Python objreg.register函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap