PyQt5,Window

图片描述

构造

经过下面的方法来建立一个Window对象python

window = QWindow()

方法

窗口的标题,一般由窗口管理器显示的参数,可使用下面的方法:app

window.setTitle(title)

Window 对象也能够经过使用如下代码最小化或最大化:ui

window.showMinimized()
window.showMaxinmzed()

另外,某些应用须要用到全屏模式:spa

window.showFullScreen()

若是窗口设置为最小化、则全屏幕最大化,它能够恢复到正常状态。
最小宽度和高度能够经过如下方式执行:code

window.setMinimumWidth(width)
window.setMaximumWidth(width)
window.setMinimumHeight(height)
window.setMaximumHeight(height)

特定的宽度和高度也能够经过如下方式声明:对象

window.setWidth(width)
window.setHeight(height)

Example

# !/usr/bin/python3

from PyQt5.QtCore import * 
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys

class Window(QWidget):
    def __init__(self):
        QWindow.__init__(self)
        self.setWindowTitle("Window")
        self.resize(400, 300)

app = QApplication(sys.argv)

screen = Window()
screen.show()

sys.exit(app.exec_())
相关文章
相关标签/搜索