• 1
  • 8
  • 9
  • 10(current)
  • 11
  • 12
  • 27
Release PyXBMCt: a Python framework for simple creating UI for XBMC addons
(2014-12-22, 13:50)Roman_V_M Wrote: 2 MGA1500

I'm glad that your experiments are successful.Smile

However, I take back my comments about the parent window needs to be closed before opening a child window. According to my quick experiments, a child window can be opened on top of the parent. The only problem I see that since the windows have semi-transparent background you can see the parent window through the child. But, as I said, I took ready-made textures from Confluence skin because my graphic skills are very limited.
But I've done only some brief experiments and do not guarantee that problems with window priorities won't happen. Closing the parent window seems to be a safe option.

Hi Roman,

I repeated your experiment and indeed it seems possible. There is a slight improvement in reaction time as the closewindow animation does not need to be performed. A non-transparent background should suffice to completely hide the main window. Personally I do not like transparent addon windows (eg openelec configuration settings addon) but that may be just me ;-)
It is tricky to rely on untested window priorities, in that sense better safe than sorry and closing the main window first. For the time being I will comment-out the close window with a good remark on the risk!

Having another question now, building further on the addon: pyXBMCt does not have a 'browse-to-a-file' dialog, does it? If so I will use the regular xbmcgui class Dialog.Browse for that...

Regards, MGA
Reply
(2014-12-22, 14:31)MGA1500 Wrote: I repeated your experiment and indeed it seems possible. There is a slight improvement in reaction time as the closewindow animation does not need to be performed.

Animation is absolutely optional. Personally, I never use it in my projects. The respective method in base classes does nothing (contains single pass) directive) and has been created only to be implemented in child classes, if you need some animation effects. In strongly typed languages, like C#, such methods are called "virtual", but in Python all methods are virtual.

Quote:A non-transparent background should suffice to completely hide the main window. Personally I do not like transparent addon windows (eg openelec configuration settings addon) but that may be just me ;-)
If somebody provides me a non-transparent texture for window background, with color and look consistent with Confluence skin, I will gladly replace the default background texture.

Quote:Having another question now, building further on the addon: pyXBMCt does not have a 'browse-to-a-file' dialog, does it? If so I will use the regular xbmcgui class Dialog.Browse for that...

PyXBMCt classes are just wrappers around Window, WindowDialog and Control classes of xbmcgui modules. For simple utility tasks Dialogs are optimal choice.
BTW, this is a standard approach for most (if not all) major GUI frameworks. File/directory selection dialogs and simple pop-up dialogs (OK, OK/Cancel etc.) are implemented as separate classes, independent of a base widget toolkit.
Reply
(2014-12-22, 17:13)Roman_V_M Wrote:
(2014-12-22, 14:31)MGA1500 Wrote: I repeated your experiment and indeed it seems possible. There is a slight improvement in reaction time as the closewindow animation does not need to be performed.

Animation is absolutely optional. Personally, I never use it in my projects. The respective method in base classes does nothing (contains single pass) directive) and has been created only to be implemented in child classes, if you need some animation effects. In strongly typed languages, like C#, such methods are called "virtual", but in Python all methods are virtual.

Quote:A non-transparent background should suffice to completely hide the main window. Personally I do not like transparent addon windows (eg openelec configuration settings addon) but that may be just me ;-)
If somebody provides me a non-transparent texture for window background, with color and look consistent with Confluence skin, I will gladly replace the default background texture.

Quote:Having another question now, building further on the addon: pyXBMCt does not have a 'browse-to-a-file' dialog, does it? If so I will use the regular xbmcgui class Dialog.Browse for that...

PyXBMCt classes are just wrappers around Window, WindowDialog and Control classes of xbmcgui modules. For simple utility tasks Dialogs are optimal choice.
BTW, this is a standard approach for most (if not all) major GUI frameworks. File/directory selection dialogs and simple pop-up dialogs (OK, OK/Cancel etc.) are implemented as separate classes, independent of a base widget toolkit.

Roman,

I have just changed the ContentPanel.png so that it is black on the inside of the border and remains the typical confluence transparancy outside of the border. Looks nice now! How would you prefer me getting the .png to you?

Will try to get rid of animation!

MGA

Regards, MGA
Reply
(2014-12-22, 18:44)MGA1500 Wrote: Roman,

I have just changed the ContentPanel.png so that it is black on the inside of the border and remains the typical confluence transparancy outside of the border. Looks nice now! How would you prefer me getting the .png to you?

Will try to get rid of animation!

MGA

Regards, MGA

Please upload the .png to some file-sharing service, like Dropbox or similar.

Regarding animation, simply remove setAnimation() method from your class. I included it in PyXBMCt Demo simply as an example of implementation, because somebody in this topic asked about this. It's not necessary to put it in your add-ons. As I've said, I don't.Smile
Reply
Roman_V_M,

