Kodi Community Forum

Full Version: PyXBMCt: a Python framework for simple creating UI for XBMC addons
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Seems to be the second method on this page: http://romanvm.github.io/xbmcstubs/docs/...class.html

(PyXBMCt is essentially a wrapper for the xbmcgui control hence the references in the PyXBMCt docs to "inheriting" properties/methods from the class I referred to above.)
Is there any way to have a AddonDialogWindow auto close after a set period of time?

I would like to display a notification box but would like the addon to continue what it's doing behind it, so doing something like using .show() then setting a delay and then closing the window won't quite work as it will hold up the addon

An option is to open it in it's own thread but requires some extra code that could be a bit of a pain to implement

So was hoping there could be an option (possible feature request?) where you could connect to the window a 'timer' type object

eg.
Code:
timer = pyxbmct.Timer(3000)
window.connect(timer, window.close)
(2015-09-02, 22:12)Eldorado Wrote: [ -> ]Is there any way to have a AddonDialogWindow auto close after a set period of time?

I would like to display a notification box but would like the addon to continue what it's doing behind it, so doing something like using .show() then setting a delay and then closing the window won't quite work as it will hold up the addon

An option is to open it in it's own thread but requires some extra code that could be a bit of a pain to implement

So was hoping there could be an option (possible feature request?) where you could connect to the window a 'timer' type object

eg.
Code:
timer = pyxbmct.Timer(3000)
window.connect(timer, window.close)

As it's said just one message above yours PyXBMCt is essentially a wrapper for several xbmcgui classes. So the answer is no: it can do only as much as Kodi API allows and WindowDialog class (a parent class of AddonDialogWindow) does not have such feature.
As for connection, again, essentially you can connect only events generated by Kodi itself (key presses and on-screen Controls activation), not custom events.

So I guess, to close your window after a specified amount of time without blocking UI you need to run some wait timer in a separate thread and then execute .close() when the timeout expires.
Hi Roman, could I trouble you for some advice?

I have a snippet of my code below.. I'm trying to use lists, sliders and radiobuttons, the list and sliders work fine but I can't seem to be able to toggle the radio buttons via mouse (or touchscreen I suspect) the only way I can manage to do it is via keyboard.. can you point out where I've gone wrong and show me how I can get the radiobuttons to repsond to mouse actions, I've tried fiddling with window.connectEventList areas but all I've managed to accomplish is breaking the other controls. Thanks for any help.

Code:
import pyxbmct.addonwindow as pyxbmct
import xbmc, xbmcaddon, xbmcgui, xbmcplugin


window = pyxbmct.AddonDialogWindow('')
window.setGeometry(1240, 650, 300, 160)



def radio1_update():

    
    if radiobutton1.isSelected():
        radiobutton2.setSelected(False)
        radiobutton3.setSelected(False)
        radiobutton4.setSelected(False)

    else:
        radiobutton1.setSelected(True)

def radio2_update():    

        
    if radiobutton2.isSelected():
        radiobutton1.setSelected(False)
        radiobutton3.setSelected(False)
        radiobutton4.setSelected(False)    

    else:
        radiobutton2.setSelected(True)
        
def radio3_update():

    
    if radiobutton3.isSelected():
        radiobutton1.setSelected(False)
        radiobutton2.setSelected(False)
        radiobutton4.setSelected(False)    

    else:
        radiobutton3.setSelected(True)
        
def radio4_update():

        
    if radiobutton4.isSelected():
        radiobutton1.setSelected(False)
        radiobutton2.setSelected(False)
        radiobutton3.setSelected(False)    

    else:
        radiobutton4.setSelected(True)
        
        
        


        
        
def list_update():

    try:
        if window.getFocus() == slider1:
        
            # do things
            pass
        
    except:
        pass    
        
        
    
    
    try:
        if window.getFocus() == slider2:
                
            # do things
            pass
        
    except:
        pass    
        

    
    
    try:
        if window.getFocus() == slider3:
        
            # do things
            pass

    except:
        pass    
    
    
    

    try:
        if window.getFocus() == listitem1:
        
            #do things
            pass
                    
            
        else:
            pass
    except:
        pass

            




#################### S L I D E R S ########################################




