pyqt5 : Unable to maximize widgets on Window resize - pyqt5

I want to show a few data on the screen (These are inputs and outputs from RPi).
I also want to show a chart. (I got sample code here https://codeloop.org/pyqtchart-how-to-create-barchart-in-pyqt5/)
I am having one issue though. I am not able to get the widgets resize when the screen resizes. Even when maximized the size remains the same.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'prodwindowui3.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtChart import QChart, QChartView, QBarSet, QPercentBarSeries, QBarCategoryAxis
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QWidget
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(923, 480)
MainWindow.setLayoutDirection(QtCore.Qt.LeftToRight)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.horizontalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.horizontalLayoutWidget.setGeometry(QtCore.QRect(50, 10, 751, 31))
self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
self.lytHTitle = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget)
self.lytHTitle.setContentsMargins(0, 0, 0, 0)
self.lytHTitle.setObjectName("lytHTitle")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.lytHTitle.addItem(spacerItem)
self.lblTitle = QtWidgets.QLabel(self.horizontalLayoutWidget)
self.lblTitle.setObjectName("lblTitle")
self.lytHTitle.addWidget(self.lblTitle)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.lytHTitle.addItem(spacerItem1)
self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(0, 40, 791, 241))
self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
self.lytH_Top = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2)
self.lytH_Top.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize)
self.lytH_Top.setContentsMargins(0, 0, 0, 0)
self.lytH_Top.setSpacing(10)
self.lytH_Top.setObjectName("lytH_Top")
self.frmInput = QtWidgets.QFrame(self.horizontalLayoutWidget_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(5)
sizePolicy.setVerticalStretch(12)
sizePolicy.setHeightForWidth(self.frmInput.sizePolicy().hasHeightForWidth())
self.frmInput.setSizePolicy(sizePolicy)
self.frmInput.setMinimumSize(QtCore.QSize(95, 208))
self.frmInput.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmInput.setFrameShape(QtWidgets.QFrame.Box)
self.frmInput.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmInput.setLineWidth(1)
self.frmInput.setObjectName("frmInput")
self.layoutWidget_5 = QtWidgets.QWidget(self.frmInput)
self.layoutWidget_5.setGeometry(QtCore.QRect(10, 10, 35, 178))
self.layoutWidget_5.setObjectName("layoutWidget_5")
self.lytV_Input_label_3 = QtWidgets.QVBoxLayout(self.layoutWidget_5)
self.lytV_Input_label_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_label_3.setSpacing(12)
self.lytV_Input_label_3.setObjectName("lytV_Input_label_3")
self.lblInput0_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput0_3.setObjectName("lblInput0_3")
self.lytV_Input_label_3.addWidget(self.lblInput0_3)
self.lblInput1_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput1_3.setObjectName("lblInput1_3")
self.lytV_Input_label_3.addWidget(self.lblInput1_3)
self.lblInput2_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput2_3.setObjectName("lblInput2_3")
self.lytV_Input_label_3.addWidget(self.lblInput2_3)
self.lblInput3_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput3_3.setObjectName("lblInput3_3")
self.lytV_Input_label_3.addWidget(self.lblInput3_3)
self.layoutWidget_6 = QtWidgets.QWidget(self.frmInput)
self.layoutWidget_6.setGeometry(QtCore.QRect(40, 10, 46, 178))
self.layoutWidget_6.setObjectName("layoutWidget_6")
self.lytV_Input_Status_3 = QtWidgets.QVBoxLayout(self.layoutWidget_6)
self.lytV_Input_Status_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_Status_3.setSpacing(12)
self.lytV_Input_Status_3.setObjectName("lytV_Input_Status_3")
self.lblInput0_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput0_Status_3.setObjectName("lblInput0_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput0_Status_3)
self.lblInput1_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput1_Status_3.setObjectName("lblInput1_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput1_Status_3)
self.lblInput2_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput2_Status_3.setObjectName("lblInput2_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput2_Status_3)
self.lblInput3_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput3_Status_3.setObjectName("lblInput3_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput3_Status_3)
self.lblOStatus_2 = QtWidgets.QLabel(self.frmInput)
self.lblOStatus_2.setGeometry(QtCore.QRect(30, 190, 30, 10))
self.lblOStatus_2.setStyleSheet("Font:Bold;")
self.lblOStatus_2.setObjectName("lblOStatus_2")
self.lytH_Top.addWidget(self.frmInput)
self.frmOutput = QtWidgets.QFrame(self.horizontalLayoutWidget_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.frmOutput.sizePolicy().hasHeightForWidth())
self.frmOutput.setSizePolicy(sizePolicy)
self.frmOutput.setMinimumSize(QtCore.QSize(95, 208))
self.frmOutput.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmOutput.setFrameShape(QtWidgets.QFrame.Box)
self.frmOutput.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmOutput.setLineWidth(1)
self.frmOutput.setObjectName("frmOutput")
self.verticalLayoutWidget_22 = QtWidgets.QWidget(self.frmOutput)
self.verticalLayoutWidget_22.setGeometry(QtCore.QRect(50, 10, 41, 178))
self.verticalLayoutWidget_22.setObjectName("verticalLayoutWidget_22")
self.lytV_Output_Status_3 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_22)
self.lytV_Output_Status_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Output_Status_3.setSpacing(12)
self.lytV_Output_Status_3.setObjectName("lytV_Output_Status_3")
self.lblOutput0_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput0_Status_3.setObjectName("lblOutput0_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput0_Status_3)
self.lblOutput1_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput1_Status_3.setObjectName("lblOutput1_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput1_Status_3)
self.lblOutput2_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput2_Status_3.setObjectName("lblOutput2_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput2_Status_3)
self.lblOutput3_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput3_Status_3.setObjectName("lblOutput3_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput3_Status_3)
self.verticalLayoutWidget_23 = QtWidgets.QWidget(self.frmOutput)
self.verticalLayoutWidget_23.setGeometry(QtCore.QRect(10, 10, 41, 178))
self.verticalLayoutWidget_23.setObjectName("verticalLayoutWidget_23")
self.lytV_Output_Label_3 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_23)
self.lytV_Output_Label_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Output_Label_3.setSpacing(12)
self.lytV_Output_Label_3.setObjectName("lytV_Output_Label_3")
self.lblOutput0_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput0_3.setObjectName("lblOutput0_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput0_3)
self.lblOutput1_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput1_3.setObjectName("lblOutput1_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput1_3)
self.lblOutput2_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput2_3.setObjectName("lblOutput2_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput2_3)
self.lblOutput3_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput3_3.setObjectName("lblOutput3_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput3_3)
self.lblOStatus_3 = QtWidgets.QLabel(self.frmOutput)
self.lblOStatus_3.setGeometry(QtCore.QRect(240, 190, 30, 10))
self.lblOStatus_3.setStyleSheet("Font:Bold;")
self.lblOStatus_3.setObjectName("lblOStatus_3")
self.lblOStatus_4 = QtWidgets.QLabel(self.frmOutput)
self.lblOStatus_4.setGeometry(QtCore.QRect(30, 190, 41, 10))
self.lblOStatus_4.setStyleSheet("Font:Bold;")
self.lblOStatus_4.setObjectName("lblOStatus_4")
self.lytH_Top.addWidget(self.frmOutput)
self.frmInput_2 = QtWidgets.QFrame(self.horizontalLayoutWidget_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(5)
sizePolicy.setVerticalStretch(12)
sizePolicy.setHeightForWidth(self.frmInput_2.sizePolicy().hasHeightForWidth())
self.frmInput_2.setSizePolicy(sizePolicy)
self.frmInput_2.setMinimumSize(QtCore.QSize(95, 208))
self.frmInput_2.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmInput_2.setFrameShape(QtWidgets.QFrame.Box)
self.frmInput_2.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmInput_2.setLineWidth(1)
self.frmInput_2.setObjectName("frmInput_2")
self.layoutWidget_7 = QtWidgets.QWidget(self.frmInput_2)
self.layoutWidget_7.setGeometry(QtCore.QRect(10, 10, 35, 178))
self.layoutWidget_7.setObjectName("layoutWidget_7")
self.lytV_Input_label_4 = QtWidgets.QVBoxLayout(self.layoutWidget_7)
self.lytV_Input_label_4.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_label_4.setSpacing(12)
self.lytV_Input_label_4.setObjectName("lytV_Input_label_4")
self.lblInput0_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput0_4.setObjectName("lblInput0_4")
self.lytV_Input_label_4.addWidget(self.lblInput0_4)
self.lblInput1_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput1_4.setObjectName("lblInput1_4")
self.lytV_Input_label_4.addWidget(self.lblInput1_4)
self.lblInput2_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput2_4.setObjectName("lblInput2_4")
self.lytV_Input_label_4.addWidget(self.lblInput2_4)
self.lblInput3_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput3_4.setObjectName("lblInput3_4")
self.lytV_Input_label_4.addWidget(self.lblInput3_4)
self.layoutWidget_8 = QtWidgets.QWidget(self.frmInput_2)
self.layoutWidget_8.setGeometry(QtCore.QRect(40, 10, 46, 178))
self.layoutWidget_8.setObjectName("layoutWidget_8")
self.lytV_Input_Status_4 = QtWidgets.QVBoxLayout(self.layoutWidget_8)
self.lytV_Input_Status_4.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_Status_4.setSpacing(12)
self.lytV_Input_Status_4.setObjectName("lytV_Input_Status_4")
self.lblInput0_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput0_Status_4.setObjectName("lblInput0_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput0_Status_4)
self.lblInput1_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput1_Status_4.setObjectName("lblInput1_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput1_Status_4)
self.lblInput2_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput2_Status_4.setObjectName("lblInput2_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput2_Status_4)
self.lblInput3_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput3_Status_4.setObjectName("lblInput3_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput3_Status_4)
self.lblOStatus_5 = QtWidgets.QLabel(self.frmInput_2)
self.lblOStatus_5.setGeometry(QtCore.QRect(30, 190, 30, 10))
self.lblOStatus_5.setStyleSheet("Font:Bold;")
self.lblOStatus_5.setObjectName("lblOStatus_5")
self.lytH_Top.addWidget(self.frmInput_2)
self.frmInput_3 = QtWidgets.QFrame(self.horizontalLayoutWidget_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(5)
sizePolicy.setVerticalStretch(12)
sizePolicy.setHeightForWidth(self.frmInput_3.sizePolicy().hasHeightForWidth())
self.frmInput_3.setSizePolicy(sizePolicy)
self.frmInput_3.setMinimumSize(QtCore.QSize(95, 208))
self.frmInput_3.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmInput_3.setFrameShape(QtWidgets.QFrame.Box)
self.frmInput_3.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmInput_3.setLineWidth(1)
self.frmInput_3.setObjectName("frmInput_3")
self.layoutWidget_9 = QtWidgets.QWidget(self.frmInput_3)
self.layoutWidget_9.setGeometry(QtCore.QRect(10, 10, 35, 178))
self.layoutWidget_9.setObjectName("layoutWidget_9")
self.lytV_Input_label_5 = QtWidgets.QVBoxLayout(self.layoutWidget_9)
self.lytV_Input_label_5.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_label_5.setSpacing(12)
self.lytV_Input_label_5.setObjectName("lytV_Input_label_5")
self.lblInput0_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput0_5.setObjectName("lblInput0_5")
self.lytV_Input_label_5.addWidget(self.lblInput0_5)
self.lblInput1_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput1_5.setObjectName("lblInput1_5")
self.lytV_Input_label_5.addWidget(self.lblInput1_5)
self.lblInput2_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput2_5.setObjectName("lblInput2_5")
self.lytV_Input_label_5.addWidget(self.lblInput2_5)
self.lblInput3_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput3_5.setObjectName("lblInput3_5")
self.lytV_Input_label_5.addWidget(self.lblInput3_5)
self.layoutWidget_10 = QtWidgets.QWidget(self.frmInput_3)
self.layoutWidget_10.setGeometry(QtCore.QRect(40, 10, 46, 178))
self.layoutWidget_10.setObjectName("layoutWidget_10")
self.lytV_Input_Status_5 = QtWidgets.QVBoxLayout(self.layoutWidget_10)
self.lytV_Input_Status_5.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_Status_5.setSpacing(12)
self.lytV_Input_Status_5.setObjectName("lytV_Input_Status_5")
self.lblInput0_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput0_Status_5.setObjectName("lblInput0_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput0_Status_5)
self.lblInput1_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput1_Status_5.setObjectName("lblInput1_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput1_Status_5)
self.lblInput2_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput2_Status_5.setObjectName("lblInput2_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput2_Status_5)
self.lblInput3_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput3_Status_5.setObjectName("lblInput3_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput3_Status_5)
self.lblOStatus_6 = QtWidgets.QLabel(self.frmInput_3)
self.lblOStatus_6.setGeometry(QtCore.QRect(30, 190, 30, 10))
self.lblOStatus_6.setStyleSheet("Font:Bold;")
self.lblOStatus_6.setObjectName("lblOStatus_6")
self.lytH_Top.addWidget(self.frmInput_3)
self.lytH_Top.setStretch(0, 10)
self.lytH_Top.setStretch(1, 10)
self.horizontalLayoutWidget_3 = QtWidgets.QWidget(self.centralwidget)
self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(10, 290, 791, 210))
self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3")
self.lytH_Chart = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3)
self.lytH_Chart.setContentsMargins(1, 0, 0, 0)
self.lytH_Chart.setSpacing(3)
self.lytH_Chart.setObjectName("lytH_Chart")
self.widget_Chart = QtWidgets.QWidget(self.horizontalLayoutWidget_3)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.widget_Chart.sizePolicy().hasHeightForWidth())
self.widget_Chart.setSizePolicy(sizePolicy)
self.widget_Chart.setObjectName("widget_Chart")
self.lytH_Chart.addWidget(self.widget_Chart)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 923, 18))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.lblTitle.setText(_translate("MainWindow",
"<html><head/><body><p align=\"center\"><span style=\" font-size:16pt; font-weight:600;\">TEST DATA SHOW</span></p></body></html>"))
self.lblInput0_3.setText(_translate("MainWindow", "Input0"))
self.lblInput1_3.setText(_translate("MainWindow", "Input1"))
self.lblInput2_3.setText(_translate("MainWindow", "Input2"))
self.lblInput3_3.setText(_translate("MainWindow", "Input3"))
self.lblInput0_Status_3.setText(_translate("MainWindow", "0"))
self.lblInput1_Status_3.setText(_translate("MainWindow", "0"))
self.lblInput2_Status_3.setText(_translate("MainWindow", "0"))
self.lblInput3_Status_3.setText(_translate("MainWindow", "0"))
self.lblOStatus_2.setText(_translate("MainWindow", "INPUT"))
self.lblOutput0_Status_3.setText(_translate("MainWindow", "0"))
self.lblOutput1_Status_3.setText(_translate("MainWindow", "0"))
self.lblOutput2_Status_3.setText(_translate("MainWindow", "0"))
self.lblOutput3_Status_3.setText(_translate("MainWindow", "0"))
self.lblOutput0_3.setText(_translate("MainWindow", "Output0"))
self.lblOutput1_3.setText(_translate("MainWindow", "Output1"))
self.lblOutput2_3.setText(_translate("MainWindow", "Output2"))
self.lblOutput3_3.setText(_translate("MainWindow", "Output3"))
self.lblOStatus_3.setText(_translate("MainWindow", "INPUT"))
self.lblOStatus_4.setText(_translate("MainWindow", "<html><head/><body><p>OUTPUT</p></body></html>"))
self.lblInput0_4.setText(_translate("MainWindow", "Input0"))
self.lblInput1_4.setText(_translate("MainWindow", "Input1"))
self.lblInput2_4.setText(_translate("MainWindow", "Input2"))
self.lblInput3_4.setText(_translate("MainWindow", "Input3"))
self.lblInput0_Status_4.setText(_translate("MainWindow", "0"))
self.lblInput1_Status_4.setText(_translate("MainWindow", "0"))
self.lblInput2_Status_4.setText(_translate("MainWindow", "0"))
self.lblInput3_Status_4.setText(_translate("MainWindow", "0"))
self.lblOStatus_5.setText(_translate("MainWindow", "INPUT"))
self.lblInput0_5.setText(_translate("MainWindow", "Input0"))
self.lblInput1_5.setText(_translate("MainWindow", "Input1"))
self.lblInput2_5.setText(_translate("MainWindow", "Input2"))
self.lblInput3_5.setText(_translate("MainWindow", "Input3"))
self.lblInput0_Status_5.setText(_translate("MainWindow", "0"))
self.lblInput1_Status_5.setText(_translate("MainWindow", "0"))
self.lblInput2_Status_5.setText(_translate("MainWindow", "0"))
self.lblInput3_Status_5.setText(_translate("MainWindow", "0"))
self.lblOStatus_6.setText(_translate("MainWindow", "INPUT"))
def create_bar(self):
# The QBarSet class represents a set of bars in the bar chart.
# It groups several bars into a bar set
set0 = QBarSet("Parwiz")
set1 = QBarSet("Bob")
set2 = QBarSet("Tom")
set3 = QBarSet("Logan")
set4 = QBarSet("Karim")
set0 << 1 << 2 << 3 << 4 << 5 << 6
set1 << 5 << 0 << 0 << 4 << 0 << 7
set2 << 3 << 5 << 8 << 13 << 8 << 5
set3 << 5 << 6 << 7 << 3 << 4 << 5
set4 << 9 << 7 << 5 << 3 << 1 << 2
series = QPercentBarSeries()
series.append(set0)
series.append(set1)
series.append(set2)
series.append(set3)
series.append(set4)
chart = QChart()
chart.addSeries(series)
chart.setTitle("Percent Example")
chart.setAnimationOptions(QChart.SeriesAnimations)
categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
axis = QBarCategoryAxis()
axis.append(categories)
chart.createDefaultAxes()
chart.setAxisX(axis, series)
chart.legend().setVisible(True)
chart.legend().setAlignment(Qt.AlignBottom)
chartView = QChartView(chart)
chartView.setRenderHint(QPainter.Antialiasing)
self.lytH_Chart.addWidget(chartView)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
ui.create_bar()
MainWindow.show()
sys.exit(app.exec_())
I am using QFrame to show a box around each set of Data. I tried to set the Horizontal and Vertical Policy under size policy as expanding also.
Nothing happens. I even used horizontal spacers.
Can some please guide. Thanks

Ok. I am still learning the QT Designer. I could find out the problem.
In fact the 3 Horizontal layouts should go into a main layout (I used a vertical layout).
This solved my problem.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'prodialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtChart import QChart, QChartView, QBarSet, QPercentBarSeries, QBarCategoryAxis
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QWidget
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(941, 545)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.lytHTitle = QtWidgets.QHBoxLayout()
self.lytHTitle.setObjectName("lytHTitle")
self.lblTitle = QtWidgets.QLabel(Dialog)
self.lblTitle.setObjectName("lblTitle")
self.lytHTitle.addWidget(self.lblTitle)
self.verticalLayout.addLayout(self.lytHTitle)
self.lytH_Top = QtWidgets.QHBoxLayout()
self.lytH_Top.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize)
self.lytH_Top.setSpacing(10)
self.lytH_Top.setObjectName("lytH_Top")
self.frmInput = QtWidgets.QFrame(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.frmInput.sizePolicy().hasHeightForWidth())
self.frmInput.setSizePolicy(sizePolicy)
self.frmInput.setMinimumSize(QtCore.QSize(95, 208))
self.frmInput.setMaximumSize(QtCore.QSize(120, 208))
self.frmInput.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmInput.setFrameShape(QtWidgets.QFrame.Box)
self.frmInput.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmInput.setLineWidth(1)
self.frmInput.setObjectName("frmInput")
self.layoutWidget_5 = QtWidgets.QWidget(self.frmInput)
self.layoutWidget_5.setGeometry(QtCore.QRect(10, 10, 35, 178))
self.layoutWidget_5.setObjectName("layoutWidget_5")
self.lytV_Input_label_3 = QtWidgets.QVBoxLayout(self.layoutWidget_5)
self.lytV_Input_label_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_label_3.setSpacing(12)
self.lytV_Input_label_3.setObjectName("lytV_Input_label_3")
self.lblInput0_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput0_3.setObjectName("lblInput0_3")
self.lytV_Input_label_3.addWidget(self.lblInput0_3)
self.lblInput1_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput1_3.setObjectName("lblInput1_3")
self.lytV_Input_label_3.addWidget(self.lblInput1_3)
self.lblInput2_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput2_3.setObjectName("lblInput2_3")
self.lytV_Input_label_3.addWidget(self.lblInput2_3)
self.lblInput3_3 = QtWidgets.QLabel(self.layoutWidget_5)
self.lblInput3_3.setObjectName("lblInput3_3")
self.lytV_Input_label_3.addWidget(self.lblInput3_3)
self.layoutWidget_6 = QtWidgets.QWidget(self.frmInput)
self.layoutWidget_6.setGeometry(QtCore.QRect(40, 10, 46, 178))
self.layoutWidget_6.setObjectName("layoutWidget_6")
self.lytV_Input_Status_3 = QtWidgets.QVBoxLayout(self.layoutWidget_6)
self.lytV_Input_Status_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_Status_3.setSpacing(12)
self.lytV_Input_Status_3.setObjectName("lytV_Input_Status_3")
self.lblInput0_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput0_Status_3.setObjectName("lblInput0_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput0_Status_3)
self.lblInput1_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput1_Status_3.setObjectName("lblInput1_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput1_Status_3)
self.lblInput2_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput2_Status_3.setObjectName("lblInput2_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput2_Status_3)
self.lblInput3_Status_3 = QtWidgets.QLabel(self.layoutWidget_6)
self.lblInput3_Status_3.setObjectName("lblInput3_Status_3")
self.lytV_Input_Status_3.addWidget(self.lblInput3_Status_3)
self.lblOStatus_2 = QtWidgets.QLabel(self.frmInput)
self.lblOStatus_2.setGeometry(QtCore.QRect(30, 190, 30, 10))
self.lblOStatus_2.setStyleSheet("Font:Bold;")
self.lblOStatus_2.setObjectName("lblOStatus_2")
self.lytH_Top.addWidget(self.frmInput)
self.frmOutput = QtWidgets.QFrame(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.frmOutput.sizePolicy().hasHeightForWidth())
self.frmOutput.setSizePolicy(sizePolicy)
self.frmOutput.setMinimumSize(QtCore.QSize(95, 208))
self.frmOutput.setMaximumSize(QtCore.QSize(120, 208))
self.frmOutput.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmOutput.setFrameShape(QtWidgets.QFrame.Box)
self.frmOutput.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmOutput.setLineWidth(1)
self.frmOutput.setObjectName("frmOutput")
self.verticalLayoutWidget_22 = QtWidgets.QWidget(self.frmOutput)
self.verticalLayoutWidget_22.setGeometry(QtCore.QRect(50, 10, 41, 178))
self.verticalLayoutWidget_22.setObjectName("verticalLayoutWidget_22")
self.lytV_Output_Status_3 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_22)
self.lytV_Output_Status_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Output_Status_3.setSpacing(12)
self.lytV_Output_Status_3.setObjectName("lytV_Output_Status_3")
self.lblOutput0_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput0_Status_3.setObjectName("lblOutput0_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput0_Status_3)
self.lblOutput1_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput1_Status_3.setObjectName("lblOutput1_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput1_Status_3)
self.lblOutput2_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput2_Status_3.setObjectName("lblOutput2_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput2_Status_3)
self.lblOutput3_Status_3 = QtWidgets.QLabel(self.verticalLayoutWidget_22)
self.lblOutput3_Status_3.setObjectName("lblOutput3_Status_3")
self.lytV_Output_Status_3.addWidget(self.lblOutput3_Status_3)
self.verticalLayoutWidget_23 = QtWidgets.QWidget(self.frmOutput)
self.verticalLayoutWidget_23.setGeometry(QtCore.QRect(10, 10, 41, 178))
self.verticalLayoutWidget_23.setObjectName("verticalLayoutWidget_23")
self.lytV_Output_Label_3 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_23)
self.lytV_Output_Label_3.setContentsMargins(7, 3, 4, 4)
self.lytV_Output_Label_3.setSpacing(12)
self.lytV_Output_Label_3.setObjectName("lytV_Output_Label_3")
self.lblOutput0_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput0_3.setObjectName("lblOutput0_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput0_3)
self.lblOutput1_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput1_3.setObjectName("lblOutput1_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput1_3)
self.lblOutput2_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput2_3.setObjectName("lblOutput2_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput2_3)
self.lblOutput3_3 = QtWidgets.QLabel(self.verticalLayoutWidget_23)
self.lblOutput3_3.setObjectName("lblOutput3_3")
self.lytV_Output_Label_3.addWidget(self.lblOutput3_3)
self.lblOStatus_3 = QtWidgets.QLabel(self.frmOutput)
self.lblOStatus_3.setGeometry(QtCore.QRect(240, 190, 30, 10))
self.lblOStatus_3.setStyleSheet("Font:Bold;")
self.lblOStatus_3.setObjectName("lblOStatus_3")
self.lblOStatus_4 = QtWidgets.QLabel(self.frmOutput)
self.lblOStatus_4.setGeometry(QtCore.QRect(30, 190, 41, 10))
self.lblOStatus_4.setStyleSheet("Font:Bold;")
self.lblOStatus_4.setObjectName("lblOStatus_4")
self.lytH_Top.addWidget(self.frmOutput)
self.frmInput_2 = QtWidgets.QFrame(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.frmInput_2.sizePolicy().hasHeightForWidth())
self.frmInput_2.setSizePolicy(sizePolicy)
self.frmInput_2.setMinimumSize(QtCore.QSize(95, 208))
self.frmInput_2.setMaximumSize(QtCore.QSize(120, 208))
self.frmInput_2.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmInput_2.setFrameShape(QtWidgets.QFrame.Box)
self.frmInput_2.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmInput_2.setLineWidth(1)
self.frmInput_2.setObjectName("frmInput_2")
self.layoutWidget_7 = QtWidgets.QWidget(self.frmInput_2)
self.layoutWidget_7.setGeometry(QtCore.QRect(10, 10, 35, 178))
self.layoutWidget_7.setObjectName("layoutWidget_7")
self.lytV_Input_label_4 = QtWidgets.QVBoxLayout(self.layoutWidget_7)
self.lytV_Input_label_4.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_label_4.setSpacing(12)
self.lytV_Input_label_4.setObjectName("lytV_Input_label_4")
self.lblInput0_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput0_4.setObjectName("lblInput0_4")
self.lytV_Input_label_4.addWidget(self.lblInput0_4)
self.lblInput1_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput1_4.setObjectName("lblInput1_4")
self.lytV_Input_label_4.addWidget(self.lblInput1_4)
self.lblInput2_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput2_4.setObjectName("lblInput2_4")
self.lytV_Input_label_4.addWidget(self.lblInput2_4)
self.lblInput3_4 = QtWidgets.QLabel(self.layoutWidget_7)
self.lblInput3_4.setObjectName("lblInput3_4")
self.lytV_Input_label_4.addWidget(self.lblInput3_4)
self.layoutWidget_8 = QtWidgets.QWidget(self.frmInput_2)
self.layoutWidget_8.setGeometry(QtCore.QRect(40, 10, 46, 178))
self.layoutWidget_8.setObjectName("layoutWidget_8")
self.lytV_Input_Status_4 = QtWidgets.QVBoxLayout(self.layoutWidget_8)
self.lytV_Input_Status_4.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_Status_4.setSpacing(12)
self.lytV_Input_Status_4.setObjectName("lytV_Input_Status_4")
self.lblInput0_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput0_Status_4.setObjectName("lblInput0_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput0_Status_4)
self.lblInput1_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput1_Status_4.setObjectName("lblInput1_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput1_Status_4)
self.lblInput2_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput2_Status_4.setObjectName("lblInput2_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput2_Status_4)
self.lblInput3_Status_4 = QtWidgets.QLabel(self.layoutWidget_8)
self.lblInput3_Status_4.setObjectName("lblInput3_Status_4")
self.lytV_Input_Status_4.addWidget(self.lblInput3_Status_4)
self.lblOStatus_5 = QtWidgets.QLabel(self.frmInput_2)
self.lblOStatus_5.setGeometry(QtCore.QRect(30, 190, 30, 10))
self.lblOStatus_5.setStyleSheet("Font:Bold;")
self.lblOStatus_5.setObjectName("lblOStatus_5")
self.lytH_Top.addWidget(self.frmInput_2)
self.frmInput_3 = QtWidgets.QFrame(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(5)
sizePolicy.setVerticalStretch(12)
sizePolicy.setHeightForWidth(self.frmInput_3.sizePolicy().hasHeightForWidth())
self.frmInput_3.setSizePolicy(sizePolicy)
self.frmInput_3.setMinimumSize(QtCore.QSize(95, 208))
self.frmInput_3.setMaximumSize(QtCore.QSize(120, 208))
self.frmInput_3.setStyleSheet("background-color: rgb(231, 226, 255);")
self.frmInput_3.setFrameShape(QtWidgets.QFrame.Box)
self.frmInput_3.setFrameShadow(QtWidgets.QFrame.Plain)
self.frmInput_3.setLineWidth(1)
self.frmInput_3.setObjectName("frmInput_3")
self.layoutWidget_9 = QtWidgets.QWidget(self.frmInput_3)
self.layoutWidget_9.setGeometry(QtCore.QRect(10, 10, 35, 178))
self.layoutWidget_9.setObjectName("layoutWidget_9")
self.lytV_Input_label_5 = QtWidgets.QVBoxLayout(self.layoutWidget_9)
self.lytV_Input_label_5.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_label_5.setSpacing(12)
self.lytV_Input_label_5.setObjectName("lytV_Input_label_5")
self.lblInput0_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput0_5.setObjectName("lblInput0_5")
self.lytV_Input_label_5.addWidget(self.lblInput0_5)
self.lblInput1_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput1_5.setObjectName("lblInput1_5")
self.lytV_Input_label_5.addWidget(self.lblInput1_5)
self.lblInput2_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput2_5.setObjectName("lblInput2_5")
self.lytV_Input_label_5.addWidget(self.lblInput2_5)
self.lblInput3_5 = QtWidgets.QLabel(self.layoutWidget_9)
self.lblInput3_5.setObjectName("lblInput3_5")
self.lytV_Input_label_5.addWidget(self.lblInput3_5)
self.layoutWidget_10 = QtWidgets.QWidget(self.frmInput_3)
self.layoutWidget_10.setGeometry(QtCore.QRect(40, 10, 46, 178))
self.layoutWidget_10.setObjectName("layoutWidget_10")
self.lytV_Input_Status_5 = QtWidgets.QVBoxLayout(self.layoutWidget_10)
self.lytV_Input_Status_5.setContentsMargins(7, 3, 4, 4)
self.lytV_Input_Status_5.setSpacing(12)
self.lytV_Input_Status_5.setObjectName("lytV_Input_Status_5")
self.lblInput0_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput0_Status_5.setObjectName("lblInput0_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput0_Status_5)
self.lblInput1_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput1_Status_5.setObjectName("lblInput1_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput1_Status_5)
self.lblInput2_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput2_Status_5.setObjectName("lblInput2_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput2_Status_5)
self.lblInput3_Status_5 = QtWidgets.QLabel(self.layoutWidget_10)
self.lblInput3_Status_5.setObjectName("lblInput3_Status_5")
self.lytV_Input_Status_5.addWidget(self.lblInput3_Status_5)
self.lblOStatus_6 = QtWidgets.QLabel(self.frmInput_3)
self.lblOStatus_6.setGeometry(QtCore.QRect(30, 190, 30, 10))
self.lblOStatus_6.setStyleSheet("Font:Bold;")
self.lblOStatus_6.setObjectName("lblOStatus_6")
self.lytH_Top.addWidget(self.frmInput_3)
self.lytH_Top.setStretch(1, 10)
self.verticalLayout.addLayout(self.lytH_Top)
self.lytH_Chart = QtWidgets.QHBoxLayout()
self.lytH_Chart.setContentsMargins(1, -1, -1, -1)
self.lytH_Chart.setSpacing(3)
self.lytH_Chart.setObjectName("lytH_Chart")
self.widget_Chart = QtWidgets.QWidget(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.widget_Chart.sizePolicy().hasHeightForWidth())
self.widget_Chart.setSizePolicy(sizePolicy)
self.widget_Chart.setLayoutDirection(QtCore.Qt.LeftToRight)
self.widget_Chart.setObjectName("widget_Chart")
self.lytH_Chart.addWidget(self.widget_Chart)
self.verticalLayout.addLayout(self.lytH_Chart)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.lblTitle.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:16pt; font-weight:600;\">TEST DATA SHOW</span></p></body></html>"))
self.lblInput0_3.setText(_translate("Dialog", "Input0"))
self.lblInput1_3.setText(_translate("Dialog", "Input1"))
self.lblInput2_3.setText(_translate("Dialog", "Input2"))
self.lblInput3_3.setText(_translate("Dialog", "Input3"))
self.lblInput0_Status_3.setText(_translate("Dialog", "0"))
self.lblInput1_Status_3.setText(_translate("Dialog", "0"))
self.lblInput2_Status_3.setText(_translate("Dialog", "0"))
self.lblInput3_Status_3.setText(_translate("Dialog", "0"))
self.lblOStatus_2.setText(_translate("Dialog", "INPUT"))
self.lblOutput0_Status_3.setText(_translate("Dialog", "0"))
self.lblOutput1_Status_3.setText(_translate("Dialog", "0"))
self.lblOutput2_Status_3.setText(_translate("Dialog", "0"))
self.lblOutput3_Status_3.setText(_translate("Dialog", "0"))
self.lblOutput0_3.setText(_translate("Dialog", "Output0"))
self.lblOutput1_3.setText(_translate("Dialog", "Output1"))
self.lblOutput2_3.setText(_translate("Dialog", "Output2"))
self.lblOutput3_3.setText(_translate("Dialog", "Output3"))
self.lblOStatus_3.setText(_translate("Dialog", "INPUT"))
self.lblOStatus_4.setText(_translate("Dialog", "<html><head/><body><p>OUTPUT</p></body></html>"))
self.lblInput0_4.setText(_translate("Dialog", "Input0"))
self.lblInput1_4.setText(_translate("Dialog", "Input1"))
self.lblInput2_4.setText(_translate("Dialog", "Input2"))
self.lblInput3_4.setText(_translate("Dialog", "Input3"))
self.lblInput0_Status_4.setText(_translate("Dialog", "0"))
self.lblInput1_Status_4.setText(_translate("Dialog", "0"))
self.lblInput2_Status_4.setText(_translate("Dialog", "0"))
self.lblInput3_Status_4.setText(_translate("Dialog", "0"))
self.lblOStatus_5.setText(_translate("Dialog", "INPUT"))
self.lblInput0_5.setText(_translate("Dialog", "Input0"))
self.lblInput1_5.setText(_translate("Dialog", "Input1"))
self.lblInput2_5.setText(_translate("Dialog", "Input2"))
self.lblInput3_5.setText(_translate("Dialog", "Input3"))
self.lblInput0_Status_5.setText(_translate("Dialog", "0"))
self.lblInput1_Status_5.setText(_translate("Dialog", "0"))
self.lblInput2_Status_5.setText(_translate("Dialog", "0"))
self.lblInput3_Status_5.setText(_translate("Dialog", "0"))
self.lblOStatus_6.setText(_translate("Dialog", "INPUT"))
def create_bar(self):
# The QBarSet class represents a set of bars in the bar chart.
# It groups several bars into a bar set
set0 = QBarSet("Parwiz")
set1 = QBarSet("Bob")
set2 = QBarSet("Tom")
set3 = QBarSet("Logan")
set4 = QBarSet("Karim")
set0 << 1 << 2 << 3 << 4 << 5 << 6
set1 << 5 << 0 << 0 << 4 << 0 << 7
set2 << 3 << 5 << 8 << 13 << 8 << 5
set3 << 5 << 6 << 7 << 3 << 4 << 5
set4 << 9 << 7 << 5 << 3 << 1 << 2
series = QPercentBarSeries()
series.append(set0)
series.append(set1)
series.append(set2)
series.append(set3)
series.append(set4)
chart = QChart()
chart.addSeries(series)
chart.setTitle("Percent Example")
chart.setAnimationOptions(QChart.SeriesAnimations)
categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
axis = QBarCategoryAxis()
axis.append(categories)
chart.createDefaultAxes()
chart.setAxisX(axis, series)
chart.legend().setVisible(True)
chart.legend().setAlignment(Qt.AlignBottom)
chartView = QChartView(chart)
chartView.setRenderHint(QPainter.Antialiasing)
self.lytH_Chart.addWidget(chartView)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
ui.create_bar()
Dialog.show()
sys.exit(app.exec_())

Related

plot grid not visible in jupyter using matplotlib

Can someone help me identify why the gridlines are missing even though plt.grid() is already added in the code please. Thank you.
km = KMeans(n_clusters = 3, init = 'k-means++', max_iter = 300, n_init = 10, random_state = 0)
y_means = km.fit_predict(x)
plt.scatter(x[y_means == 0, 0], x[y_means == 0, 1], s = 100, c = 'pink', label = 'Uninterested Customers')
plt.scatter(x[y_means == 1, 0], x[y_means == 1, 1], s = 100, c = 'yellow', label = 'General Customers')
plt.scatter(x[y_means == 2, 0], x[y_means == 2, 1], s = 100, c = 'cyan', label = 'Target Customers')
plt.scatter(km.cluster_centers_[:,0], km.cluster_centers_[:, 1], s = 50, c = 'blue' , label = 'centeroid')
plt.title('Administrative Duration vs Duration', fontsize = 20)
plt.grid()
plt.xlabel('Administrative Duration')
plt.ylabel('Bounce Rates')
plt.legend()
plt.show()

How can I keep a subplot table from stretching?

How should I alter the following script to keep the subplot (on right_ from stretching? Is there a way to set either plot area of the subplot? Frustrating as I go thru the row/column sizing in the function, but when plot it just expands to fill the area. In the left subplot is the full list (22 rows). In the right I just pass half the df rows, and it fills vertically? Thx.
import pandas as pd
import matplotlib.pyplot as plt
import six
plt.rcParams['font.family'] = "Lato"
raw_data = dict(TF_001=[42, 39, 86, 15, 23, 57, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25],
SP500=[52, 41, 79, 80, 34, 47, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25],
Strategy=[62, 37, 84, 51, 67, 32, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22,
23, 24, 25],
LP_Port=[72, 43, 36, 26, 53, 88, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25])
df = pd.DataFrame(raw_data, index=pd.Index(
['Sharpe Ratio', 'Sortino Ratio', 'Calmars Ratio', 'Ulcer Index', 'Max Drawdown', 'Volatility',
'VaR', 'CVaR', 'R-Squared', 'CAGR', 'Risk-of-Ruin', 'Gain-Pain Ratio', 'Pitfall Indicator',
'Serentity Ratio', 'Common Sense Ratio', 'Kelly Criteria', 'Payoff Ratio', 'Ratio-A',
'Ratio-B', 'Ratio-C', 'Ratio-D', 'Ratio-E'], name='Metric'),
columns=pd.Index(['TF_001', 'SP500', 'Strategy', 'LP_Port'], name='Series'))
def create_table(data,
ax=None,
col_width=None,
row_height=None,
font_size=8,
header_color='#E5E5E5',
row_colors=None,
edge_color='w',
header_columns=0,
bbox=None):
if row_colors is None:
row_colors = ['#F1F8E9', 'w']
if bbox is None:
bbox = [0, 0, 1, 1]
data_table = ax.table(cellText=data.values,
colLabels=data.columns,
rowLabels=data.index,
bbox=bbox,
cellLoc='center',
rowLoc='left',
colLoc='center',
colWidths=([col_width] * len(data.columns)))
cell_map = data_table.get_celld()
for i in range(0, len(data.columns)):
cell_map[(0, i)].set_height(row_height * 0.2)
data_table.auto_set_font_size(False)
data_table.set_fontsize(font_size)
for k, cell in six.iteritems(data_table._cells):
cell.set_edgecolor(edge_color)
if k[0] == 0 or k[1] < header_columns:
cell.set_text_props(weight='heavy', color='black')
cell.set_facecolor(header_color)
else:
cell.set_facecolor(row_colors[k[0] % len(row_colors)])
for row, col in data_table._cells:
if (row == 0) or (col == -1):
data_table._cells[(row, col)].set_alpha(0.8)
return ax
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 7), constrained_layout=False)
create_table(df, ax1, col_width=1.1, row_height=0.25, font_size=8)
create_table(df.iloc[0:11, ], ax2, col_width=1.1, row_height=0.25, font_size=8)
ax1.set_title("- Conventional Risk Measures -",
fontsize=10,
fontweight='heavy',
loc='center')
ax1.axis('off')
ax2.set_title("- Second Order Risk Measures -",
fontsize=10,
fontweight='heavy',
loc='center')
ax2.axis('off')
plt.suptitle('EF QuantOne - Performance and Risk Assessment ("PaRA")',
x=0.0175,
y=0.9775,
ha='left',
fontsize=12,
weight='heavy')
plt.tight_layout()
plt.savefig('risk_parameter_table[1].pdf',
orientation='portrait',
pad_inches=0.5)
plt.show()
Figured it out ...
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import six
plt.rcParams['font.family'] = "Lato"
raw_data = dict(TF_001=[42, 39, 86, 15, 23, 57, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25],
SP500=[52, 41, 79, 80, 34, 47, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25],
Strategy=[62, 37, 84, 51, 67, 32, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22,
23, 24, 25],
LP_Port=[72, 43, 36, 26, 53, 88, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25])
df = pd.DataFrame(raw_data, index=pd.Index(
['Sharpe Ratio', 'Sortino Ratio', 'Calmars Ratio', 'Ulcer Index', 'Max Drawdown', 'Volatility',
'VaR', 'CVaR', 'R-Squared', 'CAGR', 'Risk-of-Ruin', 'Gain-Pain Ratio', 'Pitfall Indicator',
'Serentity Ratio', 'Common Sense Ratio', 'Kelly Criteria', 'Payoff Ratio', 'Ratio-A',
'Ratio-B', 'Ratio-C', 'Ratio-D', 'Ratio-E'], name='Metric'),
columns=pd.Index(['TF_001', 'SP500', 'Strategy', 'LP_Port'], name='Series'))
def create_table(data,
ax=None,
col_width=None,
row_height=None,
font_size=8,
header_color='#E5E5E5',
row_colors=None,
edge_color='w',
header_columns=0,
bbox=None):
if row_colors is None:
row_colors = ['#F1F8E9', 'w']
if bbox is None:
bbox = [0, 0, 1, 1]
data_table = ax.table(cellText=data.values,
colLabels=data.columns,
rowLabels=data.index,
bbox=bbox,
cellLoc='center',
rowLoc='left',
colLoc='center',
colWidths=([col_width] * len(data.columns)))
cell_map = data_table.get_celld()
for i in range(0, len(data.columns)):
cell_map[(0, i)].set_height(row_height * 0.2)
data_table.auto_set_font_size(False)
data_table.set_fontsize(font_size)
for k, cell in six.iteritems(data_table._cells):
cell.set_edgecolor(edge_color)
if k[0] == 0 or k[1] < header_columns:
cell.set_text_props(weight='heavy', color='black')
cell.set_facecolor(header_color)
else:
cell.set_facecolor(row_colors[k[0] % len(row_colors)])
for row, col in data_table._cells:
if (row == 0) or (col == -1):
data_table._cells[(row, col)].set_alpha(0.8)
return ax
# fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11, 8.5), constrained_layout=False)
fig = plt.figure(figsize=(12, 10))
w, h = fig.get_size_inches()
div = np.array([w, h, w, h])
col_width = 1.1
row_height = 0.25
ax1_subplot_size = (np.array(df.shape[::-1]) + np.array([0, 1])) * np.array(
[col_width, row_height])
ax1 = fig.add_axes(np.array([1.6, 1, 4.4, 5.75]) / div)
ax2_subplot_size = (np.array(df.shape[::-1]) + np.array([0, 1])) * np.array(
[col_width, row_height])
ax2 = fig.add_axes(np.array([7.5, 3.75, 4.4, 3]) / div)
create_table(df, ax1, col_width, row_height, font_size=8)
create_table(df.iloc[0:11, ], ax2, col_width, row_height, font_size=8)
ax1.set_title("- Conventional Risk Measures -",
fontsize=10,
fontweight='heavy',
loc='center')
ax1.axis('off')
ax2.set_title("- Second Order Risk Measures -",
fontsize=10,
fontweight='heavy',
loc='center')
ax2.axis('off')
plt.suptitle('EF QuantOne - Performance and Risk Assessment ("PaRA")',
x=0.0175,
y=0.9775,
ha='left',
fontsize=12,
weight='heavy')
# plt.tight_layout()
plt.savefig('risk_parameter_table[1].pdf',
orientation='portrait',
pad_inches=0.5)
plt.show()

Variable number of reduce sums in tensorflow

Consider the situation:
token_ids = [17, 189, 981, 1000, 11, 42, 109, 26, 3377, 261]
word_ids = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2]
where I need to compute the sum of token_ids reduced for each word_id like so:
output = [ (emb[17] + emb[189] + emb[981] + emb [1000]),
(emb[11] + emb[42] + emb[109]),
(emb[26] + emb[3377] + emb[261]) ]
where emb is any embedding matrix.
I can write this code in python using for-loop like so:
prev = 0
sum_all = []
sum = 0
for i in range(len(word_ids)):
if word_ids[i] == prev:
sum += emb[token_ids[i]]
else:
sum_all += [sum]
sum = emb[token_ids[i]]
prev = word_ids[i]
if i == len(word_ids):
sum_all += [sum]
return sum_all
But I want to do it in tensorflow efficiently (vectorized if possible). Can anybody please give suggestions how to go about doing this ?
You need tf.segment_sum to computes the sum along segments of a tensor..
import tensorflow as tf
token_ids = tf.constant([17, 189, 981, 1000, 11, 42, 109, 26, 3377, 261],tf.int32)
word_ids = tf.constant([0, 0, 0, 0, 1, 1, 1, 2, 2, 2],tf.int32)
emb_matrix = tf.ones(shape=(4000,3))
emb = tf.nn.embedding_lookup(emb_matrix, token_ids)
result = tf.segment_sum(emb,word_ids)
with tf.Session() as sess:
print(sess.run(result))
[[4. 4. 4.]
[3. 3. 3.]
[3. 3. 3.]]

MatPlotLib PyQt5 Layout Problems

MatPlotLib PyQt5 Layout Problems:
Using horizontal and vertical layouts, it seems to be very difficult to get the widgets where I want them. Maybe there is another way of doing it, for instance:
If one can put the canvas and toolbar in a container or some kind of widget. Then you can size it and put it where you want.
If one can limit the size of the plot so that the UI in the background is visible. This seems impossible though.
What about using QGridLayout?
I have tried many things, but am very confused and nothing seems to work.
The problems I have (using the current horizontal and vertical layouts) are:
The labels drift and are not aligned with the widgets.
The buttonbox is too wide. Can the buttons be split between the last two columns?
Here is some code. Sorry for the formatting. (It's hard to get the 4 spaces right):
import sys
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
import matplotlib.pyplot as plt
import random
from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QHBoxLayout, QApplication, QDialog, QGridLayout, QLayout
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(QDialog):
def __init__(self, parent=None):
super(Ui_Dialog, self).__init__(parent)
self.setupUi(self)
self.setupPlot()
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(719, 353)
Dialog.setWindowTitle("Task")
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(590, 310, 121, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.label1 = QtWidgets.QLabel(Dialog)
self.label1.setGeometry(QtCore.QRect(590, 40, 51, 16))
self.label1.setText("label1:")
self.label1.setObjectName("label1")
self.label2 = QtWidgets.QLabel(Dialog)
self.label2.setGeometry(QtCore.QRect(590, 70, 41, 16))
self.label2.setText("label2:")
self.label2.setObjectName("label2")
self.cBox1 = QtWidgets.QComboBox(Dialog)
self.cBox1.setGeometry(QtCore.QRect(650, 40, 61, 22))
self.cBox1.setLayoutDirection(QtCore.Qt.LeftToRight)
self.cBox1.setEditable(False)
self.cBox1.setCurrentText("Option0")
self.cBox1.setMaxVisibleItems(2)
self.cBox1.setObjectName("cBox1")
self.cBox1.addItem("")
self.cBox1.setItemText(0, "Option0")
self.cBox1.addItem("")
self.cBox1.setItemText(1, "Option1")
self.label5 = QtWidgets.QLabel(Dialog)
self.label5.setGeometry(QtCore.QRect(590, 160, 51, 16))
self.label5.setText("label5:")
self.label5.setObjectName("label5")
self.dSpinBox5 = QtWidgets.QDoubleSpinBox(Dialog)
self.dSpinBox5.setGeometry(QtCore.QRect(650, 160, 62, 22))
self.dSpinBox5.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.dSpinBox5.setMaximum(1999.99)
self.dSpinBox5.setObjectName("dSpinBox5")
self.dSpinBox4 = QtWidgets.QDoubleSpinBox(Dialog)
self.dSpinBox4.setGeometry(QtCore.QRect(650, 130, 62, 22))
self.dSpinBox4.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.dSpinBox4.setMaximum(1999.99)
self.dSpinBox4.setObjectName("dSpinBox4")
self.label0 = QtWidgets.QLabel(Dialog)
self.label0.setGeometry(QtCore.QRect(590, 10, 41, 16))
self.label0.setText("label0:")
self.label0.setObjectName("label0")
self.dSpinBox3 = QtWidgets.QDoubleSpinBox(Dialog)
self.dSpinBox3.setGeometry(QtCore.QRect(650, 100, 62, 22))
self.dSpinBox3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.dSpinBox3.setMaximum(1999.99)
self.dSpinBox3.setObjectName("dSpinBox3")
self.label3 = QtWidgets.QLabel(Dialog)
self.label3.setGeometry(QtCore.QRect(590, 100, 61, 16))
self.label3.setText("label3:")
self.label3.setObjectName("label3")
self.lineEdit0 = QtWidgets.QLineEdit(Dialog)
self.lineEdit0.setGeometry(QtCore.QRect(650, 10, 61, 20))
self.lineEdit0.setInputMask("")
self.lineEdit0.setText("")
self.lineEdit0.setObjectName("lineEdit0")
self.label4 = QtWidgets.QLabel(Dialog)
self.label4.setGeometry(QtCore.QRect(590, 130, 41, 16))
self.label4.setText("label4:")
self.label4.setObjectName("label4")
self.spinBox2 = QtWidgets.QSpinBox(Dialog)
self.spinBox2.setGeometry(QtCore.QRect(650, 70, 61, 22))
self.spinBox2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.spinBox2.setMaximum(999)
self.spinBox2.setSingleStep(10)
self.spinBox2.setProperty("value", 50)
self.spinBox2.setObjectName("spinBox2")
self.label6 = QtWidgets.QLabel(Dialog)
self.label6.setGeometry(QtCore.QRect(590, 190, 41, 16))
self.label6.setText("label6:")
self.label6.setObjectName("label6")
self.dSpinBox6 = QtWidgets.QDoubleSpinBox(Dialog)
self.dSpinBox6.setGeometry(QtCore.QRect(650, 190, 62, 22))
self.dSpinBox6.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.dSpinBox6.setReadOnly(True)
self.dSpinBox6.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
self.dSpinBox6.setObjectName("dSpinBox6")
self.label7 = QtWidgets.QLabel(Dialog)
self.label7.setGeometry(QtCore.QRect(590, 220, 47, 16))
self.label7.setText("label7:")
self.label7.setObjectName("label7")
self.spinBox7 = QtWidgets.QSpinBox(Dialog)
self.spinBox7.setGeometry(QtCore.QRect(650, 220, 61, 22))
self.spinBox7.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.spinBox7.setMaximum(999)
self.spinBox7.setProperty("value", 50)
self.spinBox7.setObjectName("spinBox7")
self.checkBox8 = QtWidgets.QCheckBox(Dialog)
self.checkBox8.setGeometry(QtCore.QRect(650, 250, 61, 20))
self.checkBox8.setLayoutDirection(QtCore.Qt.RightToLeft)
self.checkBox8.setText("")
self.checkBox8.setCheckable(False)
self.checkBox8.setObjectName("checkBox8")
self.checkBox9 = QtWidgets.QCheckBox(Dialog)
self.checkBox9.setGeometry(QtCore.QRect(650, 280, 61, 20))
self.checkBox9.setLayoutDirection(QtCore.Qt.RightToLeft)
self.checkBox9.setText("")
self.checkBox9.setCheckable(False)
self.checkBox9.setObjectName("checkBox9")
self.label8 = QtWidgets.QLabel(Dialog)
self.label8.setGeometry(QtCore.QRect(590, 250, 51, 16))
self.label8.setText("label8")
self.label8.setObjectName("label8")
self.label9 = QtWidgets.QLabel(Dialog)
self.label9.setGeometry(QtCore.QRect(590, 276, 47, 16))
self.label9.setText("label9")
self.label9.setObjectName("label9")
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupPlot(self):
self.setLayout(QHBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.figure = plt.figure()
self.figure.set_facecolor("none")
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.widget = QtWidgets.QWidget()
layout = QVBoxLayout()
self.widget.setLayout(layout)
layout.addWidget(self.toolbar)
layout.addWidget(self.canvas)
self.layout().addWidget(self.widget)
self.widget = QtWidgets.QWidget()
layout = QVBoxLayout()
self.widget.setLayout(layout)
layout.addWidget(self.label0)
layout.addWidget(self.label1)
layout.addWidget(self.label2)
layout.addWidget(self.label3)
layout.addWidget(self.label4)
layout.addWidget(self.label5)
layout.addWidget(self.label6)
layout.addWidget(self.label7)
layout.addWidget(self.label8)
layout.addWidget(self.label9)
self.layout().addWidget(self.widget)
self.widget = QtWidgets.QWidget()
layout = QVBoxLayout()
self.widget.setLayout(layout)
layout.addWidget(self.lineEdit0)
layout.addWidget(self.cBox1)
layout.addWidget(self.spinBox2)
layout.addWidget(self.dSpinBox3)
layout.addWidget(self.dSpinBox4)
layout.addWidget(self.dSpinBox5)
layout.addWidget(self.dSpinBox6)
layout.addWidget(self.spinBox7)
layout.addWidget(self.checkBox8)
layout.addWidget(self.checkBox9)
layout.addWidget(self.buttonBox)
self.layout().addWidget(self.widget)
self.plot()
def plot(self):
data = [random.random() for i in range(10)]
self.figure.clear()
ax = self.figure.add_subplot(111)
ax.plot(data, '*-')
self.canvas.draw()
if __name__ == '__main__':
app = QApplication(sys.argv)
main = Ui_Dialog()
main.show()
sys.exit(app.exec_())
#ImportanceOfBeingErnest Your comment is what solved the question. Appreciated:
Removed all the setGeometry calls.
Created a QGridLayout .
Added widgets to the gridLayout like this:
self.layout().addWidget(self.checkBoxDone, 3, 4, 1, 1)
NB: Be careful not to confuse the parameters:
widget
start row (from 0 at the top)
start column (from 0 on the left)
number of rows to span (downwards)
number of columns to span (to the right)

TypeError: text must be a unicode or bytes for my simple game

My young child has written this the following code which is a simple game based on the classic card game bank or bust. When the code is run it throws up the following error message, however they cannot work out why this is happening. We have looked high and low for an answer and have decided to seek some expert advice. I am not a programmer but my child has really taken to Python and is starting to confuse me. Please can somebody help as it is driving me up the wall as I cannot identify an answer.
The error message is:
Traceback (most recent call last):
File "U:\Razor\Acer Z\programs\python programs\b.py", line 114, in <module>
main()
File "U:\Razor\Acer Z\programs\python programs\b.py", line 72, in main
text10 = font.render(c, 1, BLACK)
TypeError: text must be a unicode or bytes
Any ideas on why this happening??
The source code is as follows:
import pygame
import time
import random
BLACK = ( 0, 0, 0)
WHITE = ( 255, 255, 255)
BLUE = ( 0, 0, 255)
GREEN = ( 0, 255, 0)
RED = ( 255, 0, 0)
list3 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
list2 = ['alarm']
#list1 = [100, 300, 400, 500, 0]
pygame.init()
size = (600, 700)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Zach's zombie game")
pygame.mouse.set_visible(1)
screen.fill(RED)
pygame.display.flip()
list1 = [2,3]
def main():
k = 0
turn = 0
font = pygame.font.SysFont('Algerian', 18, 0, 0)
text1 = font.render("Ready?: ",1 , BLACK)
screen.blit(text1, [0, 25])
#time.sleep(5)
pygame.display.flip()
time.sleep(2)
f = str(input("ready?: "))
text2 = font.render(f ,1 , BLACK)
screen.blit(text2, [80, 25])
text3 = font.render("s is for start, n is for number, y is yes and nn is for no",1 , BLACK)
screen.blit(text3, [0, 45])
pygame.display.flip()
while True:
turn = turn + 1
c = random.choice (list1)
e = random.choice (list3)
k = k + c
text4 = font.render("Ready?",1 ,BLACK)
screen.blit(text4, [0, 65])
if turn == e and turn > 2:
text5 = font.render("You have got an alarm!!",1 , BLACK)
screen.blit(text5, [0, 85])
k = k - c
text6 = font.render("You have lost:", 1, BLACK)
screen.blit(text6, [0, 105])
text7 = font.render(k, 1, BLACK)
screen.blit(text7, [0, 135])
if turn == 9:
turn = 0
elif turn == e and turn == 1 or 0:
text8 = font.render("You have got an alarm!! You lost 0", 1, BLACK)
screen.blit(text8, [0, 155])
if turn == 9:
turn = 0
else:
text9 = font.render("Your number is:", 1, BLACK)
screen.blit(text9, [0, 175])
text10 = font.render(c, 1, BLACK)
screen.blit(tex10, [0, 195])
text11 = font.render("Do you want to bank?: ", 1, BLACK)
screen.blit(text11, [0, 215])
n = str(input("Do you want to bank?: "))
text12 = font.render(n, 1, BLACK)
screen.blit(text12, [45, 215])
text13 = font.render("Do you want to see how much money you have stored?: ", 1, BLACK)
screen.blit(text13, [0, 235])
s = str(input("Do you want to see how much money is in the bank?: "))
text14 = font.render(s, 1, BLACK)
screen.blit(text14, [75, 255])
if n == 'y':
text15 = font.render("You just stored you money in the bank",1 ,BLACK)
screen.blit(text15, [0, 275])
elif n == 'n' and s == 'y':
text16 = font.render("You have saved: ",1 ,BLACK)
screen.blit(text16, [0, 295])
text17 = font.render(k, 1, BLACK)
screen.blit(text17, [45, 295])
elif s == 'y':
text18 = font.render("You have saved: ",1 ,BLACK)
screen.blit(text17, [0, 315])
text19 = font.render(k, 1, BLACK)
screen.blit(text18, [45, 315])
elif n == 'n':
text20 = font.render("Okay", 1, BLACK)
screen.blit(text20, [0, 335])
time.sleep(1)
if turn == 9:
turn = 0
main()