Pwnna Pwnna - 1 year ago 64
Python Question

Python Message Box Without huge library dependancy

Is there a messagebox class where I can just display a simple message box without a huge GUI library or any library upon program success or failure. (My script only does 1 thing).

Also, I only need it to run on Windows.

Answer Source

You can use the ctypes library, which comes installed with Python:

import ctypes
MessageBox = ctypes.windll.user32.MessageBoxA
MessageBox(None, 'Hello', 'Window title', 0)

Above code is for Python 2.x. For Python 3.x, use MessageBoxW instead of MessageBoxA: This is the version that accepts unicode strings, which Python 3 uses by default.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download