1# This Python file uses the following encoding: utf-8
2# It has been edited by fix-complaints.py .
3
4#############################################################################
5##
6## Copyright (C) 2020 The Qt Company Ltd.
7## Contact: https://www.qt.io/licensing/
8##
9## This file is part of the Qt for Python examples of the Qt Toolkit.
10##
11## $QT_BEGIN_LICENSE:BSD$
12## You may use this file under the terms of the BSD license as follows:
13##
14## "Redistribution and use in source and binary forms, with or without
15## modification, are permitted provided that the following conditions are
16## met:
17##   * Redistributions of source code must retain the above copyright
18##     notice, this list of conditions and the following disclaimer.
19##   * Redistributions in binary form must reproduce the above copyright
20##     notice, this list of conditions and the following disclaimer in
21##     the documentation and/or other materials provided with the
22##     distribution.
23##   * Neither the name of The Qt Company Ltd nor the names of its
24##     contributors may be used to endorse or promote products derived
25##     from this software without specific prior written permission.
26##
27##
28## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39##
40## $QT_END_LICENSE$
41##
42#############################################################################
43
44"""
45hello.py
46--------
47
48This simple script shows a label with changing "Hello World" messages.
49It can be used directly as a script, but we use it also to automatically
50test PyInstaller. See testing/wheel_tester.py .
51
52When used with PyInstaller, it automatically stops its execution after
532 seconds.
54"""
55from __future__ import print_function
56
57import sys
58import random
59import platform
60import time
61
62from PySide2.QtWidgets import (QApplication, QLabel, QPushButton,
63                               QVBoxLayout, QWidget)
64from PySide2.QtCore import Slot, Qt, QTimer
65
66class MyWidget(QWidget):
67    def __init__(self):
68        QWidget.__init__(self)
69
70        self.hello = ["Hallo Welt", "你好,世界", "Hei maailma",
71            "Hola Mundo", "Привет мир"]
72
73        self.button = QPushButton("Click me!")
74        self.text = QLabel("Hello World embedded={}".format(sys.pyside_uses_embedding))
75        self.text.setAlignment(Qt.AlignCenter)
76
77        self.layout = QVBoxLayout()
78        self.layout.addWidget(self.text)
79        self.layout.addWidget(self.button)
80        self.setLayout(self.layout)
81
82        # Connecting the signal
83        self.button.clicked.connect(self.magic)
84
85    @Slot()
86    def magic(self):
87        self.text.setText(random.choice(self.hello))
88
89if __name__ == "__main__":
90    print("Start of hello.py      ", time.ctime())
91    print("  sys.version         = {}".format(sys.version.splitlines()[0]))
92    print("  platform.platform() = {}".format(platform.platform()))
93
94    app = QApplication()
95
96    widget = MyWidget()
97    widget.resize(800, 600)
98    widget.show()
99    if sys.pyside_uses_embedding:
100        milliseconds = 2 * 1000 # run 2 second
101        QTimer.singleShot(milliseconds, app.quit)
102    retcode = app.exec_()
103    print("End of hello.py        ", time.ctime())
104    sys.exit(retcode)
105