built-in MsgBox function?
#1
Question 
is there a way to popup a msgbox like the built-in Notification command, but with eg. Yes and No buttons which can each have there own command(s) behind them.

regards Eddict
Reply
#2
Eddict Wrote:is there a way to popup a msgbox like the built-in Notification command, but with eg. Yes and No buttons which can each have there own command(s) behind them.

regards Eddict

I don't think there is a built in function - but here is a workaround if you are willing to put in a little effort.

1) write an addon that uses the xbmcgui.Dialog class.

Code:
dialog = xbmcgui.Dialog()
    dialog.yesno(heading, line1[, line2, line3,nolabel,yeslabel])

2) Upon return of this function (return true/false depending on action) launch the other scripts using the builtin function RunScript or RunAddon

3) you could launch this script remotely or from another addon using the same RunAddon() builtin function.

Not as simple as the already available Notification() function but with a little work you could make an addon just as effective (like passing in the addon or script name to branch based on the true/false).
Reply
#3
You don't need to write an add-on to do this, just write a Python script and run it by mapping the RunScript function to the input of your choice.

JR
Reply
#4
ok that's good news. i was already diggin into some 'how to write an xbmc add-on' pages, but, although i am a developer, that seemed not that easy...

anybody has an eample available of an Pyhton script using a Yes/No Msgbox ? (i did some Googling, but quite some links point to EasyGui library. is this needed?)
Reply
#5
(2012-03-12, 13:31)Eddict Wrote: ok that's good news. i was already diggin into some 'how to write an xbmc add-on' pages, but, although i am a developer, that seemed not that easy...

anybody has an eample available of an Pyhton script using a Yes/No Msgbox ? (i did some Googling, but quite some links point to EasyGui library. is this needed?)

Here is the entire file for the "Manual Run" part of the XBMC Library Auto Update addon. As you can see, it is pretty simple. There is an example of a yesno dialog box and then an if statement based on the result.

Code:
import xbmc
import xbmcaddon
import xbmcgui
from service import AutoUpdater
addon_id = "service.libraryautoupdate"
Addon = xbmcaddon.Addon(addon_id)

autoUpdate = AutoUpdater()

nextRun = autoUpdate.calcNextRun()
#check if we should run updates
runUpdate = xbmcgui.Dialog().yesno(Addon.getLocalizedString(30010),Addon.getLocalizedString(30011) + nextRun,Addon.getLocalizedString(30012))

if(runUpdate):
    #run the program
    xbmc.log("Update Library Manual Run...")
    autoUpdate.runUpdates()

You can also check the documentation on xbmcgui.Dialog at this link: http://xbmc.sourceforge.net/python-docs/...tml#Dialog
Reply
#6
very useful, thanks a lot!
Reply
#7
Create a file (test.py in my case) in your userdata folder containing:

Code:
import xbmc
import xbmcgui

dialog = xbmcgui.Dialog()
i = dialog.yesno("Are you sane", "At least some of the time")

if i == 0:
    dialog.ok("Are you sane", "You should be locked up immediately")
else:
    dialog.ok("Are you sane", "Congratulations")

To test this I put the following in my keyboard.xml:

Code:
<keymap>
  <global>
    <keyboard>
      <space mod="ctrl">RunScript(special://masterprofile/test.py)</space>
    </keyboard>
  </global>
</keymap>

The end result is that when I press ctrl-space I get the "Are you sane" prompt (I declined to answer :-).

If you want a notification rather than a dialog use e.g.:

Code:
xbmc.executebuiltin("Notification(Are you sane, You should be locked up immediately)")

JR
Reply
#8
Thanks a lot for this example and builtin link is very helpful and let me do a lot of Ideas. Thanks a lot guys! but what if I want to send this dialog to another Kodi or xbmc user in my network?

Thanks for all
Reply

Logout Mark Read Team Forum Stats Members Help
built-in MsgBox function?0