WIP Skin Editer
#1
Skin Editor
by Skin Headz


somebody else can pick this up

SCRIPT TO MOVE A SKIN ITEM
PHP Code:
import xbmcgui,sys,os,xbmc
from xml
.etree import ElementTree as et
ACTION_PREVIOUS_MENU 
10
ACTION_SELECT_ITEM 
7
ACTION_BACKSPACE 
92
ACTION_MOVE_RIGHT 
2
ACTION_MOVE_LEFT 
1
BAR_FROM_TOP 
".//*[@name='SkinHeadzBarTop']/top"
BAR_HEIGHT ".//*[@name='SkinHeadzBarHeight']/height"
BAR_WIDTH ".//*[@name='SkinHeadzBarWidth']/width"
SUB_BAR_TOP ".//*[@name='SkinHeadzSubBarTop']/top"

class WindowXMLDialog(xbmcgui.WindowXMLDialog):
    
def onInit(self):
        
#Put list populating code/GUI startup things here
        
self.window xbmcgui.Window(13000)
        
self.SkinHeadz xbmc.translatePath('special://skin/1080i/includes_Demon.xml')
        
self.tree et.parse(self.SkinHeadz)
        
self.slider self.getControl9119 )
        
self.sliderperc self.slider.getPercent()
        
self.refBar self.getControl9120 )
        
self.text self.getControl9121 )
        
self.text.setLabel('SET POSITION')
        
self.refBar.setHeight(int(self.tree.find(".//*[@name='SkinHeadzBarHeight']/height").text))
        
self.slider.setPercent(self.pixeltopercent(int(self.tree.find('.//top').text)))
        
self.refBar.setPosition(0,int(self.tree.find('.//top').text))
        
self.refBar.setWidth(int(self.tree.find(".//*[@name='SkinHeadzBarWidth']/width").text))



    
def pixeltopercent(self,pixel):
        return 
int(pixel 100 1080)

    
def pixeltopercent1920(self,pixel):
        return 
int(pixel 100 1920)

    
def percenttopixel(self,percent):
        return 
int(percent 1080 100)

    
def percenttopixel920(self,percent):
        return 
int(percent 1920 100)

    
def setHeight(self):
        
self.currentHeight self.tree.find(BAR_HEIGHT).text
        self
.slider.setPercent(self.pixeltopercent(self.currentHeight))
        
self.text.setLabel('SET HEIGHT')
        
self.refBar.setHeight(self.percenttopixel(self.sliderperc))

    
def setElement(self,percent,element):
        if 
element == SUB_BAR_TOP
            
self.pixels str(int(percent 1080 100))
            
self.tree.find(element).text self.pixels
            self
.tree.write(self.SkinHeadz)
        else:
            
self.pixels str(int(percent 1080 100))
            
self.tree.find(element).text self.pixels
            self
.tree.write(self.SkinHeadz)
        if 
element == BAR_FROM_TOP:
            
self.slider.setPercent(self.pixeltopercent(int(self.tree.find(BAR_HEIGHT).text)))
        
#elif element == BAR_HEIGHT : xbmc.executebuiltin('ReloadSkin()')
        
elif element == BAR_HEIGHT:
            
xbmc.executebuiltin('ReloadSkin()')

    
def bar(self,attrib):
        if 
'osition' in attrib:    self.refBar.setPosition(0,self.percenttopixel(self.slider.getPercent()))
        
elif 'eight' in attribself.refBar.setHeight(self.percenttopixel(self.slider.getPercent()))

    
def onAction(selfaction):
        if 
action == ACTION_BACKSPACE:self.close()
        
elif action == ACTION_SELECT_ITEM:
            if 
"POSITION" in self.text.getLabel(): 
                
self.setElement(self.slider.getPercent(),BAR_FROM_TOP)
                
self.text.setLabel('SET HEIGHT')
            
elif "HEIGHT" in self.text.getLabel():
                
self.setElement(self.slider.getPercent(),BAR_HEIGHT)
                
self.setElement(self.slider.getPercent(),SUB_BAR_TOP)
                
self.text.setLabel('SET WIDTH')
            
elif "WIDTH" in self.text.getLabel():
                
self.setElement(self.slider.getPercent(),BAR_WIDTH)
        
elif action == ACTION_MOVE_LEFT
            if 
"POSITION" in self.text.getLabel(): self.bar("position")
            
elif "HEIGHT" in self.text.getLabel(): self.bar("height")
            
elif "WIDTH" in self.text.getLabel(): self.bar("width")
        
elif action == ACTION_MOVE_RIGHT:
            if 
