source: orange/Orange/OrangeCanvas/gui/tests/test_dock.py @ 11100:cf6f6744dd9b

Revision 11100:cf6f6744dd9b, 1.7 KB checked in by Ales Erjavec <ales.erjavec@…>, 19 months ago (diff)

Added gui widget toolkit.

Line 
1"""
2Tests for the DockWidget.
3
4"""
5
6from PyQt4.QtGui import QWidget, QMainWindow, QListView, QTextEdit, \
7                        QToolButton, QStringListModel, QHBoxLayout, QLabel
8
9from PyQt4.QtCore import Qt
10
11from .. import test
12from ..dock import CollapsibleDockWidget
13
14
15class TestDock(test.QAppTestCase):
16    def test_dock_standalone(self):
17        widget = QWidget()
18        layout = QHBoxLayout()
19        widget.setLayout(layout)
20        layout.addStretch(1)
21        widget.show()
22
23        dock = CollapsibleDockWidget()
24        layout.addWidget(dock)
25        list_view = QListView()
26        list_view.setModel(QStringListModel(["a", "b"], list_view))
27
28        label = QLabel("A label. ")
29        label.setWordWrap(True)
30
31        dock.setExpandedWidget(label)
32        dock.setCollapsedWidget(list_view)
33        dock.setExpanded(True)
34
35        self.app.processEvents()
36
37        def toogle():
38#            print dock.width(), dock.minimumWidth(), dock.sizeHint()
39            dock.setExpanded(not dock.expanded())
40            self.singleShot(2000, toogle)
41
42        toogle()
43
44        self.app.exec_()
45
46    def test_dock_mainwinow(self):
47        mw = QMainWindow()
48        dock = CollapsibleDockWidget()
49        w1 = QTextEdit()
50
51        w2 = QToolButton()
52        w2.setFixedSize(38, 200)
53
54        dock.setExpandedWidget(w1)
55        dock.setCollapsedWidget(w2)
56
57        mw.addDockWidget(Qt.LeftDockWidgetArea, dock)
58        mw.setCentralWidget(QTextEdit())
59        mw.show()
60
61        def toogle():
62#            print dock.width(), dock.minimumWidth(), dock.sizeHint()
63            dock.setExpanded(not dock.expanded())
64            self.singleShot(2000, toogle)
65
66        toogle()
67
68        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.