1
+ #shutdown app using python
2
+ import tkinter as tk #we can also write from tkinter import * ( which imports all function of tkinter)
3
+ import os
4
+
5
+ #functions for buttons
6
+
7
+ def restart ():
8
+ os .system ("shutdown /r /t 1" ) #1 is time
9
+ def restart_time ():
10
+ os .system ("shutdown /r /t 20" )
11
+ def logout ():
12
+ os .system ("shutdown -l" )
13
+ def shutdown ():
14
+ os .system ("shutdown /s /t 1" )
15
+
16
+ # calling of Tk liabrary
17
+ st = tk .Tk ()
18
+ st .title ("Shutdown app" )
19
+ st .geometry ("300x300" )
20
+ st .config (bg = "Blue" )
21
+
22
+ r_button = tk .Button (st ,text = "Restart" ,font = ("Time New Roman" ,10 ,"bold" ),cursor = "hand2" ,command = restart ) #font(font,size,style)
23
+ r_button .place (x = 50 ,y = 50 ,height = 40 ,width = 200 )
24
+
25
+
26
+ r_button = tk .Button (st ,text = "Restart Time" ,font = ("Time New Roman" ,10 ,"bold" ),cursor = "hand2" ,command = restart_time ) #font(font,size,style)
27
+ r_button .place (x = 50 ,y = 100 ,height = 40 ,width = 200 ) #(outer,inner)
28
+
29
+ r_button = tk .Button (st ,text = "Log-Out" ,font = ("Time New Roman" ,10 ,"bold" ),cursor = "hand2" ,command = logout ) #font(font,size,style)
30
+ r_button .place (x = 50 ,y = 150 ,height = 40 ,width = 200 )
31
+
32
+ r_button = tk .Button (st ,text = "ShutDown" ,font = ("Time New Roman" ,10 ,"bold" ),cursor = "hand2" ,command = shutdown ) #font(font,size,style)
33
+ r_button .place (x = 50 ,y = 200 ,height = 40 ,width = 200 )
34
+
35
+ st .mainloop ()
0 commit comments