Answer the question
In order to leave comments, you need to log in
Is it possible to programmatically find a PyQt5 widget in Python3, by name (string value)?
I'm quite new to Python. By email books I can't figure out from the ones I have. Or advise how to do it or advise the primer.
The program creates Label groups. At the development stage, it is not known how many there may be.
In a separate class, override Label - clicked = QtCore.pyqtSignal()
In the class that creates "Label groups"
map_ = QtCore.QSignalMapper(self) # Создаем маппер
self.labelTools.clicked.connect(map_.map) # Привязываем
map_.setMapping(self.labelTools, int(self.numWin)) # Передаем индекс
#В слоте -
@QtCore.pyqtSlot(int)
def on_click(self, index):
print(str(index))
w = QWidget.sender(self)
print(w.sender().objectName()) # пишет имя Label
wp = w.sender().parent()
print(wp.objectName()) # имя родителя
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