"POSITION" in self.text.getLabel(): self.bar("position")
            
elif "HEIGHT" in self.text.getLabel(): self.bar("height")
            
elif "WIDTH" in self.text.getLabel(): self.bar("width")

    
def onClick(self,controlID):
        if 
controlID == 9119pass
            
#self.getControl( 9120 ).setPosition(0,int(self.slider.getPercent()))

    
def onFocus(self,controlID):
        
pass
if __name__ == "__main__":
    
scriptDir xbmc.translatePath('special://skin/')
    
sys.path.insert(0os.path.join(scriptDir,'1080i'))
    
WindowXMLDialog("Custom_Resize.xml"scriptDir)
    
w.doModal()
    
del w 

includes_Demon
PHP Code:
<includes>
    <include 
name="SkinHeadzBarTop">
        <
top>10</top>
    </include>
    <include 
name="SkinHeadzBarHeight">
        <
height>162</height>
    </include>
    <include 
name="SkinHeadzSubBarTop">
        <
top>162</top>
    </include>
    <include 
name="SkinHeadzBarWidth">
        <
width>2210</width>
    </include>
    <include 
name="SkinHeadzSideLeft">
        <
width>750</width>
        <
left>-53</left>
    </include>
    <include 
name="SkinHeadzSideRight">
        <
width>750</width>
        <
left>52</left>
    </include>
    <include 
name="SkinHeadzSideGap">
        <
itemgap>960</itemgap>
    </include>
</
includes


Heres the library i used with it
PHP Code:
import xbmc,xbmcaddon,xbmcgui,urllib2,base64,shutil,re,fileinput
import errno
,json,os,hashlib,sys,urllib,xbmcplugin,time

def show
(string):
    return 
base64.b64decode(b'%s'%string)

def hide(string):
    return 
base64.b64encode(b'%s'%string)

def exe(string):
    
xbmc.executebuiltin(string)

def updateaddons():
    
exe('UpdateLocalAddons')

def reloadkeymaps():
    
exe('Action(reloadkeymaps)')

def window(window):
    
exe('ActivateWindow(%s)'%window)

def pvr(toggle):
    
jsonGetPVR '{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"pvrmanager.enabled"}, "id":1}'
    
jsonSetPVR '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"pvrmanager.enabled", "value":%s},"id":1}'
    
jsonNotify '{"jsonrpc":"2.0", "method":"GUI.ShowNotification", "params":{"title":"PVR", "message":"%s","image":""}, "id":1}'
    
PVR json.loads(xbmc.executeJSONRPC(jsonGetPVR))['result']['value']
    if 
toggle:
        if (
PVR == False):
            
xbmc.executeJSONRPC(jsonSetPVR "true")
            
xbmc.executeJSONRPC(jsonNotify "Live TV Enabled")
        else: 
pass
    
else:
        if 
PVR# i may not want to disable at all. there may be no need
            
xbmc.executeJSONRPC(jsonSetPVR "false")
            
xbmc.executeJSONRPC(jsonNotify "Live TV Disabled")

def download(urldestdp None):
    if 
not dp:
        
dp xbmcgui.DialogProgress()
        
dp.create(addon('id'),"Downloading Content",' '' ')
    
dp.update(0)
    
start_time=time.time()
    
urllib.urlretrieve(urldestlambda nbbsfs_pbhook(nbbsfsdpstart_time))

def _pbhook(numblocksblocksizefilesizedpstart_time):
    try: 
        
