2016-08-18, 11:44
First off - this is a repeat of a question I asked a while ago (see this thread: http://forum.kodi.tv/showthread.php?tid=212811)
I want to create a custom notification dialog for my addon (currently using WindowXMLDialog). The issue I'm facing is that as soon as I display the dialog, the dialog takes the focus so all key presses are trapped by that dialog (and current menus visibly lose focus).
I'm trying to replicate the behaviour of ordinary the ordinary notification dialog that doesn't trap key presses. Is this possible with python?
The solution presented in the earlier thread (adding a control to the current window) isn't really appropriate for what I want to do here as I need the ability to navigate freely without the dialog disappearing.
My code was as follows:
NB for some weird reason, the forum blocks posts with the word s-l-e-e-p in them, so you'd need to replace the 2 asterisks with an e in the code.
My xml looks like this:
If, instead, I run something simple like:then I can freely navigate while the notifications are being displayed. This is the behaviour I’d like to replicate.
Would be great to hear if there's any solution to this.
EDIT: I appreciate that there may be issues with this e.g. if the dialog doesn't trap keypresses then how do you close the dialog if your script doesn't? However, I hope my query is still valid.
I want to create a custom notification dialog for my addon (currently using WindowXMLDialog). The issue I'm facing is that as soon as I display the dialog, the dialog takes the focus so all key presses are trapped by that dialog (and current menus visibly lose focus).
I'm trying to replicate the behaviour of ordinary the ordinary notification dialog that doesn't trap key presses. Is this possible with python?
The solution presented in the earlier thread (adding a control to the current window) isn't really appropriate for what I want to do here as I need the ability to navigate freely without the dialog disappearing.
My code was as follows:
Code:
from time import sle*p
import xbmc
import xbmcgui
import xbmcaddon
__addon__ = xbmcaddon.Addon("script.my.addon.name")
class MyDialog(xbmcgui.WindowXMLDialog):
def __init__(self, strXMLname, strFallbackPath, strDefaultName, forceFallback):
# Changing the three variables passed won't change, anything
# Doing strXMLname = "bah.xml" will not change anything.
# don't put GUI sensitive stuff here (as the xml hasn't been read yet
# Idea to initialize your variables here
pass
def onInit(self):
# Put your List Populating code/ and GUI startup stuff here
pass
def onAction(self, action):
# Same as normal python Windows.
pass
def onClick(self, controlID):
"""
Notice: onClick not onControl
Notice: it gives the ID of the control not the control object
"""
pass
def onFocus(self, controlID):
pass
mydlg = MyDialog("customNotification.xml", __addon__.getAddonInfo('path'), "Default", "720p")
mydlg.show()
sle*p(5000)
mydlg.close()
My xml looks like this:
Code:
<window id="1142" type="dialog">
<coordinates>
<left>200</left>
<top>100</top>
</coordinates>
<controls>
<control type="label">
<scroll>true</scroll>
<autoscroll>true</autoscroll>
<label>Testing Custom Notification</label>
<visible>true</visible>
</control>
</controls>
</window>
If, instead, I run something simple like:
Code:
for x in range(10):
xbmc.executebuiltin("Notification(Test, {})".format(str(x)))
Would be great to hear if there's any solution to this.
EDIT: I appreciate that there may be issues with this e.g. if the dialog doesn't trap keypresses then how do you close the dialog if your script doesn't? However, I hope my query is still valid.