Creating Context Menu in Python Script
#1
I am putting together a small framework written in Python that should simplify the conversion of list based addons into graphical addons.

The way I have implemented it you can spend just a few minutes (literally) making a couple of simple changes to a default.py and all the lists will still be populated as usual but instead of appearing in the usual XBMC lists, the information will instead appear in a list within a graphical window (xbmc.windowXML) which you as a developer then have complete control of to extend as you wish (via the window's XML file).

I have however run into a problem trying to implement the context menu functionality.

I assume that because the code runs as a script rather than a plugin I can't do the usual

Code:
contextMenu = []
#populate context menu
liz.addContextMenuItems(contextMenu)

Although that isn't the actual problem; so in my code onAction is triggered and I can retrieve the appropriate list of tuples that make up the context menu I want to create.

So how do I then go about creating a context menu and displaying it in the middle of the screen like the standard one does? I would like it to use the existing XML if possible;

Code:
DialogContextMenu.xml

So that it looks like the standard context menu regardless of the current selected skin. I would also like it to resize according to how many items are in the menu, like the standard one does.

If it is important I am using a list with ID 59 in my window to display the list items from which I want to invoke the context menu.

Any help would be most appreciated, but please go easy on me, I'm fairly new to XBMC skinning!
Reply
#2
scripts can't use DialogContextMenu.xml (only plugins can).
you'll have to create your own context menu.

see script.globalsearch for example.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
(2013-12-11, 17:06)ronie Wrote: scripts can't use DialogContextMenu.xml (only plugins can).
you'll have to create your own context menu.

see script.globalsearch for example.

Thanks Ronie, I thought as much.

I have currently implemented it using a list control using the button textures so it looks the same. It works okay tbh but I'll have a look at the global search script and see how that does things.

As I said I'm new to this skinning game so any examples of anything will almost certainly help in the long run.
Reply

Logout Mark Read Team Forum Stats Members Help
Creating Context Menu in Python Script0