本章学习Qt的基本功能

例1,简单的窗口

这个简单的小例子展示的是一个小窗口。但是我们可以在这个小窗口上面做很多事情,改变大小,最大化,最小化等,这需要很多代码才能实现。这在很多应用中很常见,没必要每次都要重写这部分代码,Qt已经提供了这些功能。PyQt5是一个高级的工具集合,相比使用低级的工具,能省略上百行代码。

#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
ZetCode PyQt5 tutorial 

In this example, we create a simple
window in PyQt5.

author: Jan Bodnar
website: zetcode.com 
Last edited: August 2017
"""

import sys
from PyQt5.QtWidgets import QApplication, QWidget


if __name__ == '__main__':

    app = QApplication(sys.argv)

    w = QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()

    sys.exit(app.exec_())
View Code

相关文章:

  • 2022-01-06
  • 2021-07-28
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2021-12-19
  • 2021-04-14
  • 2021-05-05
猜你喜欢
  • 2021-08-28
  • 2022-01-23
  • 2022-01-10
  • 2021-06-27
  • 2022-01-26
  • 2021-11-28
  • 2022-12-23
相关资源
相似解决方案