Dialogs from Python Macros

Posted by shanec on 2007-01-22 17:11
OS: All / Any | Product: Komodo | tags: komodo macro python

How do I show an alert dialog from a python macro in the toolbox?


For all the dirty details, you can look at the WindowWatcher and Prompt service in Mozilla:


Below is a quick and dirty example. This
uses all the standard moz dialogs rather than our own dialogs, but it
should be good enough for most stuff.

If you do this from threads, you need to proxy it to the main UI thread,
search our python files for use of nsIProxyService for examples of that.

from xpcom import components
wwatch = components.classes["@mozilla.org/embedcomp/window-watcher;1"].getService(components.interfaces.nsIWindowWatcher)
prompt = wwatch.getNewPrompter(wwatch.activeWindow)
prompt.alert("this is the title", "this is my message")