Unable to close a window
#1
Question 
I just want to close the currently visible window through my script
The Music Library window was on screen
I wrote following in script:
PHP Code:
my_win xbmcgui.Window(xbmcgui.getCurrentWindowId())
my_win.close() 
When I ran the script It did not close the window.
In xbmc.log it printed this:
PHP Code:
00:59:21 T:140490155476864   DEBUGActivating window ID0
00
:59:21 T:140490155476864   ERRORUnable to locate window with id -10000.  Check skin files 
This does not work either.
PHP Code:
my_win xbmcgui.getCurrentWindowId()
xbmc.executebuiltin("Dialog.Close("str(my_win) +", true) "
Why?
Thanks for help in advance.
Reply
#2
Not sure why you want to do that, but this should work:

PHP Code:
window_id xbmcgui.getCurrentWindowId()
xbmc.executebuiltin("Dialog.Close(%s, true)" window_id

Note that closing a window will re-open the last one. I guess this won't work on the Home window because its the lowest one in stack.
My GitHub. My Add-ons:
Image
Reply
#3
That is not working, Sphere Sad
Perhaps Dialog.Close can close only dialogs not windows??
What happened with First approach, I don't understand that should work, but is not working.
Reply
#4
(2013-09-25, 05:11)slinuxgeek Wrote: That is not working, Sphere Sad
Perhaps Dialog.Close can close only dialogs not windows??
What happened with First approach, I don't understand that should work, but is not working.

Maybe - if this is the case, you are only able to replace the current window (without adding the current to the stack) or activating another one (with adding the current to the stack). For both see here.

What are you trying to achieve?
My GitHub. My Add-ons:
Image
Reply
#5
give this a shot, it's what skins use to go back to the previous window:
xbmc.executebuiltin("PreviousMenu")

edit:
or simply xbmc.executebuiltin("Back")
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#6
I've also been playing with xbmcgui.Window and got the impression that, being provided with the current window ID, xbmcgui.Window instance attaches itself to that window and stops responding to anything. But you can interact with the parent window, the ID of which was provided.
The only way to remove your addon is to kill XBMC.
If you want your custom window to appear over XBMC, xbmcgui.WindowDialog is safer choice, but it always stays on top until you close it.
xbmcgui.Window without explicit ID also works and opens a separate window, but you need to provide it with some background image and other design elements because it is all black by default which does not look good.
Reply
#7
@sphere
There is a window coming from addon.
after it's doModal() there are some code that must be executed.

My purpose is to return to Home screen on press of a button on android remote.
For that I modified remote.xml and I am running a script to close the window.
If I simply call xbmc.executebuiltin("ActivateWindow(Home)") that brings me to home but code after doModal() does not execute.
I believe xbmc.executebuiltin("PreviousMenu") and xbmc.executebuiltin("Back") will do same.
Right now I am using sendclick() to close the window. That clicks exit button on the window and addon code knows how to close the window properly on click of that window.
May be this is not very reliable method.
But thank you every one for answers.
Reply
#8
(2013-09-25, 15:43)slinuxgeek Wrote: If I simply call xbmc.executebuiltin("ActivateWindow(Home)") that brings me to home but code after doModal() does not execute.

I guess you need to close your window by calling close() on it and then call xbmc.executebuiltin("ActivateWindow(Home)") after doModal(), when your window event loop will be terminated by close(). Or you can use show() instead of doModal but then you need to organize window event loop by yourself.
Reply

Logout Mark Read Team Forum Stats Members Help
Unable to close a window0