percent min(numblocks blocksize 100 filesize100
        
currently_downloaded float(numblocks) * blocksize / (1024 1024
        
kbps_speed numblocks blocksize / (time.time() - start_time
        if 
kbps_speed and not percent == 100
            
eta = (filesize numblocks blocksize) / kbps_speed 
        
else: 
            
eta 0
        kbps_speed 
kbps_speed 1024 
        type_speed 
'KB'
        
if kbps_speed >= 1024:
            
kbps_speed kbps_speed 1024 
            type_speed 
'MB'
        
total float(filesize) / (1024 1024
        
mbs '[COLOR red][B]Size:[/B] [COLOR green]%.02f[/COLOR] MB of [COLOR green]%.02f[/COLOR] MB[/COLOR]'%(currently_downloadedtotal
        
e   '[COLOR red][B]Speed:[/B] [COLOR green]%.02f [/COLOR]%s/s ' % (kbps_speedtype_speed)
        
e  += '[B]ETA:[/B] [COLOR green]%02d:%02d[/COLOR][/COLOR]' divmod(eta60)
        
dp.update(percent''mbse)
    
except Exceptione:
        return 
str(e)
    if 
dp.iscanceled(): 
        
dp.close()
        
sys.exit()

def forceclose(name="This Function"):
    if 
choice('In Order To Enable %s, You Must Force Close'%(name),"Force Close","Later"): os._exit(1)

def read(file):
    return 
open(file'r').read()

def search(query,file):
    return 
re.findall(query,file)

def action(string):
    
exe('Action(%s)'%(string))

def info(string):
    return 
xbmc.getInfoLabel(string)

def refreshContainer():
    
exe('Container.Refresh')

def updateContainer():
    
exe('Container.Update')

def startpvr():
    
exe('StartPVRManager')

def controlMessage(control):
    
exe('Control.Message(%s)')%(control)

def RunAddon(id):
    
exe('RunAddon(%s)')%(id)

def RunPlugin(id):
    
exe('RunPlugin(%s)')%(id)

def condition(string):
    return 
xbmc.getCondVisibility(string)

def enableaddon(id,enable='true'):
    
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "%s", "enabled": "%s" }}'%(id,enable))

def hasaddon(addon):
    try:
        if 
xbmcaddon.Addon(addon): return True
    except
: return False

def copy
(srcdst):
    try:
        
shutil.copytree(srcdst)
    
except OSError as exc# python >2.5
        
if exc.errno == errno.ENOTDIR:
            
shutil.copy(srcdst)
        else: 
raise

def addon
(item,id="skin.aeon.nox.silvo.skinheadz"):
    try:
        if 
item     == 'id'                : return xbmcaddon.Addon(id).getAddonInfo('id')
        
elif item    == 'name'            : return xbmcaddon.Addon(id).getAddonInfo('name')
        
elif item     == 'path'            : return xbmcaddon.Addon(id).getAddonInfo('path')
        
elif item     == 'icon'            : return xbmcaddon.Addon(id).getAddonInfo('icon')
        
elif item     == 'fanart'            : return xbmcaddon.Addon(id).getAddonInfo('fanart')
        
elif item     == 'author'            : return xbmcaddon.Addon(id).getAddonInfo('author')
        
elif item     == 'fanart'            : return xbmcaddon.Addon(id).getAddonInfo('fanart')
        
elif item     == 'version'        : return xbmcaddon.Addon(id).getAddonInfo('version')
        
elif item     == 'summary'        : return xbmcaddon.Addon(id).getAddonInfo('summary')
        
elif item     == 'description'    : return xbmcaddon.Addon(id).getAddonInfo('description')
    
except: return False

def data
(string):
    return 
json.loads(string)

def openURL(url):
    
req urllib2.Request(url)
    
req.add_header('User-Agent'addon('id'))
    
response urllib2.urlopen(req)
    
link=response.read()
    
response.close()
    return 
link

def notification
(message,title=addon('name')):
    
xbmcgui.Dialog().notification(title,message)

def ok(line1,line2=None,line3=None,title=addon('name')):
    
xbmcgui.Dialog().ok(titleline1=line1,line2=line2,line3=line3)

def choice(string,y='YES',n='NO',title=addon('name')):
    return 
xbmcgui.Dialog().yesno(title,string,yeslabel=y,nolabel=n)

def input(heading=addon('name')):
    return 
xbmcgui.Dialog().input(headingtype=xbmcgui.INPUT_ALPHANUM)

def cut(string):
    
exec(string)

def log(string):
    
xbmc.log(string)

def setting(id,value=None,addon=addon('id')):
    if 
not value                     : return xbmcaddon.Addon(addon).getSetting(id)
    else                             : return 
xbmcaddon.Addon(addon).setSetting(id,value)

def insertline(file,search,add):
    
includes = []
    for 
line in fileinput.FileInput(file,inplace=1):
        if 
search in line:
            
line=line.replace(line,line+add)
        
includes.append(line)
    
with open(file"a") as myfile:
        for 
line in includes:
            
myfile.write(line)
    

def md5(fname):
    
hash_md5 hashlib.md5()
    
with open(fname"rb") as f:
        for 
chunk in iter(lambdaf.read(4096), b""):
            
hash_md5.update(chunk)
    return 
hash_md5.hexdigest()

def addItemGUI(conrol,label1=None,label2=None,icon=None,thumb=None):
    
self.self.window.getControl(control).addItem(xbmcgui.ListItem(label1label2=urliconImage=iconthumbnailImage=thumb))

def addDir(displaymode=None,username=None,password=None,icon=addon(show('aWNvbg==')),description=addon(show('aWQ='))):
    
sys.argv[0]
    if 
not mode == None:         += show("P21vZGU9JXM=") % urllib.quote_plus(mode)
    
ok=True
    liz
=xbmcgui.ListItem(displayiconImage=show("RGVmYXVsdEZvbGRlci5wbmc="), thumbnailImage=icon)
    
liz.setInfotype="Video"infoLabels={ show("VGl0bGU="): displayshow("UGxvdA=="): description} )
    
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
    return 
ok

def addItem
(displaymode=None,username=None,password=None,icon=addon(show('aWNvbg==')),description=addon(show('aWQ='))):
    
sys.argv[0]
    if 
not mode == None:        += show("P21vZGU9JXM=") % urllib.quote_plus(mode)
    
ok=True
    liz
=xbmcgui.ListItem(displayiconImage=show("RGVmYXVsdEZvbGRlci5wbmc="), thumbnailImage=icon)
    
liz.setInfotype="Video"infoLabels={ show("VGl0bGU="): displayshow("UGxvdA=="): description} )
    
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz)
    return 
