title: How to get the list of all QPushButton from a specific tab in Python Pyqt5?
body: <p>I have a Python 3.7 Pyqt5 GUI with several tabs.
  In the 2nd tab, I have a few QPushButtons. Each name of button has an id number and I need to hide or show some of these buttons depending on this id number.</p>
  <p>I can't simply use self.name_of_button.hide() because:
  from a side I have a list of ID numbers
  from the other side, I have more than 50 buttons.</p>
  <p>So I would like to loop all my buttons of my tab N°2 and check if the id in the</p>
  <pre><code>button name is in ly list of ids:
  list_id=[1,2,3,4,5]
  for button in QPushbuttons:
      text = button.text() 
      for id in list_id:
          if text.find(str(id))!=-1:
               button.setHidden(True)
  
          
  </code></pre>
  <p>SO I need to get the list of buttons of these specific Tab.
  I know how to hide/show a QPushbuttons. But I don't know how to get the list of the buttons of a specific tab with their names.</p>
  <p>I tried this code but it gives only 1 element instead of the list of buttons:</p>
  <pre><code># self.tab_run_one_task is my tab N°2
  buttons = QtWidgets.QPushButton(self.tab_run_one_task)
  </code></pre>
  <p><strong>I am using QT Designer to make the GUI:</strong></p>
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  
  class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(&quot;MainWindow&quot;)
          MainWindow.resize(800, 447)
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName(&quot;centralwidget&quot;)
          self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
          self.tabWidget.setGeometry(QtCore.QRect(30, 10, 701, 361))
          self.tabWidget.setObjectName(&quot;tabWidget&quot;)
          self.tab = QtWidgets.QWidget()
          self.tab.setObjectName(&quot;tab&quot;)
          self.tabWidget.addTab(self.tab, &quot;&quot;)
          self.tab_2 = QtWidgets.QWidget()
          self.tab_2.setObjectName(&quot;tab_2&quot;)
          self.pushButton = QtWidgets.QPushButton(self.tab_2)
          self.pushButton.setGeometry(QtCore.QRect(70, 60, 75, 23))
          self.pushButton.setObjectName(&quot;pushButton&quot;)
          self.pushButton_2 = QtWidgets.QPushButton(self.tab_2)
          self.pushButton_2.setGeometry(QtCore.QRect(70, 100, 75, 23))
          self.pushButton_2.setObjectName(&quot;pushButton_2&quot;)
          self.pushButton_3 = QtWidgets.QPushButton(self.tab_2)
          self.pushButton_3.setGeometry(QtCore.QRect(70, 140, 75, 23))
          self.pushButton_3.setObjectName(&quot;pushButton_3&quot;)
          self.pushButton_4 = QtWidgets.QPushButton(self.tab_2)
          self.pushButton_4.setGeometry(QtCore.QRect(70, 190, 75, 23))
          self.pushButton_4.setObjectName(&quot;pushButton_4&quot;)
          self.tabWidget.addTab(self.tab_2, &quot;&quot;)
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
          self.menubar.setObjectName(&quot;menubar&quot;)
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName(&quot;statusbar&quot;)
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          self.tabWidget.setCurrentIndex(1)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate(&quot;MainWindow&quot;, &quot;MainWindow&quot;))
          self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate(&quot;MainWindow&quot;, &quot;Tab 1&quot;))
          self.pushButton.setText(_translate(&quot;MainWindow&quot;, &quot;PushButton1&quot;))
          self.pushButton_2.setText(_translate(&quot;MainWindow&quot;, &quot;PushButton2&quot;))
          self.pushButton_3.setText(_translate(&quot;MainWindow&quot;, &quot;PushButton3&quot;))
          self.pushButton_4.setText(_translate(&quot;MainWindow&quot;, &quot;PushButton4&quot;))
          self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate(&quot;MainWindow&quot;, &quot;Tab 2&quot;))
  
  
  if __name__ == &quot;__main__&quot;:
      import sys
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>
  <p><strong>Here is the main code which displays the GUI:</strong></p>
  <pre><code>from simpleui2 import Ui_MainWindow
  
  
  # === The UI ===============================================================================================
  class Ui(QtWidgets.QMainWindow, Ui_MainWindow):
      def __init__(self):
  
          super(Ui, self).__init__()
          self.setupUi(self)
          self.show()
  
          # I want for example hide the buttons 'PushButton3' and 'PushButton4'
          buttons = QtWidgets.QPushButton(self.tab_2)
          print(buttons)
  
  
  if __name__ == '__main__':
      app = QtWidgets.QApplication(sys.argv)
      window = Ui()
      app.exec_()
  </code></pre>
  <p><strong>Output:</strong></p>
  <pre><code>&lt;PyQt5.QtWidgets.QPushButton object at 0x000002E15A70F9D8&gt;
  </code></pre>
  <p>As you can see the print output display one Button element without the name.</p>