• 1
  • 13
  • 14
  • 15(current)
  • 16
  • 17
  • 27
Release PyXBMCt: a Python framework for simple creating UI for XBMC addons
(2016-07-19, 17:39)ptom Wrote: one other thing i was going to ask as well is there a way to tie functions into a hover over a button? having a look around and can't see anything that would allow this

Unfortunately, Kodi does not expose such event to Python API. There is Window.onFocus method but it does not work for Python-based Window containers.
Reply
is there no way to use the xmbcgui onFocus(self, Control control) method?
Reply
(2016-07-19, 18:22)ptom Wrote: is there no way to use the xmbcgui onFocus(self, Control control) method?

I guess my post above answers your question. Maybe it works for XML-based windows, but I'm not familiar with those.
Reply
Hi Roman,

I how do I set animation to an image control?
I tried the code below but the animation does not trigger.
Code:
import resources.pyxbmct as pyxbmct

    # Create a window instance.
    window = pyxbmct.AddonDialogWindow('Hello, World!')
    # Set the window width, height and the grid resolution: 2 rows, 3 columns.
    window.setGeometry(1920, 1080, 9, 16)
    
    #image is 1200x2220
    image=pyxbmct.Image('http://i.imgur.com/lYdRVRi.png', aspectRatio=2)
    image.setAnimations([('Visible', 'effect type="zoom" end="150" center="0" time="1800"',),
                         ('Visible', 'effect type="slide" end="2220"  delay="1800" time="1800"',)])
    
    window.placeControl(image, 0, 0, 9, 16 )
    
    # Connect a key action to a function.
    window.connect(pyxbmct.ACTION_NAV_BACK, window.close)
    # Show the created window.
    window.doModal()
    # Delete the window instance when it is no longer used.
    del window

I hit a dead end with this issue with xbmcgui.WindowXML so I thought I'd give xbmcgui.Window a try.
I'm trying to display a long image like this taaall infograpgic.

I couldn't find a way to dynamically change the animation parameters with WindowXML.
Reply
I've never used advanced animation myself, but what I know for sure that all changes to a Control's properties must be done after it has been added to a Window.
Reply
Thanks, I still couldn't get it to work but there is somewhat of a reaction when I added the animation after it has been added to the window. I'll get back to it later.
Reply
Roman,

I'm currently using a List to provide scrollable content in a Dialog window.

My issue is that I can only provide a list of text to populate the List which makes the presentation a bit messy as I essentially have columns of text, as well as rows.

Is there a way to have a list where I can add, say, multiple labels in each row so I can preserve my alignment?

Thanks,

el_P
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
(2016-08-10, 20:20)el_Paraguayo Wrote: Roman,

I'm currently using a List to provide scrollable content in a Dialog window.

My issue is that I can only provide a list of text to populate the List which makes the presentation a bit messy as I essentially have columns of text, as well as rows.

Is there a way to have a list where I can add, say, multiple labels in each row so I can preserve my alignment?

Thanks,

el_P

Currently there is no Python (or rather C++ SWIG-wprapped) Grid or Table Control in Kodi. Maybe something like this can be implemented in a XML-based (skinned) GUI. I really don't know, my knowledge of Kodi skinning is rather rudimentary.
Reply
Thanks for the quick answer.

That's also beyond my skillset too!
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
Roman, next question!

How do I override the texture for a Dialog window? Basically, I just want to have a different ContentPanel.png which I could package with my addon.

Is that possible?

Thanks,

el_P

EDIT: Actually, that may the wrong file - I'm just looking to reduce overall transparency in the simplest way possible!
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
(2016-08-14, 15:06)el_Paraguayo Wrote: Roman, next question!

How do I override the texture for a Dialog window? Basically, I just want to have a different ContentPanel.png which I could package with my addon.

Is that possible?

Thanks,

el_P

EDIT: Actually, that may the wrong file - I'm just looking to reduce overall transparency in the simplest way possible!

I'm afraid there is no simple way to do that -- I haven't thought about such possibility and nobody has asked to implement it so far. Currently, I'm working (slowly) on Estuary-based design which will be standard for Krypton and above, and I'll think about adding such feature. I don't like semi-transparent ContentPanel.png either, but I borrowed design elements from Confluence "as is". BTW, in Estuary the dialog background is not transparent.
Reply
Ok. That makes sense. Thanks for letting me know.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
Hi Roman!

First of all: Thanks for the really cool framework that probably will save me lots of time developing my Addon.

My Problem:
By the moment, I play around with your "Example with interactive controls". I changed from Dialog window to the blank full screen. Now, the buttons wont work anymore Sad

