summaryrefslogtreecommitdiffstats
path: root/examples/pykde-sampler/misc/passivepop.py
blob: d38b4ec73d2b23755ff5ea105a79ebee7b7c8013 (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
from qt import Qt, QFrame, QHBoxLayout, QVBoxLayout, QLabel, SIGNAL
from tdeui import KPassivePopup, KTextEdit, KPushButton
from tdecore import KGlobal, KIcon

iconName = 'popup'
labelText = 'KPassivePopup'
docParts = ('tdeui', 'KPassivePopup')
helpText = ('Examples of the KPassivePopup widget.')


class MainFrame(QFrame):
    def __init__(self, parent=None):
        QFrame.__init__(self, parent)
        self.help = KTextEdit(helpText, '', self)
        self.button = KPushButton('Show Passive Popups', self)
        
        layout = QVBoxLayout(self, 4)
        layout.addWidget(self.help, 10)
        buttonLayout = QHBoxLayout(layout, 4)
        buttonLayout.addWidget(self.button, 1)
        buttonLayout.addStretch(10)
        layout.addStretch(10)


        self.connect(self.button, SIGNAL('clicked()'), self.showPopups)


    def showPopups(self):
        ## no support for all of the 3.5 calls
        pop = KPassivePopup.message('Hello, <i>KPassivePopup</i>', self)
        pop.setTimeout(3000)
        pop.show()

        
        pos = pop.pos()
        pos.setY(pos.y() + pop.height() + 10)
        
        ico = KGlobal.instance().iconLoader().loadIcon('help', KIcon.NoGroup,
                                                       KIcon.SizeSmall)
        pop = KPassivePopup.message('<b>Hello</b>', 'With Icons', ico, self)
        pop.setTimeout(3000)
        pop.show()
        pop.move(pos)