2012-11-29, 22:56
Hi there,
I am relatively new to xbmc, and attempting to write a program addon.
I am writing it as a python script, and have imported xbmcgui to use its window functionality, but I am a little confused as to how the window's DoModal function works.
I have a class that inherits from xbmcgui.Window, and to handle events I override the onaction and oncontrol functions, and do a load of stuff at __init__ to set up.
To run this window I call doModal, but of course this stalls while displaying the window/handling events and I cannot do anything else while the window is open (anything that isnt triggered by a control/action)
What I would like to do is have a function that can run every frame so-to-speak, somewhere I can do stuff in the background that will happen while waiting for events. For example I would like a tcp server waiting for any incoming connections to be active, or at least to check for waiting connections once a frame or so. A host of other things I would like to be happening, but all while the window is open and waiting for events...
I see that I can also call window.show() rather than domodal, so i guess that could be used as the render portion of a 'main' loop so-to-speak, but I assume this means no events would be handled for me? If so then is there any info about handling your own events? Everywhere I have looked tends to say to use domodal for all event handling, and the events are passed in somehow in domodal...
I might add, this is on a Raspberry Pi, so I guess I cant have a second thread with the window doing its domodal and my other stuff going on in the background, which would have been my first solution to this...
Any ideas or suggestions as to how I should be doing this?
Could I maybe find the the source for domodal, override that and replicate what it currently does but with my own function that is being run while it is listening for events etc?
Thanks very much.
I am relatively new to xbmc, and attempting to write a program addon.
I am writing it as a python script, and have imported xbmcgui to use its window functionality, but I am a little confused as to how the window's DoModal function works.
I have a class that inherits from xbmcgui.Window, and to handle events I override the onaction and oncontrol functions, and do a load of stuff at __init__ to set up.
To run this window I call doModal, but of course this stalls while displaying the window/handling events and I cannot do anything else while the window is open (anything that isnt triggered by a control/action)
What I would like to do is have a function that can run every frame so-to-speak, somewhere I can do stuff in the background that will happen while waiting for events. For example I would like a tcp server waiting for any incoming connections to be active, or at least to check for waiting connections once a frame or so. A host of other things I would like to be happening, but all while the window is open and waiting for events...
I see that I can also call window.show() rather than domodal, so i guess that could be used as the render portion of a 'main' loop so-to-speak, but I assume this means no events would be handled for me? If so then is there any info about handling your own events? Everywhere I have looked tends to say to use domodal for all event handling, and the events are passed in somehow in domodal...
I might add, this is on a Raspberry Pi, so I guess I cant have a second thread with the window doing its domodal and my other stuff going on in the background, which would have been my first solution to this...
Any ideas or suggestions as to how I should be doing this?
Could I maybe find the the source for domodal, override that and replicate what it currently does but with my own function that is being run while it is listening for events etc?
Thanks very much.