當前位置: 首頁>>代碼示例>>Python>>正文


Python QApplication.desktop方法代碼示例

本文整理匯總了Python中enaml.qt.QtGui.QApplication.desktop方法的典型用法代碼示例。如果您正苦於以下問題:Python QApplication.desktop方法的具體用法?Python QApplication.desktop怎麽用?Python QApplication.desktop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在enaml.qt.QtGui.QApplication的用法示例。


在下文中一共展示了QApplication.desktop方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ensure_on_screen

# 需要導入模塊: from enaml.qt.QtGui import QApplication [as 別名]
# 或者: from enaml.qt.QtGui.QApplication import desktop [as 別名]
def ensure_on_screen(rect):
    """ Ensure that the given rect is contained on screen.

    If the origin of the rect is not contained within the closest
    desktop screen, the rect will be moved so that it is fully on the
    closest screen. If the rect is larger than the closest screen, the
    origin will never be less than the screen origin.

    Parameters
    ----------
    rect : QRect
        The geometry rect of interest.

    Returns
    -------
    result : QRect
        The potentially adjusted QRect which fits on the screen.

    """
    d = QApplication.desktop()
    pos = rect.topLeft()
    drect = d.screenGeometry(pos)
    if not drect.contains(pos):
        x = pos.x()
        if x < drect.x() or x > drect.right():
            dw = drect.width() - rect.width()
            x = max(drect.x(), drect.x() + dw)
        y = pos.y()
        if x < drect.top() or y > drect.bottom():
            dh = drect.height() - rect.height()
            y = max(drect.y(), drect.y() + dh)
        rect = QRect(x, y, rect.width(), rect.height())
    return rect
開發者ID:ContinuumIO,項目名稱:ashiba,代碼行數:35,代碼來源:layout_builder.py

示例2: snapshot

# 需要導入模塊: from enaml.qt.QtGui import QApplication [as 別名]
# 或者: from enaml.qt.QtGui.QApplication import desktop [as 別名]
 def snapshot(self):
     """ Take a snapshot of the window and close it.
     
     """
     widget = self.view.proxy.widget
     framesize =  widget.window().frameSize()
     QPixmap.grabWindow(QApplication.desktop().winId(), widget.x(),
                        widget.y(), framesize.width(),
                        framesize.height() ).save(self.path)
     widget.close()
開發者ID:MatthieuDartiailh,項目名稱:enaml,代碼行數:12,代碼來源:example_doc_generator.py


注:本文中的enaml.qt.QtGui.QApplication.desktop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。