Widget background not showing PyQt6 - pyqt5

I created a registration widget in qt designer.I am importing the second file into the first one. When I run the code instead of my background is a white window. And there should be a picture that is in the repository. Although the link to the background itself is present
main.py
import sys
from PyQt6.QtWidgets import QApplication, QDialog,QFileDialog
from PyQt6 import QtWidgets
from ui_imagedialog import Ui_ImageDialog
from AboutTheProgram import Ui_AboutTheProgram
class MainWindows(QDialog,Ui_ImageDialog):
def __init__(self):
super().__init__()
self.MainMenu = Ui_ImageDialog
self.setupUi(self)
self.pushLogin.clicked.connect(self.TransitionAboutTheProgram)
# При нажатии на кнопку login перейти на новую страницу
def TransitionAboutTheProgram(self):
abouttheprogram=AboutTheProgram()
window.addWidget(abouttheprogram)
window.setCurrentIndex(window.currentIndex()+1)
class AboutTheProgram(QDialog,Ui_AboutTheProgram):
def __init__(self):
super().__init__()
self.abouttheprogram = Ui_AboutTheProgram
self.setupUi(self)
app = QApplication(sys.argv)
window = QtWidgets.QStackedWidget()
mainwindow=MainWindows()
window.addWidget(mainwindow)
window.show()
sys.exit(app.exec())
ul_imagedialog.py
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_ImageDialog(object):
def setupUi(self, ImageDialog):
ImageDialog.setObjectName("ImageDialog")
ImageDialog.resize(445, 514)
self.widget = QtWidgets.QWidget(parent=ImageDialog)
self.widget.setGeometry(QtCore.QRect(10, 10, 370, 480))
self.widget.setStyleSheet("QPushButton#pushLogin{\n"
" background-color:qlineargradient(spread:pad, x1:0, y1:0.505682, x2:1, y2:0.477, stop:0 rgba(20, 47, 78, 219), stop:1 rgba(85, 98, 112, 226));\n"
" color:rgba(255,255,255,210);\n"
" border_radius:5px;\n"
"}\n"
"QPushButton#pushLogin:hover{\n"
" background-color:qlineargradient(spread:pad, x1:0, y1:0.505682, x2:1, y2:0.477, stop:0 rgba(40, 67, 98, 219), stop:1 rgba(105, 118, 132, 226));\n"
"}\n"
"QPushButton#pushLogin:pressed{\n"
" padding-left:5px;\n"
" padding-top:5px;\n"
" background-color:rgba(105,118,132,200);\n"
"}\n"
"QPushButton#pushUrlDiscord{\n"
" background-color:rgba(0,0,0,0);\n"
" color:rgba(85,98,112,255);\n"
"}\n"
"QPushButton#pushUrlDiscord:hover{\n"
" color:rgba(155,168,182,220);\n"
"}\n"
"QPushButton#pushUrlDiscord:pressed{\n"
" padding-left:5px;\n"
" padding-top:5px;\n"
" color:rgba(115,128,142,255)\n"
"}\n"
"QPushButton#pushUrlGitHub{\n"
" background-color:rgba(0,0,0,0);\n"
" color:rgba(85,98,112,255);\n"
"}\n"
"QPushButton#pushUrlGitHub:hover{\n"
" color:rgba(155,168,182,220);\n"
"}\n"
"QPushButton#pushUrlGitHub:pressed{\n"
" padding-left:5px;\n"
" padding-top:5px;\n"
" color:rgba(115,128,142,255)\n"
"}\n"
"QPushButton#pushUrlFacebook{\n"
" background-color:rgba(0,0,0,0);\n"
" color:rgba(85,98,112,255);\n"
"}\n"
"QPushButton#pushUrlFacebook:hover{\n"
" color:rgba(155,168,182,220);\n"
"}\n"
"QPushButton#pushUrlFacebook:pressed{\n"
" padding-left:5px;\n"
" padding-top:5px;\n"
" color:rgba(115,128,142,255)\n"
"}\n"
"QPushButton#pushUrlYouTube{\n"
" background-color:rgba(0,0,0,0);\n"
" color:rgba(85,98,112,255);\n"
"}\n"
"QPushButton#pushUrlYouTube:hover{\n"
" color:rgba(155,168,182,220);\n"
"}\n"
"QPushButton#pushUrlYouTubek:pressed{\n"
" padding-left:5px;\n"
" padding-top:5px;\n"
" color:rgba(115,128,142,255)\n"
"}")
self.widget.setObjectName("widget")
self.label = QtWidgets.QLabel(parent=self.widget)
self.label.setGeometry(QtCore.QRect(40, 30, 300, 420))
self.label.setStyleSheet("border-image: url(:/image/1618615593_15-phonoteka_org-p-temno-sinii-tsvet-fon-16.jpg);\n"
"border-radius:20px;\n"
"")
self.label.setText("")
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(parent=self.widget)
self.label_2.setGeometry(QtCore.QRect(50, 60, 280, 390))
font = QtGui.QFont()
font.setPointSize(3)
font.setBold(False)
font.setWeight(50)
self.label_2.setFont(font)
self.label_2.setStyleSheet("background-color:rgba(0,0,0,100);\n"
"border-radius:25px;")
self.label_2.setText("")
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(parent=self.widget)
self.label_3.setGeometry(QtCore.QRect(135, 90, 121, 51))
font = QtGui.QFont()
font.setPointSize(20)
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setStyleSheet("color:rgba(255,255,255,210)")
self.label_3.setObjectName("label_3")
self.lineEdit = QtWidgets.QLineEdit(parent=self.widget)
self.lineEdit.setGeometry(QtCore.QRect(90, 150, 200, 40))
font = QtGui.QFont()
font.setPointSize(10)
self.lineEdit.setFont(font)
self.lineEdit.setStyleSheet("background-color:rgba(0,0,0,0);\n"
"border:none;\n"
"border-bottom:2px solid rgba(108,118,132,255);\n"
"color:rgba(255,255,255,230);\n"
"pading-bottom:7px;")
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(parent=self.widget)
self.lineEdit_2.setGeometry(QtCore.QRect(90, 220, 200, 40))
font = QtGui.QFont()
font.setPointSize(10)
self.lineEdit_2.setFont(font)
self.lineEdit_2.setStyleSheet("background-color:rgba(0,0,0,0);\n"
"border:none;\n"
"border-bottom:2px solid rgba(108,118,132,255);\n"
"color:rgba(255,255,255,230);\n"
"pading-bottom:7px;")
self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password)
self.lineEdit_2.setObjectName("lineEdit_2")
self.pushLogin = QtWidgets.QPushButton(parent=self.widget)
self.pushLogin.setGeometry(QtCore.QRect(90, 290, 200, 40))
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.pushLogin.setFont(font)
self.pushLogin.setObjectName("pushLogin")
self.label_4 = QtWidgets.QLabel(parent=self.widget)
self.label_4.setGeometry(QtCore.QRect(110, 350, 201, 21))
self.label_4.setStyleSheet("color:rgba(255,255,255,140);")
self.label_4.setObjectName("label_4")
self.pushUrlDiscord = QtWidgets.QPushButton(parent=self.widget)
self.pushUrlDiscord.setGeometry(QtCore.QRect(90, 400, 30, 30))
self.pushUrlDiscord.setMaximumSize(QtCore.QSize(30, 30))
font = QtGui.QFont()
font.setFamily("Social Media Circled")
font.setPointSize(15)
self.pushUrlDiscord.setFont(font)
self.pushUrlDiscord.setObjectName("pushUrlDiscord")
self.pushUrlGitHub = QtWidgets.QPushButton(parent=self.widget)
self.pushUrlGitHub.setGeometry(QtCore.QRect(140, 400, 30, 30))
self.pushUrlGitHub.setMaximumSize(QtCore.QSize(30, 30))
font = QtGui.QFont()
font.setFamily("Social Media Circled")
font.setPointSize(15)
self.pushUrlGitHub.setFont(font)
self.pushUrlGitHub.setObjectName("pushUrlGitHub")
self.pushUrlFacebook = QtWidgets.QPushButton(parent=self.widget)
self.pushUrlFacebook.setGeometry(QtCore.QRect(190, 400, 30, 30))
self.pushUrlFacebook.setMaximumSize(QtCore.QSize(30, 30))
font = QtGui.QFont()
font.setFamily("Social Media Circled")
font.setPointSize(15)
self.pushUrlFacebook.setFont(font)
self.pushUrlFacebook.setObjectName("pushUrlFacebook")
self.pushUrlYouTube = QtWidgets.QPushButton(parent=self.widget)
self.pushUrlYouTube.setGeometry(QtCore.QRect(240, 400, 30, 30))
self.pushUrlYouTube.setMaximumSize(QtCore.QSize(30, 30))
font = QtGui.QFont()
font.setFamily("Social Media Circled")
font.setPointSize(15)
self.pushUrlYouTube.setFont(font)
self.pushUrlYouTube.setObjectName("pushUrlYouTube")
self.retranslateUi(ImageDialog)
QtCore.QMetaObject.connectSlotsByName(ImageDialog)
def retranslateUi(self, ImageDialog):
_translate = QtCore.QCoreApplication.translate
ImageDialog.setWindowTitle(_translate("ImageDialog", "Dialog"))
self.label_3.setText(_translate("ImageDialog", "Login in"))
self.lineEdit.setPlaceholderText(_translate("ImageDialog", "User Name"))
self.lineEdit_2.setPlaceholderText(_translate("ImageDialog", "Password"))
self.pushLogin.setText(_translate("ImageDialog", "L o g i n"))
self.label_4.setText(_translate("ImageDialog", "Введите ваш логин и пароль"))
self.pushUrlDiscord.setText(_translate("ImageDialog", "Y"))
self.pushUrlGitHub.setText(_translate("ImageDialog", ")"))
self.pushUrlFacebook.setText(_translate("ImageDialog", "E"))
self.pushUrlYouTube.setText(_translate("ImageDialog", "P"))
enter image description here
Position be so
And output like this
enter image description here

