Finished menu bar (Visual only)
This commit is contained in:
parent
1a44c7258d
commit
b5a2e66df2
|
@ -3,3 +3,4 @@ data
|
|||
__pycache__
|
||||
venv
|
||||
software.spec
|
||||
temprecordloc.txt
|
19
macro.py
19
macro.py
|
@ -98,6 +98,7 @@ def startRecord():
|
|||
keyboard_listener = keyboard.Listener(on_press=on_press, on_release=on_release)
|
||||
mouse_listener.start()
|
||||
keyboard_listener.start()
|
||||
print('record started')
|
||||
|
||||
|
||||
def stopRecord():
|
||||
|
@ -105,10 +106,13 @@ def stopRecord():
|
|||
Stop record
|
||||
"""
|
||||
global macroEvents, record
|
||||
record = False
|
||||
mouse_listener.stop()
|
||||
keyboard_listener.stop()
|
||||
json_macroEvents = dumps(macroEvents, indent=4)
|
||||
open(path.join(appdata_local+"/temprecord.json"), "w").write(json_macroEvents)
|
||||
print('record stopped')
|
||||
|
||||
|
||||
def playRec():
|
||||
"""
|
||||
|
@ -160,19 +164,20 @@ def playRec():
|
|||
|
||||
# While loop to detect keybind of user
|
||||
while True:
|
||||
if (record == False and playback == False):
|
||||
# Start Record
|
||||
if record == False and playback == False:
|
||||
if is_pressed('o'):
|
||||
keyboardControl.release('o')
|
||||
keyboardControl.release('o') # I release here because for some reason sometimes startRecord is called and then right after stopRecord is called
|
||||
startRecord()
|
||||
|
||||
if (record == False and playback == False and len(macroEvents['events']) != 0):
|
||||
# Play Back
|
||||
if record == False and playback == False and len(macroEvents["events"]) != 0:
|
||||
if is_pressed('p'):
|
||||
keyboardControl.release('p')
|
||||
playback = True
|
||||
playRec()
|
||||
|
||||
if (record == True and playback == False):
|
||||
# Stop Record
|
||||
if record == True and playback == False:
|
||||
if is_pressed('escape'):
|
||||
keyboardControl.release(Key.esc)
|
||||
record = False
|
||||
stopRecord()
|
||||
|
||||
|
|
54
software.py
54
software.py
|
@ -40,7 +40,10 @@ def on_release(key):
|
|||
playbackStatement = False
|
||||
recordBtn.configure(state=NORMAL)
|
||||
playBtn.configure(image=playImg)
|
||||
file_menu.entryconfig('New', state=NORMAL)
|
||||
file_menu.entryconfig('Load', state=NORMAL)
|
||||
file_menu.entryconfig('Save', state=NORMAL)
|
||||
file_menu.entryconfig('Save as', state=NORMAL)
|
||||
|
||||
|
||||
def startRecordingAndChangeImg(pressKey=True):
|
||||
|
@ -87,8 +90,9 @@ def replay(pressKey=True):
|
|||
Replay the last recorded macro or the loaded one
|
||||
"""
|
||||
global playbackStatement, recordBtn, recordSet
|
||||
playBtn.configure(image=stopImg)
|
||||
if recordSet == True:
|
||||
playBtn.configure(image=stopImg)
|
||||
print('playback')
|
||||
playbackStatement = True
|
||||
file_menu.entryconfig('Save', state=DISABLED)
|
||||
file_menu.entryconfig('Save as', state=DISABLED)
|
||||
|
@ -142,6 +146,7 @@ def loadMacro(e=None):
|
|||
global macroPath, recordSet
|
||||
if recordStatement == False and playbackStatement == False:
|
||||
macroFile = filedialog.askopenfile(filetypes=[('Json Files', '*.json')], defaultextension='.json')
|
||||
if macroFile is not None:
|
||||
macroContent = open(macroFile.name)
|
||||
macroPath = macroFile.name
|
||||
macroEvents = load(macroContent)
|
||||
|
@ -151,8 +156,9 @@ def loadMacro(e=None):
|
|||
file_menu.entryconfig('Save', state=NORMAL, command=saveMacro)
|
||||
file_menu.entryconfig('Save as', state=NORMAL, command=saveMacroAs)
|
||||
file_menu.entryconfig('New', state=NORMAL, command=newMacro)
|
||||
recordSet = True
|
||||
macroFile.close()
|
||||
print("loaded")
|
||||
recordSet = True
|
||||
|
||||
|
||||
def newMacro(e=None):
|
||||
|
@ -197,13 +203,49 @@ window.config(menu=my_menu)
|
|||
# File Section
|
||||
file_menu = Menu(my_menu, tearoff=0)
|
||||
my_menu.add_cascade(label="File", menu=file_menu)
|
||||
file_menu.add_command(label="New", state=DISABLED)
|
||||
file_menu.add_command(label="Load", command=loadMacro)
|
||||
file_menu.add_command(label="Save", state=DISABLED)
|
||||
file_menu.add_command(label="Save as", state=DISABLED)
|
||||
file_menu.add_command(label="New", state=DISABLED, accelerator="Ctrl+N")
|
||||
file_menu.add_command(label="Load", command=loadMacro, accelerator="Ctrl+L")
|
||||
file_menu.add_command(label="Save", state=DISABLED, accelerator="Ctrl+S")
|
||||
file_menu.add_command(label="Save as", state=DISABLED, accelerator="Ctrl+Shift+S")
|
||||
file_menu.add_separator()
|
||||
file_menu.add_command(label="Exit", command=window.quit)
|
||||
|
||||
# Options Section
|
||||
options_menu = Menu(my_menu, tearoff=0)
|
||||
my_menu.add_cascade(label="Options", menu=options_menu)
|
||||
|
||||
# Playback Sub
|
||||
playback_sub = Menu(options_menu, tearoff=0)
|
||||
options_menu.add_cascade(label="Playback", menu=playback_sub)
|
||||
playback_sub.add_command(label="Speed")
|
||||
playback_sub.add_command(label="Repeat")
|
||||
|
||||
# Recordings Sub
|
||||
recordings_sub = Menu(options_menu, tearoff=0)
|
||||
options_menu.add_cascade(label="Recordings", menu=recordings_sub)
|
||||
recordings_sub.add_command(label="Mouse movement")
|
||||
recordings_sub.add_command(label="Mouse Click")
|
||||
recordings_sub.add_command(label="Keyboard")
|
||||
|
||||
# Options Sub
|
||||
options_sub = Menu(options_menu, tearoff=0)
|
||||
options_menu.add_cascade(label="Options", menu=options_sub)
|
||||
options_sub.add_command(label="Hotkeys")
|
||||
|
||||
minimization_sub = Menu(options_sub, tearoff=0)
|
||||
options_sub.add_cascade(label="Minimization", menu=minimization_sub)
|
||||
minimization_sub.add_command(label="Minimized when playing")
|
||||
minimization_sub.add_command(label="Minimized when recording")
|
||||
|
||||
options_sub.add_command(label="Run on startup")
|
||||
options_sub.add_command(label="After recording")
|
||||
|
||||
help_section = Menu(my_menu, tearoff=0)
|
||||
my_menu.add_cascade(label="Help", menu=help_section)
|
||||
help_section.add_command(label="Github Page")
|
||||
help_section.add_command(label="About")
|
||||
|
||||
|
||||
# Play Button
|
||||
playImg = PhotoImage(file=r"assets/button/play.png")
|
||||
playBtn = Button(window, image=playImg, command=replay, state=DISABLED)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import tkinter as tk
|
||||
|
||||
parent = tk.Tk()
|
||||
|
||||
menubar = tk.Menu(parent)
|
||||
show_all = tk.BooleanVar()
|
||||
show_all.set(True)
|
||||
show_done = tk.BooleanVar()
|
||||
show_not_done = tk.BooleanVar()
|
||||
|
||||
view_menu = tk.Menu(menubar)
|
||||
view_menu.add_checkbutton(label="Show All", onvalue=1, offvalue=0, variable=show_all)
|
||||
view_menu.add_checkbutton(label="Show Done", onvalue=1, offvalue=0, variable=show_done)
|
||||
view_menu.add_checkbutton(label="Show Not Done", onvalue=1, offvalue=0, variable=show_not_done)
|
||||
menubar.add_cascade(label='View', menu=view_menu)
|
||||
parent.config(menu=menubar)
|
||||
|
||||
parent.mainloop()
|
Loading…
Reference in New Issue