~ben-uberelvis/python-snippets/python-snippets

« back to all changes in this revision

Viewing changes to pykde4/kaboutkdedialog.py

  • Committer: Richard A. Johnson
  • Date: 2010-03-22 21:24:55 UTC
  • mto: This revision was merged to the branch mainline in revision 50.
  • Revision ID: nixternal@ubuntu.com-20100322212455-3g71ntumplad9xgj
Adding PyKDE4 snippets - more to come in the future

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# [SNIPPET_NAME: About KDE Dialog]
 
4
# [SNIPPET_CATEGORIES: PyKDE4]
 
5
# [SNIPPET_DESCRIPTION: PyKDE4 example showing the About KDE dialog]
 
6
# [SNIPPET_AUTHOR: Jim Bublitz <jbublitz@nwinternet.com>]
 
7
# [SNIPPET_LICENSE: GPL]
 
8
# [SNIPPET_DOCS: http://api.kde.org/pykde-4.3-api/kdecore/KAboutData.html]
 
9
 
 
10
from PyQt4.QtCore import SIGNAL, Qt
 
11
from PyQt4.QtGui import QLabel
 
12
 
 
13
from PyKDE4.kdecore import i18n
 
14
from PyKDE4.kdeui import KVBox, KHBox, KPushButton, KAboutKdeDialog
 
15
 
 
16
helpText = """The KAboutKdeDialog is the dialog that is normally
 
17
available from the help menu.
 
18
 
 
19
Press the button below to display the dialog.
 
20
"""
 
21
 
 
22
dialogName = "KAboutKdeDialog" 
 
23
 
 
24
class MainFrame(KVBox):       
 
25
    def __init__(self, parent):
 
26
        KVBox.__init__(self, parent)
 
27
        self.help = QLabel (helpText, self)
 
28
        self.layout ().setAlignment (self.help, Qt.AlignHCenter)
 
29
        
 
30
        hBox = KHBox (self)
 
31
        self.button = KPushButton(i18n("Show %s" % dialogName), hBox)
 
32
        self.button.setMaximumSize (250, 30)
 
33
        
 
34
        self.connect(self.button, SIGNAL('clicked()'), self.showDialog)
 
35
 
 
36
    def showDialog(self):
 
37
        dlg = KAboutKdeDialog (self.parent ())
 
38
        dlg.exec_ ()
 
39
 
 
40
 
 
41
 
 
42
# This example can be run standalone
 
43
 
 
44
if __name__ == '__main__':
 
45
 
 
46
    import sys
 
47
   
 
48
    from PyKDE4.kdecore import KCmdLineArgs, KAboutData, KLocalizedString, ki18n
 
49
    from PyKDE4.kdeui import KApplication, KMainWindow
 
50
    
 
51
                
 
52
    class MainWin (KMainWindow):
 
53
        def __init__ (self, *args):
 
54
            KMainWindow.__init__ (self)
 
55
 
 
56
            self.resize(640, 480)
 
57
            self.setCentralWidget (MainFrame (self))    
 
58
    
 
59
    #-------------------- main ------------------------------------------------
 
60
    
 
61
    appName     = "kaboutkdedialog.py"
 
62
    catalog     = ""
 
63
    programName = ki18n ("kaboutkdedialog")
 
64
    version     = "1.0"
 
65
    description = ki18n ("KAboutKdeDialog Example")
 
66
    license     = KAboutData.License_GPL
 
67
    copyright   = ki18n ("(c) 2007 Jim Bublitz")
 
68
    text        = ki18n ("none")
 
69
    homePage    = "www.riverbankcomputing.com"
 
70
    bugEmail    = "jbublitz@nwinternet.com"
 
71
 
 
72
    aboutData   = KAboutData (appName, catalog, programName, version, description,
 
73
                              license, copyright, text, homePage, bugEmail)
 
74
 
 
75
    # ki18n required for first two addAuthor () arguments
 
76
    aboutData.addAuthor (ki18n ("Troy Melhase"), ki18n ("original concept"))
 
77
    aboutData.addAuthor (ki18n ("Jim Bublitz"), ki18n ("pykdedocs"))
 
78
    
 
79
    KCmdLineArgs.init (sys.argv, aboutData)
 
80
    
 
81
    app = KApplication ()
 
82
    mainWindow = MainWin (None, "main window")
 
83
    mainWindow.show()
 
84
    app.connect (app, SIGNAL ("lastWindowClosed ()"), app.quit)
 
85
    app.exec_ ()