S
S
smalldick1322020-06-03 21:19:42
Python
smalldick132, 2020-06-03 21:19:42

I wrote an interface and a script, after the script is launched, the interface "does not respond". Can you correct me please?

import time, threading
from tkinter import *
from tkinter import messagebox
import keyboard

def infinite_process():
    while True:

        while keyboard.is_pressed("space"):
                time.sleep(0.00015)
                keyboard.press_and_release("space")
                time.sleep(0.030)


mainWindow = Tk()
mainWindow.geometry("500x75")
mainWindow.resizable(width=False, height=False)
mainWindow.config(bg='#232723')
mainWindow.title("G4Bhop")
lbCommand = Label(mainWindow, text="Hello world", font=("Courier New", 16)).place(x=20, y=20)
mainWindow.after(3000, infinite_process)
mainWindow.mainloop()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-06-03
@NeiroNx

That's right - there is no time for him to react to the window - he is only busy processing the keyboard. You don't let him do anything else. You need to run such things in a separate thread.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question