The dialogwindow that I create using pyxbmct is semi transparent. How do I set it to more tranparency? In xbmc class, there's a ControlImage class with setDiffuse method to set the transparency, but I can't figure out how to apply that to pyxbmct window. Any help would be appreciate.
Reply
(2015-01-02, 22:35)Gameforus Wrote: Roman_V_M,

The dialogwindow that I create using pyxbmct is semi transparent. How do I set it to more tranparency? In xbmc class, there's a ControlImage class with setDiffuse method to set the transparency, but I can't figure out how to apply that to pyxbmct window. Any help would be appreciate.

According to docs, there is no setDiffuse method. Could you explain what you mean?
In any case, PyXBMCt sources are available and you can see what objects are responsible for different window elements (background, header, etc). Since Python classes have no real 'private' attributes, you can change any property for any attribute in your child class.
As for window background, this is self.background_img attribute of a base container class.
Reply
http://mirrors.xbmc.org/docs/python-docs...ntrolImage

Methods defined here:

setColorDiffuse(...)
setColorDiffuse(colorDiffuse)--Changes the images color.

colorDiffuse : hexString - (example, '0xC0FF0000' (red tint))

example:
- self.image.setColorDiffuse('0xC0FF0000')

Is there away to do something like this with pyxbmct?
Reply
(2015-01-03, 04:02)Gameforus Wrote: Is there away to do something like this with pyxbmct?

*sighs*
I've written about over 9000 times that PyXBMCt is simply a wrapper around xbmcgui classes and can do no more and no less than xbmcgui classes and their methods. So you don't need any special "way" to use xbmcgui capabilities with PyXBMCt.
Reply
Roman,

Apologies if this is a stupid question but I need a bit of help.

I'm creating a dialog with a list item and I'd like to be able to set the size of the dialog depending on the number of elements in the list. The issue I'm finding is that I can't work out the sizes of the various components in the dialog. i.e. to create the dialog I need to know the size of:
1) The title bar;
2) Each list element; and
3) My "Close" button at the bottom.

#3 is ok because that seems to resize easily enough. However, #2 is the one that's a bit odd as it looks like the list items have a fixed size independent of the rowspan option. Therefore, if I get the wrong height for the List object then there may be a substantial gap between the List and the button that looks unsightly.

Are you able to let me know what the sizes of #1 and #2 are (or how I can find this out)?

Many thanks,

el_P
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
This post can be ignored as I've solved the problem but have left it here in case anyone has the same issues.

Also getting a strange error when I try to set the colorKey for an image:
Code:
Image(imagedict[m[1]], colorKey="0xFFFF33FF")
gives me
Code:
File "/home/elParaguayo/.kodi/addons/script.module.pyxbmct/lib/pyxbmct/addonwindow.py", line 150, in __new__
                                                return super(Image, cls).__new__(cls, -10, -10, 1, 1, *args, **kwargs)
                                            TypeError: 'colorKey' is an invalid keyword argument for this function
Probably me being stupid but both the pyxbmct and xbmc docs suggest that this is the correct keyword argument.

Any ideas?

EDIT: Hmm, looks like this was actually removed many many years ago - so I guess the docs just haven't been updated. See this: http://forum.kodi.tv/showthread.php?tid=...#pid302383

This leaves me with the problem that the transparent colour in my PNG is showing as red in the Image object.

EDIT 2: Solved the red issue by changing the PNG file from being indexed to RGB in Gimp.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
(2015-01-03, 15:27)el_Paraguayo Wrote: Roman,

Apologies if this is a stupid question but I need a bit of help.

I'm creating a dialog with a list item and I'd like to be able to set the size of the dialog depending on the number of elements in the list. The issue I'm finding is that I can't work out the sizes of the various components in the dialog. i.e. to create the dialog I need to know the size of:
1) The title bar;
2) Each list element; and
3) My "Close" button at the bottom.

#3 is ok because that seems to resize easily enough. However, #2 is the one that's a bit odd as it looks like the list items have a fixed size independent of the rowspan option. Therefore, if I get the wrong height for the List object then there may be a substantial gap between the List and the button that looks unsightly.

Are you able to let me know what the sizes of #1 and #2 are (or how I can find this out)?

Many thanks,

el_P

Regarding List, indeed its height may be slightly less than the total height of rows it should occupy (rowspan). I don't know why it happens.

As for the window header height, naturally, it can be found in PyXBMCt sources: https://github.com/romanvm/PyXBMCt/blob/...ow.py#L566 (it's 35).
All window elements are xbmcgui Controls, and their parameters can be found through respective methods:
https://github.com/romanvm/xbmcstubs/blo...ui.py#L500
https://github.com/romanvm/xbmcstubs/blo...ui.py#L527
And PyXBMCt Controls are still the same xbmcgui Controls with all their methods.

Again, PyXBMCt is totally and completely based on xbmcgui module, and all info in xbmcgui docs is valid and can be used here.
Reply
Thanks Roman. That's really helpful.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
Roman, thanks for this - it has really simplified my code!