It seems that you're using a resource file (.qrc) for the image.
These files cannot be used directly in python, and require the use of the pyrcc tool, which creates a "compiled" python file that contains all resources when it is imported.
Unfortunately, the PyQt developer chose to stop supporting that tool since Qt6, claiming that, since python packages already use multiple files, having a single file for resources doesn't make a lot of sense (I understand his point of view, but I don't agree with it; he's the maintainer, though, and that's his choice).
Luckily, there's a solution: you can use the pyrcc5 tool (available with PyQt5), then open it and change the import statements on top from PyQt5 to PyQt6.
Otherwise, just don't use resources, and directly point to physical files.
Also see this related question: How can resources be provided in PyQt6 (which has no pyrcc)?

Related

DropEvent does not work when dragging and dropping between widgets

I'm trying to get the behavior that when I drag and drop a MyButton, the dropEvent will be triggered in any part of the interface. Right now it works pretty much as needed, except for one thing. The dropEvent doesn't work if the mouse button is released between widgets, and I don't know how to fix this problem. For me it is very important that the dropEvent is always triggered, at the moment when the drag is finished, because at that moment I send a message to the server about the move made, and if at that moment the mouse was between the widgets, this message is not sent.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'DS_Test.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# 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.QtGui import QDragEnterEvent, QDropEvent
class MyButton(QtWidgets.QPushButton):
def mouseMoveEvent(self, event):
btn_img = self.grab()
painter = QtGui.QPainter(btn_img)
painter.setCompositionMode(painter.CompositionMode_DestinationIn)
painter.fillRect(btn_img.rect(), QtGui.QColor(0, 0, 0, 150))
painter.end()
data = QtCore.QMimeData()
drag = QtGui.QDrag(self)
drag.setMimeData(data)
drag.setPixmap(btn_img)
drag.setHotSpot(event.pos())
self._pos = event.pos()
drag.exec_(QtCore.Qt.CopyAction)
super(MyButton, self).mouseMoveEvent(event)
class MyFrame(QtWidgets.QFrame):
def __init__(self, parent):
super().__init__(parent)
self.setAcceptDrops(True)
def dragEnterEvent(self, e: QDragEnterEvent):
e.accept()
def dragMoveEvent(self, e):
e.accept()
def dropEvent(self, e: QDropEvent):
self.parent().dropEvent(e)
class MyQDialog(QtWidgets.QDialog):
def __init__(self):
super().__init__()
self.setAcceptDrops(True)
def dropEvent(self, e: QDropEvent):
print("dropEvent - is done")
e.accept()
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(1051, 800)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalFrame = MyFrame(Dialog)
self.horizontalFrame.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 0, 0, 211), stop:0.166 rgba(255, 255, 0, 211), stop:0.333 rgba(0, 255, 0, 211), stop:0.5 rgba(0, 255, 255, 211), stop:0.666 rgba(0, 0, 255, 211), stop:0.833 rgba(255, 0, 255, 211), stop:1 rgba(255, 0, 0, 211));")
self.horizontalFrame.setObjectName("horizontalFrame")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.horizontalFrame)
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.pushButton_3 = MyButton(self.horizontalFrame)
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalLayout_6.addWidget(self.pushButton_3)
self.pushButton_2 = MyButton(self.horizontalFrame)
self.pushButton_2.setObjectName("pushButton_2")
self.horizontalLayout_6.addWidget(self.pushButton_2)
self.pushButton = MyButton(self.horizontalFrame)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout_6.addWidget(self.pushButton)
self.verticalLayout.addWidget(self.horizontalFrame)
self.horizontalFrame_2 = MyFrame(Dialog)
self.horizontalFrame_2.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(9, 41, 4, 255), stop:0.085 rgba(2, 79, 0, 255), stop:0.19 rgba(50, 147, 22, 255), stop:0.275 rgba(236, 191, 49, 255), stop:0.39 rgba(243, 61, 34, 255), stop:0.555 rgba(135, 81, 60, 255), stop:0.667 rgba(121, 75, 255, 255), stop:0.825 rgba(164, 255, 244, 255), stop:0.885 rgba(104, 222, 71, 255), stop:1 rgba(93, 128, 0, 255));")
self.horizontalFrame_2.setObjectName("horizontalFrame_2")
self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.horizontalFrame_2)
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.verticalLayout.addWidget(self.horizontalFrame_2)
self.horizontalFrame_3 = MyFrame(Dialog)
self.horizontalFrame_3.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.05 rgba(14, 8, 73, 255), stop:0.36 rgba(28, 17, 145, 255), stop:0.6 rgba(126, 14, 81, 255), stop:0.75 rgba(234, 11, 11, 255), stop:0.79 rgba(244, 70, 5, 255), stop:0.86 rgba(255, 136, 0, 255), stop:0.935 rgba(239, 236, 55, 255));")
self.horizontalFrame_3.setObjectName("horizontalFrame_3")
self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.horizontalFrame_3)
self.horizontalLayout_8.setObjectName("horizontalLayout_8")
self.verticalLayout.addWidget(self.horizontalFrame_3)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton_3.setText(_translate("Dialog", "PushButton"))
self.pushButton_2.setText(_translate("Dialog", "PushButton"))
self.pushButton.setText(_translate("Dialog", "PushButton"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = MyQDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
As recommended in the comment, I added dragEnterEvent and dragMoveEvent to MyQDialog. Now everything works the way I want it to. Here is the corrected code
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'DS_Test.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# 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.QtGui import QDragEnterEvent, QDropEvent
class MyButton(QtWidgets.QPushButton):
def mouseMoveEvent(self, event):
btn_img = self.grab()
painter = QtGui.QPainter(btn_img)
painter.setCompositionMode(painter.CompositionMode_DestinationIn)
painter.fillRect(btn_img.rect(), QtGui.QColor(0, 0, 0, 150))
painter.end()
data = QtCore.QMimeData()
drag = QtGui.QDrag(self)
drag.setMimeData(data)
drag.setPixmap(btn_img)
drag.setHotSpot(event.pos())
self._pos = event.pos()
drag.exec_(QtCore.Qt.CopyAction)
super(MyButton, self).mouseMoveEvent(event)
class MyFrame(QtWidgets.QFrame):
def __init__(self, parent):
super().__init__(parent)
self.setAcceptDrops(True)
def dragEnterEvent(self, e: QDragEnterEvent):
e.accept()
def dragMoveEvent(self, e):
e.accept()
def dropEvent(self, e: QDropEvent):
self.parent().dropEvent(e)
class MyQDialog(QtWidgets.QDialog):
def __init__(self):
super().__init__()
self.setAcceptDrops(True)
def dragEnterEvent(self, e: QDragEnterEvent):
e.accept()
def dragMoveEvent(self, e):
e.accept()
def dropEvent(self, e: QDropEvent):
print("dropEvent - is done")
e.accept()
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(1051, 800)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalFrame = MyFrame(Dialog)
self.horizontalFrame.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 0, 0, 211), stop:0.166 rgba(255, 255, 0, 211), stop:0.333 rgba(0, 255, 0, 211), stop:0.5 rgba(0, 255, 255, 211), stop:0.666 rgba(0, 0, 255, 211), stop:0.833 rgba(255, 0, 255, 211), stop:1 rgba(255, 0, 0, 211));")
self.horizontalFrame.setObjectName("horizontalFrame")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.horizontalFrame)
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.pushButton_3 = MyButton(self.horizontalFrame)
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalLayout_6.addWidget(self.pushButton_3)
self.pushButton_2 = MyButton(self.horizontalFrame)
self.pushButton_2.setObjectName("pushButton_2")
self.horizontalLayout_6.addWidget(self.pushButton_2)
self.pushButton = MyButton(self.horizontalFrame)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout_6.addWidget(self.pushButton)
self.verticalLayout.addWidget(self.horizontalFrame)
self.horizontalFrame_2 = MyFrame(Dialog)
self.horizontalFrame_2.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(9, 41, 4, 255), stop:0.085 rgba(2, 79, 0, 255), stop:0.19 rgba(50, 147, 22, 255), stop:0.275 rgba(236, 191, 49, 255), stop:0.39 rgba(243, 61, 34, 255), stop:0.555 rgba(135, 81, 60, 255), stop:0.667 rgba(121, 75, 255, 255), stop:0.825 rgba(164, 255, 244, 255), stop:0.885 rgba(104, 222, 71, 255), stop:1 rgba(93, 128, 0, 255));")
self.horizontalFrame_2.setObjectName("horizontalFrame_2")
self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.horizontalFrame_2)
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.verticalLayout.addWidget(self.horizontalFrame_2)
self.horizontalFrame_3 = MyFrame(Dialog)
self.horizontalFrame_3.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(0, 0, 0, 255), stop:0.05 rgba(14, 8, 73, 255), stop:0.36 rgba(28, 17, 145, 255), stop:0.6 rgba(126, 14, 81, 255), stop:0.75 rgba(234, 11, 11, 255), stop:0.79 rgba(244, 70, 5, 255), stop:0.86 rgba(255, 136, 0, 255), stop:0.935 rgba(239, 236, 55, 255));")
self.horizontalFrame_3.setObjectName("horizontalFrame_3")
self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.horizontalFrame_3)
self.horizontalLayout_8.setObjectName("horizontalLayout_8")
self.verticalLayout.addWidget(self.horizontalFrame_3)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton_3.setText(_translate("Dialog", "PushButton"))
self.pushButton_2.setText(_translate("Dialog", "PushButton"))
self.pushButton.setText(_translate("Dialog", "PushButton"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = MyQDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())

pyqt5 : Unable to maximize widgets on Window resize

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_())

