summaryrefslogtreecommitdiffstats
path: root/examples/splitter.py
blob: 534e50e47b45d8f42a64906d8db52b45e58b9a2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python

import sys
from PyTQt.qt import *

class Test(TQWidget):
    def __init__(self, parent=None, name='Test', f=0):
        TQWidget.__init__(self, parent, name, f)

    def paintEvent(self, e):
        p = TQPainter(self)
        p.setClipRect(e.rect())
        d = 1000
        x1 = 0
        x2 = self.width() - 1
        y1 = 0
        y2 = self.height() - 1
        
        x = int((x1+x2)/2)
        p.drawLine(x, y1, x+d, y1+d)
        p.drawLine(x, y1, x-d, y1+d)
        p.drawLine(x, y2, x+d, y2-d)
        p.drawLine(x, y2, x-d, y2-d)

        y = int((y1+y2)/2)
        p.drawLine(x1, y, x1+d, y+d)
        p.drawLine(x1, y, x1+d, y-d)
        p.drawLine(x2, y, x2-d, y+d)
        p.drawLine(x2, y, x2-d, y-d)


if __name__=="__main__":
    a = TQApplication(sys.argv)

    s1 = TQSplitter(TQt.Vertical, None, "main")
    s2 = TQSplitter(TQt.Horizontal, s1, "top")

    t1 = Test(s2)
    t1.setEraseColor(TQt.blue.light(180))
    t1.setMinimumSize(50,0)

    t2 = Test(s2)
    t2.setEraseColor(TQt.green.light(180))
    s2.setResizeMode(t2, TQSplitter.KeepSize)
    s2.moveToFirst(t2)

    s3 = TQSplitter(TQt.Horizontal, s1, "bottom")

    t3 = Test(s3)
    t3.setEraseColor(TQt.red)
    t4 = Test(s3)
    t4.setEraseColor(TQt.white)

    t5 = Test(s3)
    t5.setMaximumHeight(250)
    t5.setMinimumSize(80,50)
    t5.setEraseColor(TQt.yellow)

    s1.setOpaqueResize(1)
    s2.setOpaqueResize(1)
    s3.setOpaqueResize(1)

    a.setMainWidget(s1)
    s1.show()
    a.exec_loop()