Kodi Community Forum

Full Version: How to use a custom window with a custom addon?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have created an improved network manager addon which generates a listing of available wifi connections,

Currently it is using the container 53 view. I would like it to utilize a custom window I have created custom_network.xml

Is there a way to have the addon utilize a window I have previously created (custom_network.xml)

I cannot find any reference of how to point the addon to this when generating a listing (listing code below)

The code is envoked via the default.py script within the addon directory.

PHP Code:
def GENERATE_LISTING():


        global 
wifi_string
        
global active_wifi
        
        active_wifi 
'None'

        
proc Popen("nmcli dev wifi",shell=Truestdout=PIPE)
        
ethernet_mask my_addon.getSetting('ethernet.mask')
        
listing = []

        for 
line in proc.stdout:
                try:

                        
scan_secure "secure"
                        
scan_connect "no"

                        
scan_essid   line.rsplit("'")[1]
                        
scan_signal  line.rsplit("'")[2].rsplit()[6]
                        if 
line.rsplit("'")[2].rsplit()[-2] == "--" scan_secure "open"
                        
if line.rsplit("'")[2].rsplit()[-1] == "yes" scan_connect "connected"

                        
listing.append(scan_essid "," scan_signal "," scan_secure "," scan_connect)

                
except IndexError:
                    
pass


        
#show the correct icon
        
for item in listing:
                
supress False
                
if (device_name in item.rsplit(",")[0] or "mediabadger" in item.rsplit(",")[0]) and "NetConnect" not in item.rsplit(",")[0]: supress True
                wifi_image 
'wifi_0'
                
sort_filter 105 int(item.rsplit(',')[1])
                if 
int(item.rsplit(',')[1]) >  0  wifi_image='wifi_25'
                
if int(item.rsplit(',')[1]) >  24 wifi_image='wifi_50'
                
if int(item.rsplit(',')[1]) >  49 wifi_image='wifi_75'
                
if int(item.rsplit(',')[1]) >  75 wifi_image='wifi_100'

                
if str(item.rsplit(',')[3]) == "connected"sort_filter "1"
                
if str(item.split(',')[2]) == "secure"    wifi_image wifi_image "l"
                
if str(item.split(',')[3]) == "connected" wifi_image wifi_image "c"
                
if str(item.split(',')[3]) == "connected" active_wifi item.rsplit(",")[0]
                
wifi_image wifi_image ".png"

                
#build an ethernet port image for the netdongle
                
if ("MediaBadger NetConnect" in item.rsplit(",")[0]):
                    
wifi_image 'wifi_eth'
                    
if str(item.rsplit(',')[3]) == "connected"sort_filter "1"
                    
if str(item.split(',')[3]) == "connected"wifi_image wifi_image "c"
                    
wifi_image wifi_image ".png"


                
#now build the list
                
url BUILD_URL({'SSID'item.rsplit(',')[0], 'ACTIVE'active_wifi})
                
li xbmcgui.ListItem(item.rsplit(',')[0], iconImage=wifi_imagethumbnailImage=wifi_image)

                
li.addContextMenuItems([ ('Refresh''Container.Refresh') ] , replaceItems=True)
                
li.setInfo('video', {'director'"Something sexy"'tracknumber'sort_filter'title'item.rsplit(',')[0] })
                
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)

                if 
not supressxbmcplugin.addDirectoryItem(handle=addon_handleurl=urllistitem=liisFolder=True)

        
#build ethernet port (only when not supressed)
        
if ethernet_mask == 'false' :

                if 
not subprocess.call("ifconfig eth0  |grep 'inet add'",shell=Truestdin=Nonestderr=Nonestdout=None):
                        
wifi_image 'wifi_ethc.png'
                
else:
                        
wifi_image 'wifi_eth.png'

                
url BUILD_URL({'SSID''Ethernet'})
                
li xbmcgui.ListItem('Ethernet'iconImage=wifi_imagethumbnailImage=wifi_image)

                
li.addContextMenuItems([ ('Refresh''Container.Refresh') ] , replaceItems=True)
                
li.setInfo('video', {'director'"Something sexy"'tracknumber'2'title''Ethernet' })
                
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)
                
xbmcplugin.addDirectoryItem(handle=addon_handleurl=urllistitem=liisFolder=True)
        
        
#build refresh button
        
wifi_image 'wifi_broadcast.png'
        
url BUILD_URL({'SSID''Broadcast'})
        
li xbmcgui.ListItem('Re-broadcast Services'iconImage=wifi_imagethumbnailImage=wifi_image)
        
li.setInfo('video', {'director'"Something sexy"'tracknumber'0'title''Re-broadcast Services' })        
        
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)
        
xbmcplugin.addDirectoryItem(handle=addon_handleurl=urllistitem=liisFolder=True)  
  
        
#build broadcast button
        
wifi_image 'wifi_refresh.png'
        
url BUILD_URL({'SSID''Refresh Connections'})
        
li xbmcgui.ListItem('Refresh Connections'iconImage=wifi_imagethumbnailImage=wifi_image)
        
li.setInfo('video', {'director'"Something sexy"'tracknumber'0'title''Refresh' })
        
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)
        
xbmcplugin.addDirectoryItem(handle=addon_handleurl=urllistitem=liisFolder=True
     
     
        
xbmcplugin.endOfDirectory(addon_handle

Thanks
that's not possible.

the addon is written as a plugin and plugins can't use their own xml window.
they depend on whatever views are already available in the skin.

only script type addons can ship with their own custom window.
Hi Ronie,

Thanks for the response, that is a pain.

Forgive my ignorance, can you point me towards the info on this? I can't locate anything specific.

(Namely on how to generate a script based addon)
you could "embed" your plugin content into any custom xml by using <content>plugin://..</content> (Sortmethods, contextmenu and probably some other stuff wont work this way though)
OK will give that a go. Thanks for the help.

Having just spent several hours trying to get xbmcgui add control methods to work, I am not going to re-engineer all this work.

if this works great otherwise, sod it Wink