|
1 #!/usr/bin/env python |
|
2 ############################################################################# |
|
3 ## |
|
4 ## Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 ## All rights reserved. |
|
6 ## Contact: Nokia Corporation (qt-info@nokia.com) |
|
7 ## |
|
8 ## This file is part of the test suite of the Qt Toolkit. |
|
9 ## |
|
10 ## $QT_BEGIN_LICENSE:LGPL$ |
|
11 ## No Commercial Usage |
|
12 ## This file contains pre-release code and may not be distributed. |
|
13 ## You may use this file in accordance with the terms and conditions |
|
14 ## contained in the Technology Preview License Agreement accompanying |
|
15 ## this package. |
|
16 ## |
|
17 ## GNU Lesser General Public License Usage |
|
18 ## Alternatively, this file may be used under the terms of the GNU Lesser |
|
19 ## General Public License version 2.1 as published by the Free Software |
|
20 ## Foundation and appearing in the file LICENSE.LGPL included in the |
|
21 ## packaging of this file. Please review the following information to |
|
22 ## ensure the GNU Lesser General Public License version 2.1 requirements |
|
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
24 ## |
|
25 ## In addition, as a special exception, Nokia gives you certain additional |
|
26 ## rights. These rights are described in the Nokia Qt LGPL Exception |
|
27 ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
28 ## |
|
29 ## If you have questions regarding the use of this file, please contact |
|
30 ## Nokia at qt-info@nokia.com. |
|
31 ## |
|
32 ## |
|
33 ## |
|
34 ## |
|
35 ## |
|
36 ## |
|
37 ## |
|
38 ## |
|
39 ## $QT_END_LICENSE$ |
|
40 ## |
|
41 ############################################################################# |
|
42 |
|
43 import sys |
|
44 from PyQt4.QtCore import SIGNAL |
|
45 from PyQt4.QtGui import QApplication, QColor, QIcon, QLabel, QMdiArea, QPixmap, \ |
|
46 QPushButton, QTableWidget, QTableWidgetItem, QTextEdit |
|
47 |
|
48 |
|
49 class Changer: |
|
50 |
|
51 def __init__(self, mdiArea): |
|
52 |
|
53 self.mdiArea = mdiArea |
|
54 self.state = 0 |
|
55 |
|
56 def change(self): |
|
57 |
|
58 if self.state == 0: |
|
59 self.mdiArea.cascadeSubWindows() |
|
60 self.mdiArea.setWindowTitle("Cascade") |
|
61 elif self.state == 1: |
|
62 self.mdiArea.tileSubWindows() |
|
63 self.mdiArea.setWindowTitle("Tile") |
|
64 self.state = (self.state + 1) % 2 |
|
65 |
|
66 |
|
67 if __name__ == "__main__": |
|
68 |
|
69 app = QApplication(sys.argv) |
|
70 pixmap = QPixmap(16, 16) |
|
71 pixmap.fill(QColor(0, 0, 0, 0)) |
|
72 icon = QIcon(pixmap) |
|
73 app.setWindowIcon(icon) |
|
74 |
|
75 mdiArea = QMdiArea() |
|
76 |
|
77 textEdit = QTextEdit() |
|
78 textEdit.setPlainText("Qt Quarterly is a paper-based newsletter " |
|
79 "exclusively available to Qt customers. Every " |
|
80 "quarter we mail out an issue that we hope will " |
|
81 "bring added insight and pleasure to your Qt " |
|
82 "programming, with high-quality technical articles " |
|
83 "written by Qt experts.") |
|
84 textWindow = mdiArea.addSubWindow(textEdit) |
|
85 textWindow.setWindowTitle("A Text Editor") |
|
86 |
|
87 label = QLabel() |
|
88 label.setPixmap(QPixmap("../../images/qt-logo.png")) |
|
89 labelWindow = mdiArea.addSubWindow(label) |
|
90 labelWindow.setWindowTitle("A Label") |
|
91 |
|
92 items = (("Henry", 23), ("Bill", 56), ("Susan", 19), ("Jane", 47)) |
|
93 table = QTableWidget(len(items), 2) |
|
94 |
|
95 for i in range(len(items)): |
|
96 name, age = items[i] |
|
97 item = QTableWidgetItem(name) |
|
98 table.setItem(i, 0, item) |
|
99 item = QTableWidgetItem(str(age)) |
|
100 table.setItem(i, 1, item) |
|
101 |
|
102 tableWindow = mdiArea.addSubWindow(table) |
|
103 tableWindow.setWindowTitle("A Table Widget") |
|
104 |
|
105 mdiArea.show() |
|
106 |
|
107 changer = Changer(mdiArea) |
|
108 button = QPushButton("Cascade") |
|
109 button.connect(button, SIGNAL("clicked()"), changer.change) |
|
110 button.show() |
|
111 sys.exit(app.exec_()) |