ayushii12
Uploaded by
8 SLIDES
30 VIEWS
0LIKES

Python Project — Shutdown, Restart and Logout using Python with GUI

DESCRIPTION

https://pythonflood.com/python-project-shutdown-restart-and-logout-using-python-with-gui-905cf913189d

Download Presentation

Python Project — Shutdown, Restart and Logout using Python with GUI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript

Playing audio...

  1. Python Project — Shutdown, Restart and Logout using Python with GUI In this Python project, we are going to use shutdown, restart and logout commands in the computer through Python program. We will make a GUI window in which these three buttons are positioned. Just by clicking at these buttons,we can make these processes happen. About Shutdown, Restart and Logout using Python Three buttons are present in the GUI window to Shutdown, Restart and Logout from the system. There are two modules required in this project: ● Tkinter Library. ● Os Module.

  2. Prerequisites For Shutdown, Restart and Logout using Python If your system does not have above library and module then we have to install them using pip installer; pip install tkinter pip install os-sys 1. tkinter- This library will help us in creating a GUI window for our program.

  3. 2. os Module- This module helps in using the Operating System functionalities. Download Shutdown, Restart and Logout Python Project Please download the source code of Python Shutdown, Restart and Logout Project: Python Shutdown, Restart and Logout Project Code. The following Steps are Required in the Project: 1. Import Required Modules 2. Create GUI Window 3. Define Shutdown Function 4. Define Restart Function 5. Define Logout Function Importing the Required Library and Module:

  4. from tkinter import * import os Importing the tkinter library and os Module. Creating the GUI Window: root=Tk() root.geometry("325x200") root.title("PC-Shutdown,Restart,Logout") root.config(bg='#FF0000') f=('Adagio Sans',15,'bold') root-It is the name of our GUI window. Tk()-Initialised tkinter which means GUI window created. geometry()-This method provides the length and breadth to GUI window.

  5. title()-This method gives title to the window confg()-This method set the configuration of the window. lb1=Label(root,text='Shutdown,Restart or Logout',font=(f),bg='#FF0000',fg='#303030') lb1.pack(pady=5) Label()- It is use to display one line or more than one line of text. text- It is use to display text on label. font- It is a style in which font written. bg- It is the background Colour of label. fg- It is the colour of letters in text. pack()- It is used to set the position with respect to each other. Button(root,text='Shutdown',font=(f),bg='#333333',fg='white',command=shutd own).pack(pady=5) Button(root,text='Restart',font=(f),bg='#333333',fg='white',command=restar t).pack(pady=5)

  6. Button(root,text='Logout',font=(f),bg='#333333',fg='white',command=logout)Button(root,text='Logout',font=(f),bg='#333333',fg='white',command=logout) .pack(pady=5) Button()-It is a button used to display on our window. command-it is used as a function of button when it is clicked. In this project we have created Three Buttons: 1. Shutdown Button 2. Restart Button 3. Logout Button Defining Shutdown Function: def shutdown(): os.system("shutdown /s /t 0")

  7. /s-This is for shutting down the system. /t-It denotes the time in which system is shutting down. Here 0 means system is shutting down in zero seconds. Defining Restart Function: def restart(): os.system("shutdown /r /t 0") /r-This is for restarting the system. /t-It denotes the time in which system is shutting down.Here 0 means system is shutting down in zero seconds. Defining Logout Function: def logout(): os.system("shutdown /l /t 0")

  8. /l-This is for logging out the system. /t-It denotes the time in which system is shutting down.Here 0 means system is shutting down in zero seconds. root.mainloop() root.main()-It is simply a method in the main window that executes what we wish to execute in an application and ends the mainloop. Conclusion We have successfully created an application with Python. With this application we can shutdown, restart and logout our computer. We learned how to use the tkinter module to create a simple interface of the application.

More Related