Here is the code:
Code:
class MyAddon(pyxbmct.BlankFullWindow):

    def __init__(self):
        """Class constructor"""
        # Call the base class' constructor.
        super(MyAddon, self).__init__()
        # Set width, height and the grid parameters
        self.setGeometry(300, 230, 4, 2)
        # Call set controls method
        self.set_controls()
        # Call set navigation method.
        self.set_navigation()
        # Connect Backspace button to close our addon.
        self.connect(pyxbmct.ACTION_NAV_BACK, self.close)

    def set_controls(self):
        """Set up UI controls"""
        # Image control
        image = pyxbmct.Image(os.path.join(_addon_path, 'xbmc-logo.png'), aspectRatio=0, colorDiffuse='0xF0FFF0F0')
        self.placeControl(image, 0, 0, rowspan=2, columnspan=2)
        # Text label
        label = pyxbmct.Label('Your name:')
        self.placeControl(label, 2, 0)
        # Text edit control
        self.name_field = pyxbmct.Edit('')
        self.placeControl(self.name_field, 2, 1)
        # Close button
        self.close_button = pyxbmct.Button('Close')
        self.placeControl(self.close_button, 3, 0)
        # Connect close button
        self.connect(self.close_button, self.close)
        # Hello button.
        self.hello_buton = pyxbmct.Button('Hello')
        self.placeControl(self.hello_buton, 3, 1)
        # Connect Hello button.
        self.connect(self.hello_buton, lambda:
            xbmc.executebuiltin('Notification(Hello {0}!, Welcome to PyXBMCt.)'.format(
                self.name_field.getText())))

    def set_navigation(self):
        """Set up keyboard/remote navigation between controls."""
        self.name_field.controlUp(self.hello_buton)
        self.name_field.controlDown(self.hello_buton)
        self.close_button.controlLeft(self.hello_buton)
        self.close_button.controlRight(self.hello_buton)
        self.hello_buton.setNavigation(self.name_field, self.name_field, self.close_button, self.close_button)
        # Set initial focus.
        self.setFocus(self.name_field)

if __name__ == '__main__':
    gui = MyAddon()
    gui.doModal()
    del gui

Whats the matter with this? Backspace closes the window without any problems. I also read your docs, but cant find anything about this behaviour.

Thanks forward for your answer!
selli
Reply
(2016-08-22, 15:29)selli69 Wrote: My Problem:
By the moment, I play around with your "Example with interactive controls". I changed from Dialog window to the blank full screen. Now, the buttons wont work anymore Sad

Which "buttons" exactly? The example includes only one button in the bottom right corner ('Close') and it does work as all the other interactive controls. I cannot reproduce any problem with BlankFullWindow - it works as supposed.
Reply
Thanks for your quick reply!

As you can see in the code, there are TWO buttons: one hello and one close button. both of them dont work. Look at the code I posted, i promise by my mothers life, there are two buttons.. Wink I used this code from your doc

One further problem:
As playing around a little more, i added a discrete running thread, which should update the text of a label in the gui. The update works, but it seems to "overwrite" the label in graphics without clearing the previous content, so there is a mashup with all the updated texts. Is it possible to "clear" a control?

My actual code:
Code:
class MyAddon(pyxbmct.BlankFullWindow):

    def __init__(self):
        """Class constructor"""
        # Call the base class' constructor.
        super(MyAddon, self).__init__()
        # Set width, height and the grid parameters
        self.setGeometry(300, 330, 5, 2)
        # Call set controls method
        self.set_controls()
        # Call set navigation method.
        self.set_navigation()
        # Connect Backspace button to close our addon.
        self.connect(pyxbmct.ACTION_NAV_BACK, self.close)

    def set_controls(self):
        """Set up UI controls"""
        # Image control
        image = pyxbmct.Image(os.path.join(_addon_path, 'xbmc-logo.png'), aspectRatio=0, colorDiffuse='0xF0FFF0F0')
        self.placeControl(image, 0, 0, rowspan=2, columnspan=2)
        # Text label
        label = pyxbmct.Label('Your name:')
        self.placeControl(label, 2, 0)
        # Text label
        self.label2 = pyxbmct.Label('Counter')
        self.placeControl(self.label2, 5, 0, columnspan=2)
        # Text edit control
        self.name_field = pyxbmct.Edit('')
        self.placeControl(self.name_field, 2, 1)
        # Close button
        self.close_button = pyxbmct.Button('Close')
        self.placeControl(self.close_button, 3, 0)
        # Connect close button
        self.connect(self.close_button, self.close)
        # Hello button.
        self.hello_buton = pyxbmct.Button('Hello')
        self.placeControl(self.hello_buton, 3, 1)
        # Connect Hello button.
        self.connect(self.hello_buton, lambda:
            xbmc.executebuiltin('Notification(Hello {0}!, Welcome to PyXBMCt.)'.format(
                self.name_field.getText())))

    def set_navigation(self):
        """Set up keyboard/remote navigation between controls."""
        self.name_field.controlUp(self.hello_buton)
        self.name_field.controlDown(self.hello_buton)
        self.close_button.controlLeft(self.hello_buton)
        self.close_button.controlRight(self.hello_buton)
        self.hello_buton.setNavigation(self.name_field, self.name_field, self.close_button, self.close_button)
        # Set initial focus.
        self.setFocus(self.name_field)

class BackgroundTask(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        i = 0
        while 1:
            i += 1
            gui.label2 = pyxbmct.Label("Counter: %s" %i)
            gui.placeControl(gui.label2, 5, 0, columnspan=2)
            xbmc.log("counter: %s" %i)
            time.sle*p(1)


if __name__ == '__main__':
    gui = MyAddon()

    bgthread = BackgroundTask()
    bgthread.start()



    gui.doModal()
    del gui

i have seen, that following message is in the logfile:

Code:
16:09:59 T:140716885931776   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.AttributeError'>
                                            Error Contents: 'MyAddon' object has no attribute 'window_close_button'
                                            Traceback (most recent call last):
                                              File "/home/hal/.kodi/addons/script.module.pyxbmct/lib/pyxbmct/addonwindow.py", line 755, in onControl
                                                if control == self.window_close_button:
                                            AttributeError: 'MyAddon' object has no attribute 'window_close_button'
                                            -->End of Python script error report<--
Reply
  • 1
  • 13
  • 14
  • 15(current)
  • 16
  • 17
  • 27

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