By Sayak Mandal
Power management functions GUI application, that is used to shut down, log out, restart, sleep, and many operations in Windows.
Power management functions GUI-based application, that is used to shut down, log out, restart, sleep, and many operations in Windows. These operations can be possible in many ways and there are many shortcuts to do that. I create an application for these kinds of operations using Python. For this, some modules are required. This application is used for Windows.
Prerequisites:
os:
We use os module to shut down, log out, sleep, restart operations. Os module is used to interact with operating systems such as Windows, Linux etc. Os is a built-in function in Python that's why we can use it without 'pip' installation. To use os we will import it using import os. Here I use 'os.system' command that is used for executing a system command.
Tkinter:
Tkinter is a Python library. It is used for creating GUI. It develops Graphical User Interface with buttons, text boxes, labels etc. Tkinter is available by default so not to install again using pip. To import this library we use from tkinter import *.
ctypes:
Ctypes is a Python library that is used to call functions in a dynamic link library. It is a built-in library, we don't reinstall it. For importing the library we use import ctypes.
This application is another shortcut way to shut down, restart, log out, and sleep windows using Python. After running the code a GUI is pop up automatically that contains 'Shut Down', 'Restart', 'Log Out', 'Sleep' buttons. If you want to shut down your windows then click 'Shut Down' button, If you want to Restart your windows then click the 'Restart' button, If you want to log out of your windows then click 'Log Out' button, If you want to sleep your windows then click 'Sleep' button.
Output:
Submitted by Sayak Mandal (Sayak)
Download packets of source code on Coders Packet
Comments