Jul-29-2019, 03:28 PM
Hi,
I am new to python. I am developing an application in python using PyQt4. I want a multipage application. I wrote one code this I need help how can I code when I press the next button on the first page it should go to the next page with different widgets.
I am new to python. I am developing an application in python using PyQt4. I want a multipage application. I wrote one code this I need help how can I code when I press the next button on the first page it should go to the next page with different widgets.
import sys from PyQt4 import QtGui, QtCore class Window(QtGui.QMainWindow): def __init__(self): super(Window, self).__init__() self.setGeometry(0, 0, 800, 480) self.setWindowTitle("Femikare") self.home() def home(self): label1 = QtGui.QLabel(self) label1.setText("Please Select One Product") label1.setStyleSheet("font: bold 50px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") label1.resize(800,40) label1.move(0,0) #qApp->setStyleSheet("QRadioButton { background-color: white; background-position: center}"); rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/1.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "1" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(0,40) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l1 = QtGui.QLabel(self) p1 = 20 l1.setText("Price: %d" %p1) l1.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l1.resize(200,20) l1.move(0,210) rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/2.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "2" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(200,40) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l2 = QtGui.QLabel(self) p2 = 20 l2.setText("Price: %d" %p2) l2.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l2.resize(200,20) l2.move(200,210) rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/3.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "3" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(400,40) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l3 = QtGui.QLabel(self) p3 = 20 l3.setText("Price: %d" %p3) l3.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l3.resize(200,20) l3.move(400,210) rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/4.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "4" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(600,40) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l4 = QtGui.QLabel(self) p4 = 20 l4.setText("Price: %d" %p4) l4.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l4.resize(200,20) l4.move(600,210) rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/5.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "5" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(0,240) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l5 = QtGui.QLabel(self) p5 = 20 l5.setText("Price: %d" %p5) l5.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l5.resize(200,20) l5.move(0,410) rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/6.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "6" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(200,240) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l6 = QtGui.QLabel(self) p6 = 20 l6.setText("Price: %d" %p6) l6.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l6.resize(200,20) l6.move(200,410) rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/7.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "7" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(400,240) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l7 = QtGui.QLabel(self) p7 = 20 l7.setText("Price: %d" %p7) l7.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l7.resize(200,20) l7.move(400,410) rdoProduct = QtGui.QRadioButton(self) rdoProduct.setIcon(QtGui.QIcon("images/8.png")) rdoProduct.setIconSize(QtCore.QSize(180,180)) rdoProduct.productId = "8" rdoProduct.toggled.connect(self.test) rdoProduct.resize(200,200) rdoProduct.move(600,240) rdoProduct.setStyleSheet('QRadioButton::unchecked{background-color: white; width: 0px; height: 0px;}' 'QRadioButton::checked{background-color: pink; width: 0px; height: 0px;}' 'QRadioButton::indicator{width: 0px; height: 0px;}') l8 = QtGui.QLabel(self) p8 = 20 l8.setText("Price: %d" %p8) l8.setStyleSheet("font: bold 20px;" "color: rgb(255, 0, 127);" "background-color: white;" "qproperty-alignment: AlignCenter;") l8.resize(200,20) l8.move(600,410) btn = QtGui.QPushButton("NEXT", self) #btn.setIcon(QtGui.QIcon("images/Next.png")) #btn.setIconSize(QtCore.QSize(40,40)) btn.setStyleSheet("font: bold 20px;" "color: rgb(0, 0, 0);") btn.clicked.connect(self.test) btn.resize(400,40) btn.move(400,440) btn = QtGui.QPushButton("CANCEL",self) #btn.setIcon(QtGui.QIcon("images/Cancel.png")) #btn.setIconSize(QtCore.QSize(40,40)) btn.setStyleSheet("font: bold 20px;" "color: rgb(0, 0, 0);") btn.clicked.connect(QtCore.QCoreApplication.instance().quit) btn.resize(400,40) btn.move(0,440) self.show() def test(self): rdoProduct = self.sender() if rdoProduct.isChecked(): v = rdoProduct.productId print(v) def run(): app = QtGui.QApplication(sys.argv) GUI = Window() sys.exit(app.exec_()) run()