[PyKDE] KDE XML GUI ActionLists

Gordon Tyler gordon at doxxx.net
Tue Apr 22 05:16:01 BST 2003


Hi all,

Continuing from my experiments with KDE's XML GUI stuff and popup menu's, I'm 
now trying to get ActionLists to work, but with no success.

In the attached ui.rc file, I have an ActionList defined in the "Open With..." 
submenu of File menu and in a popup menu. In the script, I'm attempting to 
update the contents of the ActionList with the following code (reformatted 
for email):

    def updateOpenWithActions(self, selectedFileItems):
        print "updateOpenWithActions"
        self.unplugActionList("file_open_with_list")
        self.openWithActions = []
        if len(selectedFileItems) == 1:
            fileItem = selectedFileItems[0]
            offers = KServiceTypeProfile.offers(fileItem.mimetype(), \
                    "Application")
            offers.sort(lambda x,y: cmp(x.preference(), y.preference()))
            for offer in offers:
                service = offer.service()
                print "updateOpenWithActions: service=%s, preference=%d" % \
                        (str(service.name()), offer.preference())
                action = KAction(service.name(), KShortcut(), \
                        self.fileOpenWith, None, "file_open_with_" + \
                        str(service.desktopEntryName()))
                self.openWithActions.append(action)
        self.plugActionList("file_open_with_list", self.openWithActions)

I've verified that the KActions are being created and added to the 
self.openWithActions list. However, when I run the scriptand open either of 
the menus that contain the ActionList, there are no items. No errors, just an 
empty menu.

Has anybody else used ActionLists in PyKDE?

Thanks,
Gordon
-------------- next part --------------
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="finder" version="1">

    <MenuBar>
        <Menu name="file" noMerge="1"><text>&amp;File</text>
            <Action name="file_open"/>
            <Menu name="file_open_with"><text>Open &amp;With</text>
                <ActionList name="file_open_with_list"/>
                <Action name="file_open_with_choose"/>
            </Menu>
            <Separator/>
            <Action name="file_properties"/>
            <Separator/>
            <Action name="file_close_window"/>
        </Menu>
    </MenuBar>

    <Menu name="context">
        <Action name="file_open"/>
        <Menu name="file_open_with"><text>Open &amp;With</text>
            <ActionList name="file_open_with_list"/>
            <Action name="file_open_with_choose"/>
        </Menu>
        <Separator/>
        <Action name="file_properties"/>
    </Menu>

</kpartgui>


More information about the PyQt mailing list