简体   繁体   English

pyinstaller 运行完成后,如何使 Windows 发出哔哔声?

[英]How can I make Windows beep when pyinstaller is finished running?

Good morning!早上好!

I'm currently trying to work on making an executable for my Python script using PyInstaller and so I often have to wait for it to finish compiling (is that the right word in this case?), but I don't want to keep staring at the screen unnecessarily.我目前正在尝试使用 PyInstaller 为我的 Python 脚本制作可执行文件,因此我经常不得不等待它完成编译(在这种情况下,这是正确的词吗?),但我不想一直盯着不必要地在屏幕上。

I understand that I can import winsound and make it beep that way from within a script, but how would I do so with pyinstaller from terminal?我知道我可以在脚本中导入 winsound 并使其发出哔哔声,但是我将如何从终端使用 pyinstaller 执行此操作?

In other words, whenever I type in "pyinstaller myScript.py" into terminal and Python finishes creating the executable, I'd like Windows to beep.换句话说,每当我在终端中输入“pyinstaller myScript.py”并且 Python 完成创建可执行文件时,我都希望 Windows 发出哔哔声。

You can simply run it sequentially after the pyinstaller program: pyinstaller myScript.py; python3 -c "print('\\7')";你可以简单地在pyinstaller程序之后依次运行它: pyinstaller myScript.py; python3 -c "print('\\7')"; pyinstaller myScript.py; python3 -c "print('\\7')";

You can also try pyinstaller myScript.py; echo ^G;你也可以试试pyinstaller myScript.py; echo ^G; pyinstaller myScript.py; echo ^G; . . Where ^G is the character that is printed when you do Ctrl + G on your keyboard.其中 ^G 是在键盘上Ctrl + G时打印的字符。

Using winsound , you could have a simple python script that beeps:使用winsound ,你可以有一个简单的 python 脚本发出哔哔声:

beep.py

import winsound 
              
winsound.Beep(500, 250) # Hz, ms

then in your terminal: pyinstaller myScript.py;然后在您的终端中: pyinstaller myScript.py; python3 beep.py` python3 beep.py`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM