from PyQt5.QtWidgets import QApplication,QWidget from PyQt5.QtGui import QColor import sys from t import Ui_Form class myform(QWidget,Ui_Form): def __init__(self): super().__init__() self.setupUi(self) self.btn.clicked.connect(self.ok) def ok(self): r=self.spin1.value() g=self.spin2.value() b=self.spin3.value() col=QColor(r,g,b) self.setStyleSheet('QWidget{background-color:%s}'%col.name()) if __name__=='__main__': app=QApplication(sys.argv) w=myform() w.show() app.exec_()