Kodi Community Forum
Release PyXBMCt: a Python framework for simple creating UI for XBMC addons - 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: Release PyXBMCt: a Python framework for simple creating UI for XBMC addons (/showthread.php?tid=174859)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Roman_V_M - 2017-07-02

@ Wimpie

I never tested that many controls, but if the number of Python-based controls is indeed the bottleneck, you could try a different approach, e.g. XML-based UI.

As for some busy dialog, you may look at this: https://codedocs.xyz/xbmc/xbmc/group__python___dialog_busy.html


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Wimpie - 2017-07-03

I'll try the busy dialog.

I like you framework. I now know how to use it (for my purpose), so I'd prefer not to learn again something new if it's not needed.

Thanks


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Roman_V_M - 2017-07-03

@Wimpie

Thanks, But, as I stressed many times, PyXBMCt is only a thin wrapper for xbmcgui so it's limited by Kodi Python API implementation.


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Wimpie - 2017-07-04

Hi Roman,

I'm unable to set a background image (using v17.3, win7, png file, size is 1280x720) for my window. I don't get any (clear to me) error message, but the background also gets no background image. Something is wrong...


This is a snippet of my init code:
Code:
class BIUinfo_Builder_Window(pyxbmct.AddonFullWindow):

    def __init__(self, title=''):

        # You need to call base class' constructor.
        super(BIUinfo_Builder_Window, self).__init__(title)
        # Set the window width, height and the grid resolution.
        self.setGeometry(1280, 720, 17, 16)
        # image located at:
        my_image = xbmc.validatePath(ADDONPATH + '/resources/media/t.png')
        log("my_image = %s" % my_image)
        self.setBackground(my_image)
        
        self.create_add_mpls_controls()

I'm sure the path to t.png is correct, I get this in my Kodi.log:
Code:
10:59:40.338 T:1868   DEBUG: ------ Window Init (DialogConfirm.xml) ------
10:59:40.338 T:1868    INFO: Loading skin file: DialogConfirm.xml, load type: KEEP_IN_MEMORY
10:59:40.426 T:1868   DEBUG: Bluray iso utils: my_image = C:\Users\Max Renn\AppData\Roaming\Kodi\addons\script.service.bluray_iso_utils\resources\media\t.png
10:59:44.272 T:1868   DEBUG: Bluray iso utils: user_language = vls
10:59:48.265 T:1196   DEBUG: Activating window ID: 0
10:59:48.265 T:1196   ERROR: Unable to locate window with id -10000.  Check skin files
10:59:48.277 T:1196   DEBUG: Activating window ID: 13000
10:59:48.515 T:1196   DEBUG: ------ Window Deinit (DialogConfirm.xml) ------

ERROR: Unable to locate window with id -10000. Check skin files

