datetime:2019/5/23 14:28
author:nzb

打开更多的窗口

from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication,QLabel, QPushButton, QComboBox, QVBoxLayout,  QDialog, QMainWindow, QCalendarWidget, QVBoxLayout, QLabel
import sys
from PyQt5.QtWidgets import QCompleter, QLineEdit


class Window(QDialog):
    """模糊查询"""
    def __init__(self):
        super().__init__()

        self.title = "PyQt5 QDialog"
        self.top = 200
        self.left = 500
        self.width = 400
        self.height = 300

        self.InitWindow()

    def InitWindow(self):
        self.setWindowIcon(QtGui.QIcon("../img/home.ico"))
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.InitUI()
        self.show()

    def InitUI(self):

        vbox = QVBoxLayout()

        self.btn = QPushButton("Open second dialog")
        self.btn.setFont(QtGui.QFont("Sanserif", 15))
        self.btn.clicked.connect(self.openSecondDialog)

        vbox.addWidget(self.btn)

        self.setLayout(vbox)

    def openSecondDialog(self):
        """打开另一个窗口"""
        # 1.只能打开第二个,并且不能移动第一个
        # mydialog = QDialog()
        # mydialog.setModal(True)
        # mydialog.exec()
        # 可以无限打开,并且可以在第一个上操作
        mydialog = QDialog(self)
        mydialog.show()


App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())

results matching ""

    No results matching ""