Search code examples
pythonalerts

Alert boxes in Python?


Is it possible to produce an alert similar to JavaScript's alert("message") in python, with an application running as a daemon.

This will be run in Windows, Most likely XP but 2000 and Vista are also very real possibilities.

Update:
This is intended to run in the background and alert the user when certain conditions are met, I figure that the easiest way to alert the user would be to produce a pop-up, as it needs to be handled immediately, and other options such as just logging, or sending an email are not efficient enough.


Solution

  • what about this:

    import win32api
    
    win32api.MessageBox(0, 'hello', 'title')
    

    Additionally:

    win32api.MessageBox(0, 'hello', 'title', 0x00001000) 
    

    will make the box appear on top of other windows, for urgent messages. See MessageBox function for other options.