ok

def skinres
():
    
results search(r'aspect="(.+?)" .+? folder="(.+?)"',read(xbmc.translatePath('special://skin/addon.xml')))
    for 
item in results:
        if 
info('Skin.AspectRatio'in item:
            for 
listitem in item:
                if 
not info('Skin.AspectRatio'in listitem:
                    
xbmc.log(listitem)
                    return 
listitem

def get
(path,file=None):
    if 
'ystem'         in path:                         return xbmc.translatePath('special://xbmc/'+file)                                     if file else xbmc.translatePath('special://xbmc/')
    
elif 'ome'         in path:                          return xbmc.translatePath('special://home/'+file)                                     if file else xbmc.translatePath('special://home/')
    
elif 'ddons'     in path:                         return xbmc.translatePath('special://home/addons/'+file)                             if file else xbmc.translatePath('special://home/addons/')
    
elif 'serdata'     in path:                         return xbmc.translatePath('special://userdata/'+file)                                 if file else xbmc.translatePath('special://userdata/')
    
elif 'atabase'     in path:                         return xbmc.translatePath('special://userdata/Database/'+file)                         if file else xbmc.translatePath('special://userdata/Database/')
    
elif 'eymaps'     in path:                         return xbmc.translatePath('special://userdata/keymaps/'+file)                         if file else xbmc.translatePath('special://userdata/keymaps/')
    
elif 'ddon'     in path and 'ata' in path:         return xbmc.translatePath('special://userdata/addon_data/'+file)                     if file else xbmc.translatePath('special://userdata/addon_data')
    
elif 'lugin.'     in path:                         return xbmc.translatePath('special://home/addons/'+path+"/"+file)                     if file else xbmc.translatePath('special://home/addons/%s/'%path)
    
elif 'cript.'     in path:                         return xbmc.translatePath('special://home/addons/'+path+"/"+file)                     if file else xbmc.translatePath('special://home/addons/%s/'%path)
    
elif 'kin'         in path and 'addon.xml' in file:return xbmc.translatePath('special://skin/%s'%(file))
    
elif 'kin'         in path and 'debug' in file:     return xbmc.translatePath('special://skin/media/%s'%(file))
    
elif 'kin'         in path:                        return xbmc.translatePath('special://skin/%s/%s'%(skinres(),file))                  if file else xbmc.translatePath('special://skin/'


just activate the home window before you runscript and if your trying to do this from android for any odd reason, youll need to impliment the python 2.7 version of elementtree
hope somebody elses imagination is intrigued




Reply
#2
Just a few questions... Where is all the code to move the now playing widgets if you position the main menu over their current position? What about the two widget options offered and how to handle where they go when moving the menu bar to all those different possible locations?
Reply
#3
(2017-02-27, 09:08)mikeSiLVO Wrote: Just a few questions... Where is all the code to move the now playing widgets if you position the main menu over their current position? What about the two widget options offered and how to handle where they go when moving the menu bar to all those different possible locations?

well to be honest i never finished it,in the version i was editing, i was going to manually add in my own widgets. i ended up adding quite a few things to it like background panel images added more things to color, changeable logo, sidefade, and even adjusting them. i tried to make is as customizable as possible. i even added an intro video with an overlay logo that fades in so the user could just place theirs inside. was going to be great but i'm just too busy
Reply
#4
(2017-02-27, 09:08)mikeSiLVO Wrote: Just a few questions... Where is all the code to move the now playing widgets if you position the main menu over their current position? What about the two widget options offered and how to handle where they go when moving the menu bar to all those different possible locations?

if you need any help integrating it, i'll be here
Reply
#5
bump
Reply

Logout Mark Read Team Forum Stats Members Help
Skin Editer0