Pollution rose plot gridded

I am trying to create a pollution rose plot as described in the link Plotting Windrose: making a pollution rose with concentration set to color
Example in the reply is working but when I used my data then it is giving a weird plot. Any advice where I am going wrong? Thank you.
import matplotlib.pyplot as plt
import numpy as np
wd = [90.,297.,309.,336.,20.,2.,334.,327.,117.,125.,122.,97.,95.,97.,103.,106.,125.,148.,147.,140.,141.,145.,144.,151.,161.]
ws = [15,1.6,1.8,1.7,2.1,1.6,2.1,1.4,3,6.5,7.1,8.2,10.2,10.2,10.8,10.2,11.4,9.7,8.6,7.1,6.4,5.5,5,5,6]
oz = [10.,20.,30.,40.,50.,60.,70.,80.,90.,100.,110.,120.,90.,140.,100.,106.,125.,148.,147.,140.,141.,145.,144.,151.,161.]
pi_fac = 22/(7*180.)
wd_rad = [w * pi_fac for w in wd]
ws_r = np.linspace(min(ws),max(ws),16)
WD,WS = np.meshgrid(wd_rad,ws_r)
C = oz + np.zeros((len(ws_r),len(wd)),dtype=float)
C = np.ma.masked_less_equal(C,10)
fig, ax = plt.subplots(subplot_kw={"projection":"polar"})
ax.pcolormesh(WD,WS,C,vmin=10, vmax=170) # I tried different vmin and vmax too
plt.show()
The linked post assumes you have a regular grid for directions and for speeds, but your input seems to be quite unordered combinations.
To create a plot with colored regions depending on the oz values, you could try tricontourf. tricontourf takes in X, Y and Z values that don't need to lie on a grid and creates a contour plot. Although it is meant for rectangular layouts, it might also work for your case. It will have a discontinuity though, when crossing from 360º to 0º.
The plot of this example also draws a colorbar to show which range of oz values correspond to which color. vmin and vmax can change this mapping of colors.
import matplotlib.pyplot as plt
import numpy as np
wd = [90, 297, 309, 336, 20, 2, 334, 327, 117, 125, 122, 97, 95, 97, 103, 106, 125, 148, 147, 140, 141, 145, 144, 151, 161]
ws = [15, 1.6, 1.8, 1.7, 2.1, 1.6, 2.1, 1.4, 3, 6.5, 7.1, 8.2, 10.2, 10.2, 10.8, 10.2, 11.4, 9.7, 8.6, 7.1, 6.4, 5.5, 5, 5, 6]
oz = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 90, 140, 100, 106, 125, 148, 147, 140, 141, 145, 144, 151, 161]
fig, ax = plt.subplots(subplot_kw={"projection": "polar"})
cont = ax.tricontourf(np.radians(np.array(wd)), ws, oz, cmap='hot')
plt.colorbar(cont)
plt.show()
With ax.scatter(np.radians(np.array(wd)), ws, c=oz, cmap='hot', vmax=250) you could create a scatter plot to get an idea how the input looks like when colored.
You might want to incorporate Python's windrose library to get polar plots to resemble a windrose.
Another approach, which might be closer to the one intended by the linked question, would be to use scipy's interpolate.griddata to map the data to a grid. To get rid of the areas without data, an 'under' color of 'none' can be used, provided that vmin is higher than zero.
import matplotlib.pyplot as plt
import numpy as np
from scipy import interpolate
wd = [90, 297, 309, 336, 20, 2, 334, 327, 117, 125, 122, 97, 95, 97, 103, 106, 125, 148, 147, 140, 141, 145, 144, 151, 161]
ws = [15, 1.6, 1.8, 1.7, 2.1, 1.6, 2.1, 1.4, 3, 6.5, 7.1, 8.2, 10.2, 10.2, 10.8, 10.2, 11.4, 9.7, 8.6, 7.1, 6.4, 5.5, 5, 5, 6]
oz = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 90, 140, 100, 106, 125, 148, 147, 140, 141, 145, 144, 151, 161]
wd_rad = np.radians(np.array(wd))
oz = np.array(oz, dtype=np.float)
WD, WS = np.meshgrid(np.linspace(0, 2*np.pi, 36), np.linspace(min(ws), max(ws), 16 ))
Z = interpolate.griddata((wd_rad, ws), oz, (WD, WS), method='linear')
fig, ax = plt.subplots(subplot_kw={"projection": "polar"})
cmap = plt.get_cmap('hot')
cmap.set_under('none')
img = ax.pcolormesh(WD, WS, Z, cmap=cmap, vmin=20)
plt.colorbar(img)
plt.show()

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)