# Slider value label
SLIDER1_INIT_VALUE = 100


# Slider
global slider1
slider1 = pyxbmct.Slider()
window.placeControl(slider1, 180, 90, 25, 60)
slider1.setPercent(SLIDER1_INIT_VALUE)
slider1.setVisible(True)
#Connect key and mouse events for slider update feedback.
window.connectEventList([pyxbmct.ACTION_MOVE_LEFT,
                       pyxbmct.ACTION_MOVE_RIGHT,
                       pyxbmct.ACTION_MOUSE_DRAG,
                       pyxbmct.ACTION_MOUSE_LEFT_CLICK],
                      list_update)



################ slider 2




# Slider value label
SLIDER2_INIT_VALUE = 50


# Slider
global slider2
slider2 = pyxbmct.Slider()
window.placeControl(slider2, 270, 90, 25, 60)
slider2.setPercent(SLIDER2_INIT_VALUE)
slider2.setVisible(True)
#Connect key and mouse events for slider update feedback.
window.connectEventList([pyxbmct.ACTION_MOVE_LEFT,
                       pyxbmct.ACTION_MOVE_RIGHT,
                       pyxbmct.ACTION_MOUSE_DRAG,
                       pyxbmct.ACTION_MOUSE_LEFT_CLICK],
                      list_update)





################### R A D I O   B U T T O N S #################################





radiobutton1 = pyxbmct.RadioButton('1')
window.placeControl(radiobutton1, 458, 25, 10, 12)
window.connect(radiobutton1, radio1_update)
radiobutton1.setVisible(True)


radiobutton2 = pyxbmct.RadioButton('2')
window.placeControl(radiobutton2, 458, 37, 10, 12)
window.connect(radiobutton2, radio2_update)
radiobutton2.setVisible(True)

radiobutton3 = pyxbmct.RadioButton('3')
window.placeControl(radiobutton3, 458, 49, 10, 12)
window.connect(radiobutton3, radio3_update)
radiobutton3.setVisible(True)

radiobutton4 = pyxbmct.RadioButton('4')
window.placeControl(radiobutton4, 458, 61, 10, 12)
window.connect(radiobutton4, radio4_update)
radiobutton4.setVisible(True)


########################################################################




listitem1 = pyxbmct.List('font14', '', _space=5, _itemHeight=35, _alignmentY=6)
window.placeControl(listitem1, 110, 3, 470, 65)
listitem1.setVisible(True)
window.connect(listitem1, lambda: window.setFocus(listitem1))



listitem1.addItem('1')
listitem1.addItem('2')
listitem1.addItem('3')
listitem1.addItem('4')


listitem1.controlDown(radiobutton1)
radiobutton1.controlUp(listitem1)
radiobutton1.controlRight(radiobutton2)
radiobutton2.controlLeft(radiobutton1)
radiobutton2.controlRight(radiobutton3)
radiobutton3.controlLeft(radiobutton2)
radiobutton3.controlRight(radiobutton4)
radiobutton4.controlLeft(radiobutton3)




window.connectEventList(
    [pyxbmct.ACTION_MOVE_DOWN,
    pyxbmct.ACTION_MOVE_UP,
    pyxbmct.ACTION_MOUSE_WHEEL_DOWN,
    pyxbmct.ACTION_MOUSE_WHEEL_UP,
    pyxbmct.ACTION_MOUSE_MOVE],
    list_update)




        


        

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
2 petewilson

I have 2 questions for you: which version of Kodi are you using and does PyXBMCt Demo addon have the same problem?

The thing is that controls' behavior is handled by Kodi internal logic so it does not matter how you interact with them: using keybord, remote, mouse or else. They should just work. Yes, you can connect ACTION_MOUSE_LEFT_CLICK action (or technically you catch it within xbmcgui.Window.onAction event callback method) but it is propagated to addon level after it has been processed by Kodi core logic (which handles controls' behavior too).
tested on both windows kodi 14.2 and android kodi 15.1, I have the demo installed on my windows system and it works fine yeah, the only difference that stands out to me is OOP. I've even tried rem'ing out all the other controls and just leaving the radiobuttons by themselves and no window.connectEventList at all and on both systems nothing happens on mouse input. would you say the code looks ok/works for you?
(2015-10-22, 12:26)petewilson Wrote: [ -> ]tested on both windows kodi 14.2 and android kodi 15.1, I have the demo installed on my windows system and it works fine yeah, the only difference that stands out to me is OOP. I've even tried rem'ing out all the other controls and just leaving the radiobuttons by themselves and no window.connectEventList at all and on both systems nothing happens on mouse input. would you say the code looks ok/works for you?

