Lv.的博客

PyQt5 顶层窗口API

################################
# PyQt5中文网 - PyQt5全套视频教程 #
#    https://www.PyQt5.cn/     #
#         主讲: 村长            #
################################
from PyQt5.Qt import *
import sys

'''
图标、标题、透明度、窗口状态、最大化最小化、窗口标志
'''


class Window(QWidget):
    def mousePressEvent(self, QMouseEvent):
        if self.isMaximized():
            self.showNormal()
        else:
            self.showMaximized()


app = QApplication(sys.argv)

window = Window()
window.setWindowTitle('顶层窗口常用API学习 - PyQt5中文网')
window.resize(600, 450)
window.move(300, 300)

icon = QIcon('123.jpg')
window.setWindowIcon(icon)
print(window.windowIcon())

window.setWindowOpacity(0.6)

# 窗口状态
# WindowNoState
# WindowMinimized
# WindowMaximized
# WindowFullScreen
# WindowActive
window.setWindowState(Qt.WindowMaximized)

# 窗口展示方法
# showFullScreen()
# showMinimized()
# showMaximized()
# showNormal()
# 判定
# isMaximized()
# isMinimized()
# isFullScreen()
# window.showNormal()

# 窗口标志在案例中讲解,内容很多,但不常用,案例中会讲解几个常用的
window.setWindowFlags(Qt.FramelessWindowHint)

window.show()
sys.exit(app.exec_())

 

posted @ 2022-05-31 16:57  Avatarx  阅读(99)  评论(0编辑  收藏  举报