Answer the question
In order to leave comments, you need to log in
The GUI does not open when adding the function to run the script on keypress?
I made a GUI using PyQt5, and when I added lines to run a script on a button click, the GUI stopped working for me, I just started learning Python, so I can’t understand what the problem is.
I will be very glad if you help me!
Lines to run the script on keypress
key = 'F7'
while True:
if keyboard.is_pressed(key):
keyboard.write('Привет')
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox
import time
import keyboard
import sys
class Ui_ChatSpamer(QMainWindow):
def __init__(self):
super(Ui_ChatSpamer, self).__init__()
def setupUi(self, ChatSpamer):
ChatSpamer.setObjectName("ChatSpamer")
ChatSpamer.setEnabled(True)
ChatSpamer.resize(500, 430)
ChatSpamer.setMinimumSize(QtCore.QSize(500, 430))
ChatSpamer.setMaximumSize(QtCore.QSize(500, 430))
font = QtGui.QFont()
font.setBold(False)
font.setWeight(50)
ChatSpamer.setFont(font)
ChatSpamer.setStyleSheet("")
key = 'F7'
while True:
if keyboard.is_pressed(key):
keyboard.write('Привет')
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
ChatSpamer = QtWidgets.QMainWindow()
ui = Ui_ChatSpamer()
ui.setupUi(ChatSpamer)
ChatSpamer.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question