[PyKDE] where is KStdAccel::New?
Jim Bublitz
jbublitz at nwinternet.com
Fri Feb 4 16:50:45 GMT 2005
On Friday 04 February 2005 06:19, Christopher J. Bottaro wrote:
> OK, I found KStdAccel::shortcut in kdeui.KAction (would have been nice if
> this was documented somewhere seeing as how there isn't really a direct
> mapping in Python), but where is KStdAccel::New?
>
> I'm reading the KDE API documentation and I'm trying mimic the following
> code in PyKDE:
>
> KAction *newAct = new KAction(i18n("&New"), "filenew",
> KStdAccel::shortcut(KStdAccel::New),
> this, SLOT(fileNew()),
> actionCollection(), "new");
>
> I took me a while to figure out that KStdAccel::shortcut is
> kdeui.KAction.shortcut in PyKDE, but I'm stumped about KStdAccel::New
> (and KStdAccel::Quit, etc).
This should work:
from kdecore import KStdAccel
from kdeui import KAction, KMainWindow
class MainWin (KMainWindow):
def __init__ ( ... ):
...
self.newAct = KAction (i18n("&New"), "filenew",
KStdAccel.shortcut(KStdAccel.New),
self, self.fileNew,
self.actionCollection(), "new");
def fileNew ( ... ):
...
KStdAccel is in the kdecore section in the PyKDE docs (which just lists the
available members in Python syntax). The copy of the KDE API docs I looked at
didn't include KStdAccel - you could file a bug report with them if that's
still the case.
This is easier:
from kdeui import KMainWindow, KStdAction
class MainWin (KMainWindow):
def __init__ (self, *args):
...
self.newAction = KStdAction.openNew (self.slotNew,
self.actionCollection ())
def slotNew (self, id = -1):
See templates/annotated/menuapp3.py (templates/basic/menapp3.py for the same
thing without the comments).
Jim
More information about the PyQt
mailing list