Esempio n. 1
0
 def button2clicked(self):
     grid_layout = QGridLayout()
     self.setLayout(grid_layout)
     for x in range(4):
         for y in range(4):
             button = QPushButton()
             policy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
             button.setSizePolicy(policy)
             button.setStyleSheet("background-color: white")
             grid_layout.addWidget(button, x, y)
             button.clicked.connect(self.buttonColor1)
     button3 = QPushButton("Restart", self)
     grid_layout.addChildWidget(button3)
     button3.move(125, 0)
     button3.resize(50, 20)
     button3.setStyleSheet("background-color: grey")
     button3.clicked.connect(self.button3clicked)
    def move_table(self, index):
        """
        dynamically move table control to the currently active tab
        this is when only one table control is shared among multiple tabs
        Args:
            index: the active tab's index
        Returns:
        """
        for i in range(0, self.tabDefaults.count()):
            controls = self.tabDefaults.widget(i).findChildren(QTableWidget, self.tblGeneric.objectName())
            if len(controls) > 0 and i != index:
                layout_src = self.tabDefaults.widget(i).layout()
                if layout_src is not None:
                    layout_src.removeWidget(self.tblGeneric)
                layout_dest = self.tabDefaults.widget(index).layout()
                if layout_dest is None:
                    layout_dest = QGridLayout(self.tabDefaults.widget(index))
                    self.tabDefaults.widget(index).setLayout(layout_dest)
                layout_dest.addChildWidget(self.tblGeneric)
                break

        pass