如何在不使用Tkinter的情况下创建警报框? [英] How to create an alert box without using Tkinter?

查看:118
本文介绍了如何在不使用Tkinter的情况下创建警报框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在不使用python Tkinter库的情况下在python中创建一个消息框,以便我可以在使用exit()函数之前使用它,这将显示消息并在用户按下确定后立即回答,用户退出程序. /p>

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.

推荐答案

这是使用Windows的msg命令执行此操作的一种方法.该代码基于@ErykSun在问题通过子进程执行msg(和其他)Windows命令.

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.'])

这篇关于如何在不使用Tkinter的情况下创建警报框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