This GUI program is the modified version of my previously posted gui post.
Source code:::

from tkinter import *
import os
from tkinter import messagebox as tmsg
import time

def run():
    a=slider.get()
    b=slider1.get()
    if a==0 and b==0:
        que=tmsg.askquestion("Warning...","Do you want to Shutdown computer now!!!")
        if que=='yes':
            os.system("shutdown /s")
    elif a==0 and b!=0:
        c=b*60
        os.system(f"shutdown /s /t {c}")
    elif a>0:
        c=(a*60*60)+(b*60)
        os.system(f"shutdown /s /t {c}")
    else:
        pass
def log_off():
    a=slider.get()
    b=slider1.get()
    if a==0 and b==0:
        que=tmsg.askquestion("Warning...","Do you want to Restart computer now!!!")
        if que=='yes':
            os.system("shutdown /r")
    elif a==0 and b!=0:
        c=b*60
        batfile=open("temp.bat",'w')
        batfile.write(f"@echo off\necho restarting.......\ntimeout /t {c}\nshutdown /r")
        batfile.close()
        vbsfile=open("temp.vbs",'w')
        vbsfile.write('Set oShell = CreateObject ("Wscript.Shell") \nDim strArgs\nstrArgs = "cmd /c temp.bat"\noShell.Run strArgs, 0, false')
        os.startfile("temp.vbs")
    elif a!=0 and b!=0:
        c=(a*60*60)+(b*60)
        batfile=open("temp.bat",'w')
        batfile.write(f"@echo off\ntimeout /t {c}\nshutdown /r")
        batfile.close()
        vbsfile=open("temp.vbs",'w')
        vbsfile.write('Set oShell = CreateObject ("Wscript.Shell") \nDim strArgs\nstrArgs = "cmd /c temp.bat"\noShell.Run strArgs, 0, false')
        os.startfile("temp.vbs")
        root.destroy()
    pass
def sleep():
    a=slider.get()
    b=slider1.get()
    if a==0 and b==0:
        que=tmsg.askquestion("Warning...","Do you want to log off computer now!!!")
        if que=='yes':
            os.system("shutdown /h")
    elif a==0 and b!=0:
        c=b*60
        batfile=open("temp.bat",'w')
        vbsfile=open("temp.vbs",'w')
        batfile.write(f"@echo off\ntimeout /t {c}\nshutdown /h")
        batfile.close()
        vbsfile=open("temp.vbs",'w')
        vbsfile.write('Set oShell = CreateObject ("Wscript.Shell") \nDim strArgs\nstrArgs = "cmd /c temp.bat"\noShell.Run strArgs, 0, false')
        os.startfile("temp.vbs")
    elif a!=0 and b!=0:
        c=(a*60*60)+(b*60)
        batfile=open("temp.bat",'w')
        batfile.write(f"@echo off\ntimeout /t {c}\nshutdown /h")
        batfile.close()
        vbsfile=open("temp.vbs",'w')
        vbsfile.write('Set oShell = CreateObject ("Wscript.Shell") \nDim strArgs\nstrArgs = "cmd /c temp.bat"\noShell.Run strArgs, 0, false')
        os.startfile("temp.vbs")
    pass
def cancel():
    os.system("shutdown /a")
    root.destroy()

root=Tk()
root.title("Scheduled Shutdown -(FE Div-B) (PBL) --R.Gadekar".upper())
root.geometry("500x190")
root.minsize(500,208)
root.maxsize(800,300)
f1=Frame(root,bg="#ffffff")
f1.pack(fill="both")
f2=Frame(root,bg='#ffffff')
f2.pack(fill="both")
f4=Frame(root,bg='green')
f4.pack(fill='both',expand=True)

Label(f1,text="Hours    ",fg="#000000",bg="#ffffff",font='arial 17 bold').pack(side=LEFT)
slider=Scale(f1,from_=0,to=1+11,orient=HORIZONTAL,tickinterval=1,bg="#ffffff",borderwidth=0)
slider.pack(fill="both")

Label(f2,text="Minutes",fg="#000000",bg="#ffffff",font='arial 17 bold').pack(side=LEFT)
slider1=Scale(f2,from_=0,to=60,orient=HORIZONTAL,tickinterval=10/2,bg="#ffffff",borderwidth=0)
slider1.pack(fill="both")

Button(f4,text="Cancel",font="arial 17 bold",fg="#ffffff",bg='green',command=cancel).pack(fill='both')
Button(f4,text="Shutdown",font="arial 17 bold",
       bg="red",fg='yellow',command=run,borderwidth=4).pack(side=LEFT,fill='both',expand=True)
Button(f4,text="Restart",font="arial 17 bold",
       bg="yellow",fg='blue',command=log_off,borderwidth=4).pack(side=LEFT,fill='both',expand=True)
Button(f4,text="Hibernate",font="arial 17 bold",
       bg="blue",fg='pink',command=sleep,borderwidth=4).pack(side=LEFT,fill='both',expand=True)

root.mainloop()

Here is .exe package :::

https://drive.google.com/open?id=1gHRb-wfyTLiPagBjSZi1ZIEmX8GEFjLl

#########################R.D.Gadekar#########################. 
To be connected with me msg on ::: """rameshwarrdg@gmail.com"""
Instagram handle :: """rameshwar_d_g"""


Comments

Post a Comment

Popular Posts