It seems that your List and RadioButtons row are overlapping with the List stealing mouse focus (you should see yourself that the list is activated when you hover the mouse cursor over the RadioButtons). You should carefully check your Controls placement within the grid.
cracked it, I was using:

window.placeControl(radiobutton1, 458, 25, 10, 12)

instead of

window.placeControl(radiobutton1, 458, 84, columnspan=15, rowspan=40)
I've published a re-worked documentation for PyXBMCt: http://romanvm.github.io/PyXBMCt/docs/. It replaces both the old PDF-based QuickStart Guide and auto-generated docs. Now it's a nice static web-site created with Sphinx. Hope, you will find it more convenient.
@Roman_V_M
thanks for your work. Q: Cant find a way to show a headerless dialogwindow with background. i just want to give an overlaytext a background(color) to optimize the readability..
Image

regards chmee
(2015-12-14, 12:52)chmee Wrote: [ -> ]@Roman_V_M
thanks for your work. Q: Cant find a way to show a headerless dialogwindow with background. i just want to give an overlaytext a background(color) to optimize the readability..

regards chmee

BlankDialogWindow class has no visual elements on its own and allows you to decorate you UI as you want. You can add an Image control with a texture as a background and then place a Label with some text over it.

Alternatively, you can attach controls to existing windows, including fullscreen video, without using PyXBMCt. See how it's done in my other plugin:
https://github.com/romanvm/kodi.yatp/blo...n_label.py

The only problem here that it's difficult to control your Controls placement exactly, because resolution of existing windows are defined by the current skin and display resolution. If you create a brand new Window or WindowDialog class instance, its resolution is always 1280x720.
ah ok, layering. thanks. Is there any control i can use, that has (by itself) a background taken from chosen skin?

regards chmee
(2015-12-14, 17:06)chmee Wrote: [ -> ]Is there any control i can use, that has (by itself) a background taken from chosen skin?

No, there's not. Yo need to provide a texture image file explicitly.
Hi guys,

Im new to Python GUI with PYXBMCT, I've managed to created the layout with the buttons and images etc exactly where I want them to be etc. The part I'm stuck on is making the buttons do something.

Im using the self.connect(self.example_button, lambda: XXXXXXX) functions but not quite sure how to use it?

I have a horizontal navigation menu at the top and when you click the first button on the left I want it to display content such as image/button/info in the blank space below, I believe this is called multi-frame/window but how do I go about it?

If anybody could help me Id appreciate it allot.

Ive also looked at youtube tutorials for tkinter and tried to apply the method to pyxbmct but can't get it to work.

Thanks in Advance.
(2016-02-11, 12:23)Harvinder Wrote: [ -> ]Hi guys,

Im new to Python GUI with PYXBMCT, I've managed to created the layout with the buttons and images etc exactly where I want them to be etc. The part I'm stuck on is making the buttons do something.

Im using the self.connect(self.example_button, lambda: XXXXXXX) functions but not quite sure how to use it?

I have a horizontal navigation menu at the top and when you click the first button on the left I want it to display content such as image/button/info in the blank space below, I believe this is called multi-frame/window but how do I go about it?

If anybody could help me Id appreciate it allot.

Ive also looked at youtube tutorials for tkinter and tried to apply the method to pyxbmct but can't get it to work.

Thanks in Advance.

Have you read the documentation and examples for PyXBMCt? connect method accepts a function/method object that you want to execute if a Control is activated. lambda is used in special cases and you need to understand what you are doing.

With PyXBMCt you can emulate tabbed layout by creating sets of controls that are shown/hidden when a "tab" button is clicked, using their setVisible() methods.

Also, PyXBMCt is closer to PyQt as the name implies.
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