Kodi Community Forum
GUI Builder - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: GUI Builder (/showthread.php?tid=21315)

Pages: 1 2 3


GUI Builder - Nuka1195 - 2006-08-01

This module allows you to skin your python scripts with a standard XBMC skinfile.xml.
You may pass a dialog and a percent finished as a continuation for your scripts initialization.

It creates a dictionary of your controls, with the controls <id> as the key (self.controls{id : control}).
It also creates a dictionary of visibilty conditions, with the controls <id> as the key
(self.visibility{id : condition}).
e.g. self.controls[300].setVisible(xbmc.getCondVisibility(self.visibility[300]))

It creates a dictionary of your controls positions in a tuple, with the controls <id> as the key
(self.positions{id : (x, y)}).
It also creates a list variable for a coordinates based window (self.coordinates[x, y]).
e.g. self.controls[300].setPosition(self.positions[300][0] + self.coordinates[0], self.positions[300][1] + self.coordinates[1])

The Includes & references functions were translated from Xbox media center's source, thanks Developers.
A special thanks to elupus for shaming me into doing it the right way. Smile

Nuka1195

Usage:
Code:
import  guibuilder
guibuilder.GUIBuilder(win, SkinXML[, ImagePath, title, line1, dlg, pct])

win          : Your window or windowdialog class. passed as self.
SkinXML          : The xml file including path you want to use.
ImagePath      : [opt] The path to any custom images. If you precede the
               texture with a \ in the xml, it will use the ImagePath.
               Do not include the ending \ in ImagePath.
               <texture>\button.png</texture> will use ImagePath.
title               : [opt] Title you want to use for the progress dialog.
line1              : [opt] The first line of the progress dialog.
dialog             : [opt] A current progress Dialog, If passed can be used
                      as a continuation of your script intialization.
pct                : [opt] The percent already completed.

get "guibuilder.py" module and an example "GUI Builder.zip" http://xbmc.cvs.sourceforge.net/xbmc/XBMC/scripts/

The zip contains examples of a Window and a WindowDialog.

This module requires a build with the xbmc.getCondVisibility() method added July 27th.

Animations are ignored. Not all conditional visibilty tags work with python. (e.g. Control.HasFocus(id) and Control.IsVisible(id))

It uses the location of the includes.xml file it finds as the source for setCoordinateResolution(), This may have to change.


- SleepyP - 2006-08-01

thats freaking awesome!


- trignum5 - 2006-08-02

Alot of times ppl spend outrageous amounts of time working on classes etc thats 'supposed' to save time in the long run.. I think you actually succeeded.. Nice work..


- smuto - 2006-08-02

Can u change default folder location for "guibuilder.py" module to 'XBMC/python/Lib' ?


- smuto - 2006-08-02

1 'XBMC/python/Lib' - one module for every script, always up to date

2 Info dialogs - IMHO this is a tool, print to python log is enough


- Nuka1195 - 2006-08-02

1. Smile I've had this discussion with other people. I agree one copy in a single location, but it makes it harder to install the script. All you have to do is put it in XBMC/python/Lib and remove it from your extras folder and it should find it.

2. Do you mean no progress dialogs? It's fast enough that it might not appear to freeze, but i like knowing what's going on. or did you mean the one ok dialog, if there was an error? I could add a silent option that if True wouldn't display dialogs or maybe if fastMethod was True?

Update: I added resolve includes for <include> tags outside a control block. A fastMethod option, if set to True, it won't use includes.xml or references.xml. Slight speed improvement if your skins won't use <include> tags and all necessary tags are set. Fixed some bugs, added more checks for a valid skin file and change some code to work more like XBMC's source. Also added some more function credits at the top of the file.


- Nuka1195 - 2006-08-02

Ok, if fastMethod = True then no dialogs.

This also disables the includes.xml and references.xml.

The problem is I use the location of the includes.xml as a basis for determining the coordinateresolution. The problem with that is the skinner has no control.

What if I add a <resolution>resolution</resolution> tag to the skin.xml. I didn't want to add extra tags, but... The problem with this is if it finds the includes.xml in a different resolutions folder, things won't line up? That may not be a problem, since I imagine if your skinning for a specific skin, you would use an already skinned resolution?

Any suggestions?


- HarshReality - 2006-08-02

Going to sound like a dweeb but I'm looking forward to some brave soul sitting down and trying a tutorial on "how to" ffrom starting this up to shutting it down! God (he doesnt seem to like me) knows there are some skins I'd love to give a spin with this!


- Nuka1195 - 2006-08-03

@HarshReality, Don't the examples help. I'm terrible at explaining things.

Added: <resolution> optional tag, so now the skinner can have complete control. options are '1080i', '720p', '480p', '480p16x9', 'ntsc', 'ntsc16x9', 'pal', 'pal16x9', 'pal60', 'pal6016x9'

GetConditionalVisibility(), GetSkinPath(), LoadReferences(), LoadIncludes(), ResolveInclude()
The above functions were translated from Xbox Media Center's source, thanks Developers.

Edit: Also moved the getCondVisibilty() check to the end of the try block. Now it should'nt error even without a newer build, though <visible> tags won't work. Also changed the keyword arguments to be similar.

Code:
import  guibuilder
guibuilder.GUIBuilder(win, skinXML[, imagePath, title, line1, dlg, pct, fastMethod])

win        : Your window or windowdialog class. passed as self.
skinXML        : The xml file including path you want to use.
imagePath    : [opt] The path to any custom images. If you precede the
        texture with a \ in the xml, it will use the imagePath.
        Do not include the ending \ in imagePath.
        <texture>\button.png</texture> will use imagePath.
title        : [opt] Title you want to use for the progress dialog.
line1        : [opt] The first line of the progress dialog.
dialog        : [opt] A current progress Dialog, If passed can be used
        as a continuation of your script intialization.
pct        : [opt] The percent already completed.
fastMethod    : [opt] No dialogs, No <include> and
        doesn't use references.xml.



- HarshReality - 2006-08-03

The examples are clear enough if you know what your using it for/with to begin with. Is it a computer app or am I just making a script shortcut and then selecting a script to modify and moving things around.........


- smuto - 2006-08-03

some_control_test

please make the example help

What i'm making wrong?

pal - skinning resolutions
720p - runing


- Nuka1195 - 2006-08-03

What skin are you using?

In PM III it looks fine on 720p except, the label controls need a <width> tag since there isn't one in the references.xml file.

The list looks fine. Some controls just are not supported in python. Is that what you mean?

if you want to set the resolution to PAL just add it before the <controls> block.
<defaultcontrol>50</defaultcontrol>
<resolution>PAL</resolution>

Sorry don't understand what you need. It looks fine except for the <width> tags needed for the label controls.


- Nuka1195 - 2006-08-03

@Harsh, You use this to help create a new script. It allows easier skinning, but requires the use of self.controls{} as your control. So adding this to an existing script may or may not be hard.

Sorry, that's the best I can explain. Smile


- smuto - 2006-08-04

It allows easier skinning Nod - it's true, thx a lot


- smuto - 2006-09-16

@feature Suggestions
Script Installer - with GUI Builder for XBMC 2.0.0
guibuilder.py - default directory in CVS - 'XBMC/python/Lib' - for XBMC 2.0.0