Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # !/usr/bin/env python
- # coding: UTF-8
- #
- # Algoritmo que gera uma interface gráfica para
- # agendar o desligamento do computador.
- #
- # @author: Alex Lares
- # @since: 05/08/2021
- #
- import os
- from tkinter import *
- # Função para desligar
- def comando(segundos):
- tempo = "60*" + segundos
- tempo = eval(tempo)
- tempo = str(tempo)
- os.system("shutdown -s -t " + tempo)
- # Função geradora da janela
- def janelinha():
- root = Tk()
- root.configure(bg='#BD5652')
- root.title('Shutdown Scheduler')
- root.geometry('300x200')
- root.resizable(0, 0)
- x = (root.winfo_screenwidth() - root.winfo_reqwidth()) / 2
- y = (root.winfo_screenheight() - root.winfo_reqheight()) / 2
- root.geometry("+%d+%d" % (x, y))
- # Texo superior
- Label(text='Agendador de Desligamento', font='Arial 15', bg='#BD5652').pack(side=TOP)
- Label(text='\nDigite em quantos minutos o computador \n deverá ser desligado.\n',
- bg='#BD5652').pack(side=TOP)
- # Barra de entrada
- seg = StringVar()
- barra = Entry(root, width='20', font="Courier 17", textvariable=seg)
- barra.pack()
- # Botão de confirmação
- b1 = Button(root, text="Confirmar", width=10, command=lambda: comando(seg.get()))
- b1.place(x=20, y=150)
- # Botão de cancelamento
- b2 = Button(root, text="Cancelar Agendamento", width=20, command=lambda: os.system("shutdown -a"))
- b2.place(x=130, y=150)
- root.mainloop()
- janelinha()
Add Comment
Please, Sign In to add comment