Questions for anyone in the know (I'm suspecting this is more xbmcgui/kodigui though):

- Are font sizes adjustable? Per label?
I want to create heading/sub-heading text labels, which would need to be larger than the content text.

- Are objects destroyable?
(Note: this is a nice-to-know - not important. I've adjusted my code to create dedicated controls)
self.removeControl supposedly just hides the control - so doing this many times would just fill memory.
In testing, using self.removeControl appears fine, but I did get Kodi to crash once!

- Are there caveats for using a dense grid?
I have set my grid as 100 x 100, but will probably increase this 200 x 200. What issues are there likely to be?
The example grid is far smaller (9 x 4).


Regards.
Reply
(2015-01-07, 13:00)CiscoKid Wrote: - Are font sizes adjustable? Per label?
I want to create heading/sub-heading text labels, which would need to be larger than the content text.

Unfortunately, custom fonts for addons are not supported by XBMC/Kodi. This is a long waited feature by add-on developers.

Quote:- Are objects destroyable?
(Note: this is a nice-to-know - not important. I've adjusted my code to create dedicated controls)
self.removeControl supposedly just hides the control - so doing this many times would just fill memory.
In testing, using self.removeControl appears fine, but I did get Kodi to crash once!

Not sure what you mean, but what about calling an object destructor explicitly with del?

Quote:- Are there caveats for using a dense grid?
I have set my grid as 100 x 100, but will probably increase this 200 x 200. What issues are there likely to be?
The example grid is far smaller (9 x 4).

I've never tested such large grid but in theory there shouldn't be any problems.
Reply
I feel kinda dumb, can someone help me, I've been learning python over the last week or so and have made some scripts that I'd like to be able to launch from a menu of some sort. I feel like I have almost made it but I'm really stuck. After lots of searching/trial and error, this is what I've come up with:

Code:
import os
import xbmc
import xbmcaddon
import pyxbmct.addonwindow as pyxbmct

_addon = xbmcaddon.Addon()
_addon_path = _addon.getAddonInfo('path')


class MyAddon(pyxbmct.AddonDialogWindow):

    def __init__(self, title=''):
        super(MyAddon, self).__init__(title)
        self.setGeometry(500, 450, 9, 4)
        self.set_active_controls()
        self.set_navigation()
        self.connect(pyxbmct.ACTION_NAV_BACK, self.close)


    def set_active_controls(self):
        self.list = pyxbmct.List()
        self.placeControl(self.list, 0, 0, 15, 4)
        items = ['Item {0}'.format(i) for i in range(1, 8)]
        self.list.addItems(items)
        self.connect(self.list, lambda: xbmc.executebuiltin('Notification(Note!,{0} selected.)'.format(
            self.list.getListItem(self.list.getSelectedPosition()).getLabel())))
        self.connectEventList(
            [pyxbmct.ACTION_MOVE_DOWN,
             pyxbmct.ACTION_MOVE_UP,
             pyxbmct.ACTION_MOUSE_WHEEL_DOWN,
             pyxbmct.ACTION_MOUSE_WHEEL_UP,
             pyxbmct.ACTION_MOUSE_MOVE],
            self.list_update)
        self.button = pyxbmct.Button('Close')
        self.placeControl(self.button, 8, 3)
        self.connect(self.button, self.close)


    def set_navigation(self):
        self.setFocus(self.list)

    def list_update(self):
        try:
            if self.getFocus() == self.list:
                self.list_item_label.setLabel(self.list.getListItem(self.list.getSelectedPosition()).getLabel())
            else:
                self.list_item_label.setLabel('')
        except (RuntimeError, SystemError):
            pass

    def setAnimation(self, control):
        control.setAnimations([('WindowOpen', 'effect=fade start=0 end=100 time=500',),
                                ('WindowClose', 'effect=fade start=100 end=0 time=500',)])


if __name__ == '__main__':
    window = MyAddon('Scripts')
    window.doModal()

most, if not all should be familular as it was mostly taken from an example I found, I've tried and tried though and I just can't seem to figure out for myself how to use this code for my purpose.. all I want is a simple menu that launches external scripts.. I had no idea it was this hard.. I've tried other examples that didn't even highlight the selected option..

anyways, can some kind person explain to me how I can customize the options, can I enter plain text titles somehow, and then explain how I can get certain code to run if that item is selected.. ie..

menu text 1 > xbmc.executebuiltin('XBMC.RunScript(/script1.py)')
menu text 2 > xbmc.executebuiltin('XBMC.RunScript(/script2.py)')
menu text 3 > xbmc.executebuiltin('XBMC.RunScript(/script3.py)')

thanks very much Wink
Reply
  • 1
  • 8
  • 9
  • 10(current)
  • 11
  • 12
  • 27

Logout Mark Read Team Forum Stats Members Help
PyXBMCt: a Python framework for simple creating UI for XBMC addons4