我正在尝试制作一个计时器来关闭我运行 linux 的计算机。选择我使用 spinbox 的时间。所以想法是选择旋转框中的时间量,然后添加到命令sudo shutdown -P
+ 15 分钟(例如示例)。
直到现在它才关闭,我无法用简单的方法来做到这一点。
from tkinter import *
import os
import time
def shutdown():
hrs = spin1.get()
command1 = ('sudo shutdown -P')
#sum1 = command1 + hrs
os.system('sudo shutdown -P') + ('hrs')
print(os.system)
def cancel():
command = ('sudo shutdown -c')
os.system('sudo shutdown -c')
print(command)
'''def hrs():
spn1 = spin1.get()
dsp1 = spn1
lbltime ['text'] = dsp1'''
entry_width = 2
win = Tk()
spin1 = IntVar()
spn = IntVar()
win.title('SHUTDOWN')
win.geometry('300x250+300+150')
lbl = Label(win, text='SET YOUR SHUTDOWN')
lbl.place(x=80, y=30)
spin1 = Spinbox(win, from_=00, to=23, font=('arial',26,'bold'), width= entry_width, textvariable=spin1)
spin1.insert(0, '00')
spin1.place(x=130, y=60)
setup = Button(win, text='SET TIMER', font=('arial',16,'bold'), command=lambda :shutdown())
setup.place(x=90, y=130)
cnc = Button(win, text='CANCEL', font=('verdana',10, 'bold'),command= lambda :cancel())
cnc.place(x=120, y=180)
win.mainloop()
料青山看我应如是
相关分类