Autoit GUI, Variables not being declared on button press

I am still in the process of learning how to script my own GUIs. Koda has been a big help, I have been messing around with it, learning little bits at a time. However, I have encountered an error that I can not seem to get around. The current GUI I am working on is a simple tool to change bot settings for a game. This gui should have 5 buttons for difficulty setting, and a list of check boxes for the number of bots.
BUT, when I select a difficulty level, bot number, and hit save I get this error:
'Variable used without being declared'
The error is occuring on this line (botSAVE button at the end):
FileWriteLine($file2, "aiSettings.setMaxNBots " & $botnum)
I thought the button functions 'Func numClick()' set this variable based on the button that was pressed, but obviously I have overlooked something. Hopefully it is an easy fix. Does anybody see what might be causing this error? I have posted this question on autoitcsript forums but they seem to shy away from game automation scripts so I didn't really get much help over there.
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=c:\users\admin\desktop\form1.kxf
$Form1 = GUICreate("Battlefield 2 Bot-Tool", 418, 499, 759, 83)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Pic1 = GUICtrlCreatePic("C:\Users\admin\Desktop\bflogo.jpg", 0, 0, 417, 233)
$Settings = GUICtrlCreateTab(8, 240, 401, 249)
GUICtrlSetOnEvent(-1, "SettingsChange")
$Bot = GUICtrlCreateTabItem("Bots")
$botSAVE = GUICtrlCreateButton("Save these changes", 220, 433, 169, 33)
GUICtrlSetOnEvent(-1, "botSAVEClick")
$botDEFAULT = GUICtrlCreateButton("Restore default settings", 28, 433, 169, 33)
GUICtrlSetOnEvent(-1, "botDEFAULTClick")
$botskill = GUICtrlCreateGroup(" Bot skill level", 28, 265, 169, 145)
$skill1 = GUICtrlCreateRadio(" RECRUIT", 44, 289, 113, 17)
GUICtrlSetTip(-1, "Easy opposition, a damn turkey shoot")
GUICtrlSetOnEvent(-1, "skill1Click")
$skill2 = GUICtrlCreateRadio(" TRAINED", 44, 313, 113, 17)
GUICtrlSetTip(-1, "Default setting, opponents are deadly at close range")
GUICtrlSetOnEvent(-1, "skill2Click")
$skill3 = GUICtrlCreateRadio(" HARDENED", 44, 337, 113, 17)
GUICtrlSetTip(-1, "Enemies are a force to be reckoned with")
GUICtrlSetOnEvent(-1, "skill3Click")
$skill4 = GUICtrlCreateRadio(" VETERAN", 44, 361, 113, 17)
GUICtrlSetTip(-1, "Enemies are experienced, and dangerous")
GUICtrlSetOnEvent(-1, "skill4Click")
$skill5 = GUICtrlCreateRadio(" ELITE", 44, 385, 113, 17)
GUICtrlSetTip(-1, "Crack shot opponents will strategize against you. You will not survive")
GUICtrlSetOnEvent(-1, "skill5Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$botnumber = GUICtrlCreateGroup(" Number of bots ", 220, 265, 169, 145)
$num1 = GUICtrlCreateRadio("2", 236, 289, 25, 17)
GUICtrlSetOnEvent(-1, "num1Click")
$num2 = GUICtrlCreateRadio("4", 236, 313, 25, 17)
GUICtrlSetOnEvent(-1, "num2Click")
$num3 = GUICtrlCreateRadio("6", 236, 337, 25, 17)
GUICtrlSetOnEvent(-1, "num3Click")
$num4 = GUICtrlCreateRadio("8", 236, 361, 25, 17)
GUICtrlSetOnEvent(-1, "num4Click")
$num5 = GUICtrlCreateRadio("10", 236, 385, 33, 17)
GUICtrlSetOnEvent(-1, "num5Click")
$num6 = GUICtrlCreateRadio("12", 284, 289, 33, 17)
GUICtrlSetOnEvent(-1, "num6Click")
$num7 = GUICtrlCreateRadio("14", 284, 313, 33, 17)
GUICtrlSetOnEvent(-1, "num7Click")
$num8 = GUICtrlCreateRadio("16", 284, 337, 33, 17)
GUICtrlSetOnEvent(-1, "num8Click")
$num9 = GUICtrlCreateRadio("18", 284, 361, 33, 17)
GUICtrlSetOnEvent(-1, "num9Click")
$num10 = GUICtrlCreateRadio("20", 284, 385, 33, 17)
GUICtrlSetOnEvent(-1, "num10Click")
$num11 = GUICtrlCreateRadio("24", 340, 289, 33, 17)
GUICtrlSetOnEvent(-1, "num11Click")
$num12 = GUICtrlCreateRadio("28", 340, 313, 33, 17)
GUICtrlSetOnEvent(-1, "num12Click")
$num13 = GUICtrlCreateRadio("32", 340, 337, 33, 17)
GUICtrlSetOnEvent(-1, "num13Click")
$num14 = GUICtrlCreateRadio("36", 340, 361, 33, 17)
GUICtrlSetOnEvent(-1, "num14Click")
$num15 = GUICtrlCreateRadio("40", 340, 385, 33, 17)
GUICtrlSetOnEvent(-1, "num15Click")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Server = GUICtrlCreateTabItem("Server")
$serverDEFAULT = GUICtrlCreateButton("Restore default settings", 28, 433, 169, 33)
$serverSAVE = GUICtrlCreateButton("Save these changes", 220, 433, 169, 33)
GUICtrlCreateTabItem("")
GUISetState(#SW_SHOW)
Opt("MustDeclareVars",1)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Form1Close()
If #GUI_WINHANDLE = $Form1 Then
Exit
EndIf
EndFunc
Func Form1Maximize()
EndFunc
Func Form1Minimize()
EndFunc
Func Form1Restore()
EndFunc
Func num1Click()
$botnum = "2"
EndFunc
Func num2Click()
$botnum = "4"
EndFunc
Func num3Click()
$botnum = "6"
EndFunc
Func num4Click()
$botnum = "8"
EndFunc
Func num5Click()
$botnum = "10"
EndFunc
Func num6Click()
$botnum = "12"
EndFunc
Func num7Click()
$botnum = "14"
EndFunc
Func num8Click()
$botnum = "16"
EndFunc
Func num9Click()
$botnum = "18"
EndFunc
Func num10Click()
$botnum = "20"
EndFunc
Func num11Click()
$botnum = "24"
EndFunc
Func num12Click()
$botnum = "28"
EndFunc
Func num13Click()
$botnum = "32"
EndFunc
Func num14Click()
$botnum = "36"
EndFunc
Func num15Click()
$botnum = "40"
EndFunc
Func SettingsChange()
EndFunc
Func skill1Click()
$skillset = "0.1"
EndFunc
Func skill2Click()
$skillset = "0.3"
EndFunc
Func skill3Click()
$skillset = "0.6"
EndFunc
Func skill4Click()
$skillset = "0.8"
EndFunc
Func skill5Click()
$skillset = "1.0"
EndFunc
Func botDEFAULTClick()
EndFunc
Func botSAVEClick()
Local $file = FileOpen("AIDefault.ai", 1)
If $file = -1 Then
MsgBox(0, "Protected file", "Please ensure that the file 'AIDefault.ai' is not set to Read Only.")
exit
EndIf
FileWriteLine($file, "aiSettings.setNSides 2 ")
FileWriteLine($file, "aiSettings.setAutoSpawnBots 1 ")
FileWriteLine($file, "aiSettings.setMaxNBots 64 ")
FileWriteLine($file, "aiSettings.maxBotsIncludeHumans 1")
FileWriteLine($file, "aiSettings.setBotSkill 0.4 ")
FileWriteLine($file, "run BotNames.ai ")
FileWriteLine($file, "aiSettings.setInformationGridDimension 32")
FileWriteLine($file, "run AIPathFinding.ai")
FileWriteLine($file, "run AIBotChanger.ai ")
FileClose($file)
$file2 = FileOpen("AIBotChanger.ai", 1)
If $file2 = -1 Then
MsgBox(0, "Protected file", "Please ensure that the file 'AIBotChanger.ai' is not set to Read Only.")
Exit
EndIf
FileWriteLine($file2, "aiSettings.overrideMenuSettings 1")
FileWriteLine($file2, "aiSettings.setMaxNBots " & $botnum)
FileWriteLine($file2, "aiSettings.setBotSkill " & $skillset)
FileWriteLine($file2, "aiSettings.maxBotsIncludeHumans 0")
FileClose($file2)
EndFunc
-If anybody sees what I have done wrong, OR has a link to a topic that covers declaring variables with a button click, Help is always appreciated. The only topics I have found are incredibly vague, or differ slightly from what I am look for
When you want to use a variable value outside of a function as well, you must declare its scope to be global. So just add a line Global $botnum (probably with a default value) before your many function declarations...
And obviously the same with $skillset.
The error is raised because you used Opt("MustDeclareVars", 1). But it wouldn't work anyways when you wouldn't declare these variables as global, because the value is set in the function but discarded again as soon as the function ends. So when you'd use them uninitialized in another function then, you would always receive the default value of an uninitialized variable.