-
Notifications
You must be signed in to change notification settings - Fork 0
/
idle.py
53 lines (43 loc) · 1.79 KB
/
idle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! python3
import pyautogui, time
from threadsafe_tkinter import *
pyautogui.PAUSE = 1
pyautogui.FAILSAFE = True
class idleWindow:
def __init__(self, master):
self.master = master
self.button_clicks = 0
self.labelText = StringVar()
self.labelText.set("Idle Stopped.")
self.idleStatus = Label(master, textvariable=self.labelText)
self.idleStatus.pack(side=RIGHT)
#self.startButton = Button(master, text="Start Idle", command=self.startIdle)
#self.startButton.pack(side=LEFT)
self.startStopButton = Button(master, text='Start/Stop', command=self.startStopButton)
self.startStopButton.pack(side=LEFT)
def startIdle(self):
#self.labelText.set("Idle is Running...")
#self.pauseButton.config(state=NORMAL)
self.idleStatus.update_idletasks()
pyautogui.typewrite(['numlock', 'numlock'])
print("Working...")
self.after_id = self.master.after(5000, self.startIdle)
def startStopButton(self):
self.button_clicks += 0
self.labelText.set("Idle is Running = " + str(self.button_clicks))
self.startStopButton['text'] = "Start"
if self.button_clicks == 0:
self.button_clicks += 1
self.startStopButton['text'] = "Started " + str(self.button_clicks)
self.startIdle()
else:
self.labelText.set("Idle is Paused." + str(self.button_clicks))
self.startStopButton['text'] = 'Paused ' + str(self.button_clicks)
self.stopIdle()
self.idleStatus.update_idletasks()
self.button_clicks = 0
root = Tk()
root.geometry("380x50+0+945")
root.title("Idle")
runWindow = idleWindow(root)
root.mainloop()