i cant find a way to start the run
function by pressing a key while not giving focus to the tkinter window, i also need to be able to stop the function while its runing by pressing the key again
import time import keyboard from tkinter import * import re def run(debug=None,): while True: if keyboard.is_pressed('q'): return() else: print(debug) print("2") print("4") print("6") print("8") window = Tk() window.title("pain") window.geometry('350x200') #widgets label = Label(window, text="fuck off") label.grid(column=0, row=0) button = Button(window, text="Click Me") button = Button(window, text="Click Me", command=run) button.bind('<Enter>',run) button.grid(column=1, row=0) #other stuff window.bind('q',run) window.mainloop()
im new to coding so im unsure if this is even possible
https://stackoverflow.com/questions/67352631/use-tkinter-to-keybind-functions-without-having-focus May 02, 2021 at 11:04AM
没有评论:
发表评论