Answer the question
In order to leave comments, you need to log in
Problem with PyQt5, how to fix the error?
I decided to make a simple generator application with a GUI on PyQt5, but an error appeared.
Here is the code itself:
import sys
import os
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import *
from PyQt5.uic import loadUi
import random, string
import time
class p_main(QWidget):
def __init__(self):
super(p_main, self).__init__()
loadUi("uno.ui", self)
self.PushButton.clicked.connect(gen)
def gen():
value = 1
while value <= amount:
code = "https://discord.gift/" + ('').join(random.choices(string.ascii_letters + string.digits, k=16))
value += 1
self.Label.setText(code)
app = QApplication(sys.argv[:1])
wind = p_main(QWidget)
wind.show()
sys.exit(app.exec_())
Traceback (most recent call last):
File "C:\Users\Desmoke\Desktop\5.py", line 23, in <module>
wind = p_main(QWidget)
TypeError: __init__() takes 1 positional argument but 2 were given
Answer the question
In order to leave comments, you need to log in
It started like this for me ... True, only an empty window. I don't have "uno.ui"
import sys
import os
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import *
from PyQt5.uic import loadUi
import random, string
import time
class p_main(QWidget):
def __init__(self):
super().__init__()
#loadUi("uno.ui", self)
#self.PushButton.clicked.connect(gen)
def gen():
value = 1
while value <= amount:
code = "https://discord.gift/" + ('').join(random.choices(string.ascii_letters + string.digits, k=16))
value += 1
self.Label.setText(code)
app = QApplication(sys.argv[:1])
wind = p_main()
wind.show()
sys.exit(app.exec_())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question