Skip to content
Advertisement

How to create Dialog box for Restarting in Win10 using Python

I am trying to run a Python script for the restart button on my taskbar. Here is the code I have:

JavaScript

I want to execute this outside of Python. Meaning when I click this button:
shutdown icon

I want it to say “Do you wish to restart your computer?” to confirm the restart instead of just doing it automatically.

Advertisement

Answer

Maybe this can help. Install PySimpleGUI first by running the following command:

JavaScript

If it doesn’t work, try:

JavaScript

Run this code. It will simply open a window with two buttons: Shut down and Cancel. Just be sure you’re ready to run it because it will shut down your machine. Save your work!

JavaScript

You won’t be able to use the system icons and button, though. This is your standalone app to shut down your machine. If you want it to run outside Python, you need to create an executable file (.exe). In order to do that, you need to install PyInstaller.

JavaScript

or

JavaScript

Check out their website. It explains in detail how to do it. https://pypi.org/project/pyinstaller/

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement