Answer the question
In order to leave comments, you need to log in
Why are functions not attached to buttons on the widget being created from my class?
when a button is pressed, I call a class function (from another module), which returns a form (with buttons, etc.)
all actions that are written in __init__ are performed, and when I tried to bind a function to a button in this class, this function is created on the form being created doesn't work anymore
why?
in short, the code is something like this:
module 1.py
from 2.py import Task
...
self.tasks.addTab(Task(параметры __init__).new_task(), self.task_name.toPlainText())
class Task:
def __init__(self, параметры):
super().__init__()
self.tab_2 = QtWidgets.QTabWidget()
self.tab_2.setObjectName("tab_2")
# кнопка для примера
self.start_task = QtWidgets.QPushButton(self.tab_2)
self.start_task.setGeometry(QtCore.QRect(300, 510, 171, 23))
font = QtGui.QFont()
font.setPointSize(9)
self.start_task.setFont(font)
self.start_task.setObjectName("start_task")
self.start_task.clicked.connect(self.test)
def new_task(self):
return self.tab_2
def test(self):
print('111')
Answer the question
In order to leave comments, you need to log in
class Task:
def __init__(self, параметры):
super().__init__()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question