Pwnna Pwnna - 7 months ago 43
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.


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.