I keep getting the error:
TypeError: runcmd() missing 1 required positional argument: 'inp'
while trying to use keyboard.add_hotkey,
def runcmd(inp):
text = inp
kb.remove_hotkey("enter")
if text == "help":
from tkinter import messagebox
messagebox.showinfo("commands","switchto <file> | opens <file> in the main editor\n")
def open_cmd_pallete():
top= tk.Toplevel(root)
top.geometry("750x30")
top.title("command pallete")
inp = tk.Entry(top)
inp.pack()
kb.add_hotkey("enter",runcmd,args=(inp.get())) # issue here
and whenever I try to change it to kb.add_hotkey("enter",runcmd(inp.get()))
then it throws another error, so how do i fix this?
for anyone who might (although very rare) come back to this. All you need to do is change the variable to a global, so in wherever (
def
), just change it toand it works