-2

I need to create a message box in python without using python Tkinter library so that I can use that before using exit() function this will display the message and answer as soon as user presses okay, user gets out of program.

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

0

Here's one way to do it with Windows' msg command. The code is based on @ErykSun's comment under the question Can't execute msg (and other) Windows commands via subprocess.

import os
import subprocess

sysroot = os.environ['SystemRoot']
sysnative = (os.path.join(sysroot, 'SysNative')
                if os.path.exists(os.path.join(sysroot, 'SysNative'))
             else
                os.path.join(sysroot, 'System32'))
msgexe_path = os.path.join(sysnative, 'msg.exe')
subprocess.run([msgexe_path, '*', 'ALL YOUR BASE ARE WHERE BELONG TO US.'])

martineau
  • 119,623
  • 25
  • 170
  • 301