1#!/usr/bin/env python 2 3 4############################################################################# 5## 6## Copyright (C) 2013 Riverbank Computing Limited. 7## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 8## All rights reserved. 9## 10## This file is part of the examples of PyQt. 11## 12## $QT_BEGIN_LICENSE:BSD$ 13## You may use this file under the terms of the BSD license as follows: 14## 15## "Redistribution and use in source and binary forms, with or without 16## modification, are permitted provided that the following conditions are 17## met: 18## * Redistributions of source code must retain the above copyright 19## notice, this list of conditions and the following disclaimer. 20## * Redistributions in binary form must reproduce the above copyright 21## notice, this list of conditions and the following disclaimer in 22## the documentation and/or other materials provided with the 23## distribution. 24## * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 25## the names of its contributors may be used to endorse or promote 26## products derived from this software without specific prior written 27## permission. 28## 29## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 32## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 34## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 35## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 40## $QT_END_LICENSE$ 41## 42############################################################################# 43 44 45from PyQt5.QtWidgets import (QApplication, QGridLayout, QLabel, QLineEdit, 46 QVBoxLayout, QWizard, QWizardPage) 47 48 49def createIntroPage(): 50 page = QWizardPage() 51 page.setTitle("Introduction") 52 53 label = QLabel( 54 "This wizard will help you register your copy of Super Product " 55 "Two.") 56 label.setWordWrap(True) 57 58 layout = QVBoxLayout() 59 layout.addWidget(label) 60 page.setLayout(layout) 61 62 return page 63 64 65def createRegistrationPage(): 66 page = QWizardPage() 67 page.setTitle("Registration") 68 page.setSubTitle("Please fill both fields.") 69 70 nameLabel = QLabel("Name:") 71 nameLineEdit = QLineEdit() 72 73 emailLabel = QLabel("Email address:") 74 emailLineEdit = QLineEdit() 75 76 layout = QGridLayout() 77 layout.addWidget(nameLabel, 0, 0) 78 layout.addWidget(nameLineEdit, 0, 1) 79 layout.addWidget(emailLabel, 1, 0) 80 layout.addWidget(emailLineEdit, 1, 1) 81 page.setLayout(layout) 82 83 return page 84 85 86def createConclusionPage(): 87 page = QWizardPage() 88 page.setTitle("Conclusion") 89 90 label = QLabel("You are now successfully registered. Have a nice day!") 91 label.setWordWrap(True) 92 93 layout = QVBoxLayout() 94 layout.addWidget(label) 95 page.setLayout(layout) 96 97 return page 98 99 100if __name__ == '__main__': 101 102 import sys 103 104 app = QApplication(sys.argv) 105 106 wizard = QWizard() 107 wizard.addPage(createIntroPage()) 108 wizard.addPage(createRegistrationPage()) 109 wizard.addPage(createConclusionPage()) 110 111 wizard.setWindowTitle("Trivial Wizard") 112 wizard.show() 113 114 sys.exit(app.exec_()) 115