aboutsummaryrefslogtreecommitdiffstats
path: root/examples/widgets/richtext/orderform/orderform.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/richtext/orderform/orderform.py')
-rw-r--r--examples/widgets/richtext/orderform/orderform.py75
1 files changed, 19 insertions, 56 deletions
diff --git a/examples/widgets/richtext/orderform/orderform.py b/examples/widgets/richtext/orderform/orderform.py
index ce0569c47..9725624c3 100644
--- a/examples/widgets/richtext/orderform/orderform.py
+++ b/examples/widgets/richtext/orderform/orderform.py
@@ -1,57 +1,19 @@
-
-#############################################################################
-##
-## Copyright (C) 2013 Riverbank Computing Limited.
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: http://www.qt.io/licensing/
-##
-## This file is part of the Qt for Python examples of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:BSD$
-## You may use this file under the terms of the BSD license as follows:
-##
-## "Redistribution and use in source and binary forms, with or without
-## modification, are permitted provided that the following conditions are
-## met:
-## * Redistributions of source code must retain the above copyright
-## notice, this list of conditions and the following disclaimer.
-## * Redistributions in binary form must reproduce the above copyright
-## notice, this list of conditions and the following disclaimer in
-## the documentation and/or other materials provided with the
-## distribution.
-## * Neither the name of The Qt Company Ltd nor the names of its
-## contributors may be used to endorse or promote products derived
-## from this software without specific prior written permission.
-##
-##
-## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2013 Riverbank Computing Limited.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
"""PySide6 port of the widgets/richtext/orderform example from Qt v5.x"""
import sys
-from PySide6.QtCore import QDate, Qt, Signal, Slot
+from PySide6.QtCore import QDate, Qt, Slot
from PySide6.QtGui import (QFont, QTextCharFormat, QTextCursor,
QTextFrameFormat, QTextLength, QTextTableFormat)
from PySide6.QtWidgets import (QApplication, QCheckBox, QDialog,
QDialogButtonBox, QGridLayout, QLabel,
QLineEdit, QMainWindow, QMenu, QMessageBox,
QTableWidget, QTableWidgetItem, QTabWidget,
- QTextEdit, QWidget)
+ QTextEdit)
from PySide6.QtPrintSupport import QAbstractPrintDialog, QPrintDialog, QPrinter
@@ -127,8 +89,7 @@ class MainWindow(QMainWindow):
body_frame_format.setWidth(QTextLength(QTextLength.PercentageLength, 100))
cursor.insertFrame(body_frame_format)
- cursor.insertText("I would like to place an order for the following "
- "items:", text_format)
+ cursor.insertText("I would like to place an order for the following items:", text_format)
cursor.insertBlock()
cursor.insertBlock()
@@ -159,17 +120,17 @@ class MainWindow(QMainWindow):
cursor.insertBlock()
cursor.insertText("Please update my records to take account of the "
- "following privacy information:")
+ "following privacy information:")
cursor.insertBlock()
offers_table = cursor.insertTable(2, 2)
cursor = offers_table.cellAt(0, 1).firstCursorPosition()
cursor.insertText("I want to receive more information about your "
- "company's products and special offers.", text_format)
+ "company's products and special offers.", text_format)
cursor = offers_table.cellAt(1, 1).firstCursorPosition()
cursor.insertText("I do not want to receive any promotional "
- "information from your company.", text_format)
+ "information from your company.", text_format)
if sendOffers:
cursor = offers_table.cellAt(0, 0).firstCursorPosition()
@@ -191,16 +152,18 @@ class MainWindow(QMainWindow):
def create_sample(self):
dialog = DetailsDialog('Dialog with default values', self)
self.create_letter('Mr Smith',
- '12 High Street\nSmall Town\nThis country',
- dialog.order_items(), True)
+ '12 High Street\nSmall Town\nThis country',
+ dialog.order_items(), True)
+ @Slot()
def open_dialog(self):
dialog = DetailsDialog("Enter Customer Details", self)
if dialog.exec() == QDialog.Accepted:
self.create_letter(dialog.sender_name(), dialog.sender_address(),
- dialog.order_items(), dialog.send_offers())
+ dialog.order_items(), dialog.send_offers())
+ @Slot()
def print_file(self):
editor = self.letters.currentWidget()
printer = QPrinter()
@@ -229,8 +192,7 @@ class DetailsDialog(QDialog):
self._name_edit = QLineEdit()
self._address_edit = QTextEdit()
- self._offers_check_box = QCheckBox("Send information about "
- "products and special offers:")
+ self._offers_check_box = QCheckBox("Send information about products and special offers:")
self.setup_items_table()
@@ -279,15 +241,16 @@ class DetailsDialog(QDialog):
def send_offers(self):
return self._offers_check_box.isChecked()
+ @Slot()
def verify(self):
if self._name_edit.text() and self._address_edit.toPlainText():
self.accept()
return
answer = QMessageBox.warning(self, "Incomplete Form",
- "The form does not contain all the necessary information.\n"
- "Do you want to discard it?",
- QMessageBox.Yes, QMessageBox.No)
+ "The form does not contain all the necessary information.\n"
+ "Do you want to discard it?",
+ QMessageBox.Yes, QMessageBox.No)
if answer == QMessageBox.Yes:
self.reject()