summaryrefslogtreecommitdiffstats
path: root/examples/pytde-sampler/dialogs/font.py
blob: 7846eb6c3d87918bb6e2cbdcab4851dde5aa5a57 (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

from PyTQt.tqt import TQFrame, TQHBoxLayout, TQVBoxLayout, TQTimer, SIGNAL, TQFont, TQString
from tdecore import i18n
from tdeui import KPushButton, TDEFontDialog, KTextEdit

iconName = 'fonts'
labelText = 'TDEFontDialog'
docParts = ('tdeui', 'TDEFontDialog')
helpText = ("TDE provides a font dialog box for users to select (can you "
            "guess??) fonts.  The button below displays a font dialog box.  "
            "The font of this widget (the text widget you're reading) is used "
            "as the default.  If the dialog is accepted, the font of this "
            "widget is change to match the selection.")


fontText = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam
ante. Nam in mauris. Vestibulum ante velit, condimentum vel, congue
sit amet, lobortis a, dui. Fusce auctor, quam non pretium nonummy, leo
ante imperdiet libero, id lobortis erat erat quis eros. Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac
turpis egestas. Cras ut metus. Vivamus suscipit, sapien id tempor
elementum, nunc quam malesuada dolor, sit amet luctus sapien odio vel
ligula. Integer scelerisque, risus a interdum vestibulum, felis ipsum
pharetra eros, nec nonummy libero justo quis risus. Vestibulum
tincidunt, augue vitae suscipit congue, sem dui adipiscing nulla, ut
nonummy arcu quam ac sem. Nulla in metus. Phasellus neque.
"""


class MainFrame(TQFrame):
    def __init__(self, parent=None):
        TQFrame.__init__(self, parent)
        self.button = KPushButton(i18n('Show Font Dialog'), self)
        self.help = KTextEdit(helpText, '', self)
        self.example = KTextEdit(fontText, '', self)
        
        layout = TQVBoxLayout(self, 4)
        layout.addWidget(self.help)
        buttonlayout = TQHBoxLayout(layout, 4)
        buttonlayout.addWidget(self.button)
        buttonlayout.addStretch(1)
        layout.addWidget(self.example, 10)
        layout.addStretch(1)
        self.connect(self.button, SIGNAL('clicked()'), self.showFontDialog)


    def showFontDialog(self):
        font = TQFont(self.example.font())
        string = TQString()
        accepted, other = TDEFontDialog.getFontAndText(font, string, False, self)
        if accepted:
            self.example.setFont(font)
            self.example.setText(string)