import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class Button(QPushButton):
def __init__(self,
func,
parent = None):
super(Button,
self).__init__(parent)
self.func = func
def mousePressEvent(self,
QEvent):
self.func()
class Window(QWidget):
def __init__(self):
QWidget.__init__(self)
self.GUI()
def clean(self):
for i in self.children():
i.setParent(None)
self.GUI1()
def GUI(self):
self.layout = QHBoxLayout()
self.btn = Button(self.clean,
'test')
self.layout.addWidget(self.btn)
self.setLayout(self.layout)
def GUI1(self):
self.layout1 = QHBoxLayot()
self.btn1 = Button(self.clean,
'test1')
self.layout1.addWidget(self.btn1)
self.setLayout(self.layout1)
app = QApplication(sys.argv)
screen = Window()
screen.show()
sys.exit(app.exec_())
P.S я знаю про pastebin.org, но он мне недоступен
попробуй ideone использовать
Обсуждают сегодня