This line comes a little bit later (but before the window is displayed). I first thought this was connected to my problem, but I still get this error if I disable the background line (#self.setBackground(my_image)).

I am at a loss, again.

What am I doing wrong? Does it work for you?

Thanks!


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Roman_V_M - 2017-07-04

@Wimpie

I cannot reproduce your error. Modified pyxbmct.demo addon with the following code (the relevant fragment):

Code:
back = os.path.join(_addon.getAddonInfo('path').decode('utf-8'), 'bbb-splash.jpg')


class MyAddon(pyxbmct.AddonFullWindow):

    def __init__(self, title=''):
        super(MyAddon, self).__init__(title)
        self.setGeometry(700, 450, 9, 4)
        self.setBackground(back)
        self.set_info_controls()
        self.set_active_controls()
        self.set_navigation()
        # Connect a key action (Backspace) to close the window.
        self.connect(pyxbmct.ACTION_NAV_BACK, self.close)

works perfectly.


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Wimpie - 2017-07-06

Then something is wrong with my code.

Thanks.


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Livin - 2017-07-14

@Roman_V_M

I'm not a skinner but would like to do something I hope is easy, and I hope you can guide me.

I have an automation app that sends Kodi messages for on-screen notifications.

Would it be possible to have that app send data that Kodi would display as an on-screen menu/selection - then Kodi would send back the 'answer'?

I'm not versed in JSON so here's my lame attempt at an example JSON dataset going from the app to Kodi...

{"menu":[
{ "option":"Turn on Switch", "ReturnData":"RefID|23" },
{ "option":"Turn off Switch", "ReturnData":"RefID|44" },
{ "option":"Cancel", "CloseMenu":"Kodi_close_dialog_command" },
]}


thx for your help!


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Roman_V_M - 2017-07-14

@Livin

I'm not a skinner too, that is why I chose Python-based solution. As I understand, you need to dynamically create a UI based on JSON request and send back some data based on user interaction. I guess, technically it is possible but it will be a quite complex application (addon), especially for a beginner.


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Wimpie - 2017-07-16

Hi Roman,

About setting a background image. It also works for me.

Image

But I didn't understand the picture would come there. I have a window that is as big as the screen, so I didn't see the background picture.

What I would like, is to place a background picture behind all the controls, iow, within the marked area.

The background picture would be visible on any location not occupied by a control.

Is this possible?

PS: Atm I'm using an image control, as big as the screen, and put all controls on top of this image. This sorta works.

Image

I hope z-order is related to creation order of the controls, so that if I create the background image first, it will always stay on the bottom (but doesn't seem to be the case).

How can I make sure a imagecontrol always stays at the bottom?

How do I change the picture of an existing imagecontrol?


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Roman_V_M - 2017-07-16

@Wimpie If you need to replace the dialog background you should have said so. To replace the dialog background you can override Skin class: http://romanvm.github.io/script.module.pyxbmct/skins.html

Your method with adding an Image Control with background image is OK, but I doubt that Pythonic Controls have zorder. Normally, Controls that have been added later are displayed on top of ones that have been added earlier (if their coordinates overlap). This is how PyXBMCt dialogs are created - a couple of images and a close button are added first.

Also all PyXBMCt Controls are descendants of xbmcgui Controls so all their methods work here.

If you need fully customized appearance, you can look at *Blank* that have no visual elements of their own.


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Wimpie - 2017-07-16

Hi Roman,

I'm stuck.

I am trying to use your skin example. BTW is it possible that the line:

"pyxbct.skin = MySkin()" needs to be
"pyxbmct.skin = MySkin()" ?


Code:
import os
import xbmc
import xbmcaddon
import pyxbmct

_addon = xbmcaddon.Addon()
back = os.path.join(_addon.getAddonInfo('path').decode('utf-8'), 'bbb-splash.jpg')

class MySkin(pyxbmct.Skin):
    @property
    def main_bg_img(self):
        return back


pyxbmct.skin = MySkin()


class MyAddon(pyxbmct.skin):

    def __init__(self):
        self.setGeometry(700, 450, 9, 4)
        # Set extra button for other window
        self.extra_button = pyxbmct.Button('other window')
        self.placeControl(self.extra_button, 9, 0)
        

if __name__ == '__main__':

    window = MyAddon()
    window.doModal()

    os.sleep(5000)
    del window

This is my latest attempt, but I tried some other things also. I always get an exception:

Code:
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.TypeError'>
                                            Error Contents: Error when calling the metaclass bases
                                                __init__() takes exactly 1 argument (4 given)
                                            Traceback (most recent call last):
                                              File "C:\Users\Max Renn\AppData\Roaming\Kodi\addons\script.service.bluray_iso_utils\testtscript.py", line 18, in <module>
                                                class MyAddon(pyxbmct.skin):
                                            TypeError: Error when calling the metaclass bases
                                                __init__() takes exactly 1 argument (4 given)
                                            -->End of Python script error report<--

I don't see where I'm passing 4 arguments...

I'm almost embarrassed to ask, but could you show a minimal working example? It seems my python OOP knowledge is lacking...

Thanks


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Livin - 2017-07-17

(2017-07-14, 08:37)Roman_V_M Wrote: @Livin

I'm not a skinner too, that is why I chose Python-based solution. As I understand, you need to dynamically create a UI based on JSON request and send back some data based on user interaction. I guess, technically it is possible but it will be a quite complex application (addon), especially for a beginner.
can your framework do any of this?

Sent from my SAMSUNG-SM-G935A


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Roman_V_M - 2017-07-17

@Wimpie

First, thank you for spotting a typo in the docs. I'll fix that immediately.

The problem is that you are overthinking this. After you have patched the module-level skin variable, you use PyXBMCt normally as you did before. You don't need to invent stuff like this
Code:
class MyAddon(pyxbmct.skin)
which is an invalid Python statement by definition because you are trying to inherit from a non-type object.

Also consult API docs: http://romanvm.github.io/script.module.pyxbmct/_autosummary/pyxbmct.addonskin.html#module-pyxbmct.addonskin
to see which property is responsible for which element.


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - Roman_V_M - 2017-07-17

@Livin

Quote:can your framework do any of this?

Showing a UI - yes, but your task goes way beyond that. You need to create some REST API to receive requests and send replies, and the part that translate a JSON request into a dynamic UI. This you'll have to implement yourself.


RE: PyXBMCt: a Python framework for simple creating UI for XBMC addons - prozasmoothie - 2017-08-17

Hi;

I want to video player plugin without using skin.I looked your plugin.video.example (video player addon)Roman.You used kodi skin.Your methods derived from xbmcgui class.is that possible to write video plugin with using the pyxbmct without using Kodi's skin?