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
|
#!/usr/bin/env python
import sys, os.path
from PyQt4.QtCore import QString, SIGNAL, Qt, QSize
from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs, i18n
from PyKDE4.kdeui import KApplication, KXmlGuiWindow, KTextEdit, KAction
from PyKDE4.kdeui import KStandardAction, KIcon
class MainWindow (KXmlGuiWindow):
def __init__ (self):
KXmlGuiWindow.__init__ (self)
self.textArea = KTextEdit ()
self.setCentralWidget(self.textArea)
self.setupActions()
def setupActions (self):
clearAction = KAction(KIcon("edit-clear"), i18n("Clear"), self)
dfltShortcut = KAction.ShortcutTypes (KAction.DefaultShortcut)
activeShortcut = KAction.ShortcutTypes (KAction.ActiveShortcut)
clearAction.setShortcut(Qt.CTRL+Qt.Key_W, dfltShortcut | activeShortcut)
self.actionCollection().addAction("clear", clearAction)
self.connect (clearAction, SIGNAL ("triggered(bool)"), self.textArea.clear)
KStandardAction.quit (app.quit, self.actionCollection())
self.setupGUI(QSize (600, 400), KXmlGuiWindow.Default, os.path.join (sys.path [0], "kactionui.rc"))
#--------------- main ------------------
appName = "KAction"
catalog = ""
programName = ki18n ("KAction")
version = "1.2"
description = ki18n ("Tutorial - Fourth Program")
license = KAboutData.License_GPL
copyright = ki18n ("(c) 2007 Jim Bublitz")
text = ki18n ("none")
homePage = "www.riverbankcomputing.com"
bugEmail = "jbublitz@nwinternet.com"
aboutData = KAboutData (appName, catalog, programName, version, description,
license, copyright, text, homePage, bugEmail)
KCmdLineArgs.init (sys.argv, aboutData)
app = KApplication ()
#------- new stuff added here ----------
mainWindow = MainWindow ()
mainWindow.show ()
app.exec_ ()
|