from PySide2.QtWidgets import QWidget, QFrame, QGridLayout, \
                              QLabel, QPushButton, QCheckBox
from PySide2.QtGui import QFont, QColor
from PySide2.QtCore import Qt
from collections import OrderedDict
from indicator import Indicator
import usb_msg as um

ALARMS = OrderedDict([
    ('VFAIL', QColor(255, 0, 0)),
    ('OSCAL', QColor(255, 0, 0)),
    ('SCAFL', QColor(255, 0, 0)),
    ('SCDBL', QColor(255, 0, 0)),
    ('CTRAL', QColor(255, 127, 0)),
    ('TCAL', QColor(255, 127, 0)),
    ('RPTAL', QColor(255, 127, 0)),
    ('FPAL', QColor(255, 127, 0)),
    ('EPAL', QColor(255, 127, 0)),
    ('WATCH', QColor(255, 127, 0)),
    ('PIPAL', QColor(180, 0, 255)),
    ('WARN', QColor(255, 255, 0)),
])


class Alarms(QFrame):
    def __init__(self, parent, usbif):
        super().__init__(parent)

        self._usbif = usbif
        self._alarm_inds = {}
Exemple #2
0
    def setupUi(self, Dialog):
        if Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(1288, 706)
        self.tableWidget_7 = QTableWidget(Dialog)
        if (self.tableWidget_7.columnCount() < 7):
            self.tableWidget_7.setColumnCount(7)
        __qtablewidgetitem = QTableWidgetItem()
        self.tableWidget_7.setHorizontalHeaderItem(0, __qtablewidgetitem)
        __qtablewidgetitem1 = QTableWidgetItem()
        self.tableWidget_7.setHorizontalHeaderItem(1, __qtablewidgetitem1)
        __qtablewidgetitem2 = QTableWidgetItem()
        self.tableWidget_7.setHorizontalHeaderItem(2, __qtablewidgetitem2)
        __qtablewidgetitem3 = QTableWidgetItem()
        self.tableWidget_7.setHorizontalHeaderItem(3, __qtablewidgetitem3)
        __qtablewidgetitem4 = QTableWidgetItem()
        self.tableWidget_7.setHorizontalHeaderItem(4, __qtablewidgetitem4)
        __qtablewidgetitem5 = QTableWidgetItem()
        self.tableWidget_7.setHorizontalHeaderItem(5, __qtablewidgetitem5)
        __qtablewidgetitem6 = QTableWidgetItem()
        self.tableWidget_7.setHorizontalHeaderItem(6, __qtablewidgetitem6)
        self.tableWidget_7.setObjectName(u"tableWidget_7")
        self.tableWidget_7.setGeometry(QRect(10, 300, 1271, 391))
        self.tableWidget_7.setSizeAdjustPolicy(
            QAbstractScrollArea.AdjustToContents)
        self.tableWidget_7.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tableWidget_7.setSelectionMode(QAbstractItemView.SingleSelection)
        self.tableWidget_7.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tableWidget_7.setSortingEnabled(True)
        self.tableWidget_7.horizontalHeader().setCascadingSectionResizes(True)
        self.tableWidget_7.horizontalHeader().setDefaultSectionSize(85)
        self.tableWidget_7.horizontalHeader().setProperty(
            "showSortIndicator", True)
        self.tableWidget_7.horizontalHeader().setStretchLastSection(True)
        self.groupBox_27 = QGroupBox(Dialog)
        self.groupBox_27.setObjectName(u"groupBox_27")
        self.groupBox_27.setGeometry(QRect(1050, 60, 211, 131))
        self.pushButton_2 = QPushButton(self.groupBox_27)
        self.pushButton_2.setObjectName(u"pushButton_2")
        self.pushButton_2.setGeometry(QRect(110, 50, 91, 50))
        self.pushButton = QPushButton(self.groupBox_27)
        self.pushButton.setObjectName(u"pushButton")
        self.pushButton.setGeometry(QRect(10, 50, 91, 50))
        self.groupBox_2 = QGroupBox(Dialog)
        self.groupBox_2.setObjectName(u"groupBox_2")
        self.groupBox_2.setGeometry(QRect(0, 220, 1261, 70))
        self.comboBox_14 = QComboBox(self.groupBox_2)
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.addItem("")
        self.comboBox_14.setObjectName(u"comboBox_14")
        self.comboBox_14.setGeometry(QRect(905, 27, 71, 31))
        self.lineEdit = QLineEdit(self.groupBox_2)
        self.lineEdit.setObjectName(u"lineEdit")
        self.lineEdit.setGeometry(QRect(120, 27, 231, 30))
        self.comboBox_12 = QComboBox(self.groupBox_2)
        self.comboBox_12.addItem("")
        self.comboBox_12.addItem("")
        self.comboBox_12.addItem("")
        self.comboBox_12.addItem("")
        self.comboBox_12.addItem("")
        self.comboBox_12.addItem("")
        self.comboBox_12.addItem("")
        self.comboBox_12.setObjectName(u"comboBox_12")
        self.comboBox_12.setGeometry(QRect(620, 27, 201, 31))
        self.label = QLabel(self.groupBox_2)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(9, 27, 111, 30))
        self.label_96 = QLabel(self.groupBox_2)
        self.label_96.setObjectName(u"label_96")
        self.label_96.setGeometry(QRect(830, 27, 70, 30))
        self.label_96.setMidLineWidth(0)
        self.label_96.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                   | Qt.AlignVCenter)
        self.label_79 = QLabel(self.groupBox_2)
        self.label_79.setObjectName(u"label_79")
        self.label_79.setGeometry(QRect(550, 28, 61, 30))
        self.label_79.setMidLineWidth(0)
        self.label_79.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                   | Qt.AlignVCenter)
        self.comboBox = QComboBox(self.groupBox_2)
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.setObjectName(u"comboBox")
        self.comboBox.setGeometry(QRect(380, 30, 150, 30))
        self.pushButton_3 = QPushButton(self.groupBox_2)
        self.pushButton_3.setObjectName(u"pushButton_3")
        self.pushButton_3.setGeometry(QRect(1020, 27, 93, 30))
        self.groupBox_37 = QGroupBox(Dialog)
        self.groupBox_37.setObjectName(u"groupBox_37")
        self.groupBox_37.setGeometry(QRect(10, 10, 131, 211))
        self.label_152 = QLabel(self.groupBox_37)
        self.label_152.setObjectName(u"label_152")
        self.label_152.setGeometry(QRect(10, 30, 111, 171))
        self.label_152.setFrameShape(QFrame.WinPanel)
        self.label_152.setIndent(0)
        self.groupBox_35 = QGroupBox(Dialog)
        self.groupBox_35.setObjectName(u"groupBox_35")
        self.groupBox_35.setGeometry(QRect(370, 10, 421, 211))
        self.lineEdit_95 = QLineEdit(self.groupBox_35)
        self.lineEdit_95.setObjectName(u"lineEdit_95")
        self.lineEdit_95.setEnabled(False)
        self.lineEdit_95.setGeometry(QRect(70, 70, 341, 31))
        palette = QPalette()
        brush = QBrush(QColor(0, 0, 0, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Text, brush)
        brush1 = QBrush(QColor(0, 0, 0, 128))
        brush1.setStyle(Qt.SolidPattern)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_95.setPalette(palette)
        self.label_146 = QLabel(self.groupBox_35)
        self.label_146.setObjectName(u"label_146")
        self.label_146.setGeometry(QRect(2, 70, 61, 30))
        self.label_146.setMidLineWidth(0)
        self.label_146.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.lineEdit_98 = QLineEdit(self.groupBox_35)
        self.lineEdit_98.setObjectName(u"lineEdit_98")
        self.lineEdit_98.setEnabled(False)
        self.lineEdit_98.setGeometry(QRect(90, 110, 121, 31))
        palette1 = QPalette()
        palette1.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette1.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette1.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette1.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette1.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette1.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_98.setPalette(palette1)
        self.label_149 = QLabel(self.groupBox_35)
        self.label_149.setObjectName(u"label_149")
        self.label_149.setGeometry(QRect(2, 110, 81, 30))
        self.label_149.setMidLineWidth(0)
        self.label_149.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.label_151 = QLabel(self.groupBox_35)
        self.label_151.setObjectName(u"label_151")
        self.label_151.setGeometry(QRect(0, 150, 81, 30))
        self.label_151.setMidLineWidth(0)
        self.label_151.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.lineEdit_99 = QLineEdit(self.groupBox_35)
        self.lineEdit_99.setObjectName(u"lineEdit_99")
        self.lineEdit_99.setEnabled(False)
        self.lineEdit_99.setGeometry(QRect(90, 150, 201, 31))
        palette2 = QPalette()
        palette2.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette2.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette2.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette2.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette2.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette2.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_99.setPalette(palette2)
        self.label_150 = QLabel(self.groupBox_35)
        self.label_150.setObjectName(u"label_150")
        self.label_150.setEnabled(True)
        self.label_150.setGeometry(QRect(240, 20, 91, 30))
        self.label_150.setMidLineWidth(0)
        self.label_150.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.lineEdit_36 = QLineEdit(self.groupBox_35)
        self.lineEdit_36.setObjectName(u"lineEdit_36")
        self.lineEdit_36.setEnabled(False)
        self.lineEdit_36.setGeometry(QRect(340, 20, 71, 31))
        palette3 = QPalette()
        palette3.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette3.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette3.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette3.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette3.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette3.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_36.setPalette(palette3)
        self.groupBox_38 = QGroupBox(Dialog)
        self.groupBox_38.setObjectName(u"groupBox_38")
        self.groupBox_38.setGeometry(QRect(150, 10, 221, 211))
        self.label_153 = QLabel(self.groupBox_38)
        self.label_153.setObjectName(u"label_153")
        self.label_153.setGeometry(QRect(29, 30, 21, 29))
        self.label_153.setMidLineWidth(0)
        self.label_153.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.lineEdit_103 = QLineEdit(self.groupBox_38)
        self.lineEdit_103.setObjectName(u"lineEdit_103")
        self.lineEdit_103.setEnabled(False)
        self.lineEdit_103.setGeometry(QRect(71, 64, 131, 30))
        palette4 = QPalette()
        palette4.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette4.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette4.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette4.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette4.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette4.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_103.setPalette(palette4)
        self.lineEdit_103.setMaxLength(20)
        self.lineEdit_104 = QLineEdit(self.groupBox_38)
        self.lineEdit_104.setObjectName(u"lineEdit_104")
        self.lineEdit_104.setEnabled(False)
        self.lineEdit_104.setGeometry(QRect(70, 30, 131, 30))
        palette5 = QPalette()
        palette5.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette5.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette5.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette5.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette5.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette5.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_104.setPalette(palette5)
        self.lineEdit_104.setMaxLength(30)
        self.lineEdit_104.setReadOnly(False)
        self.lineEdit_104.setClearButtonEnabled(False)
        self.label_154 = QLabel(self.groupBox_38)
        self.label_154.setObjectName(u"label_154")
        self.label_154.setGeometry(QRect(10, 64, 41, 29))
        self.label_154.setMidLineWidth(0)
        self.label_154.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.label_155 = QLabel(self.groupBox_38)
        self.label_155.setObjectName(u"label_155")
        self.label_155.setGeometry(QRect(40, 102, 51, 29))
        self.label_155.setMidLineWidth(0)
        self.label_155.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.lineEdit_105 = QLineEdit(self.groupBox_38)
        self.lineEdit_105.setObjectName(u"lineEdit_105")
        self.lineEdit_105.setEnabled(False)
        self.lineEdit_105.setGeometry(QRect(100, 102, 71, 30))
        palette6 = QPalette()
        palette6.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette6.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette6.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette6.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette6.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette6.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_105.setPalette(palette6)
        self.lineEdit_105.setMaxLength(5)
        self.lineEdit_106 = QLineEdit(self.groupBox_38)
        self.lineEdit_106.setObjectName(u"lineEdit_106")
        self.lineEdit_106.setEnabled(False)
        self.lineEdit_106.setGeometry(QRect(100, 135, 71, 30))
        palette7 = QPalette()
        palette7.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette7.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette7.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette7.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette7.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette7.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_106.setPalette(palette7)
        self.lineEdit_106.setMaxLength(4)
        self.lineEdit_106.setEchoMode(QLineEdit.Normal)
        self.lineEdit_106.setReadOnly(False)
        self.label_156 = QLabel(self.groupBox_38)
        self.label_156.setObjectName(u"label_156")
        self.label_156.setGeometry(QRect(39, 135, 51, 29))
        self.label_156.setMidLineWidth(0)
        self.label_156.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.label_157 = QLabel(self.groupBox_38)
        self.label_157.setObjectName(u"label_157")
        self.label_157.setGeometry(QRect(130, 170, 21, 30))
        self.label_157.setMidLineWidth(0)
        self.label_157.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.lineEdit_107 = QLineEdit(self.groupBox_38)
        self.lineEdit_107.setObjectName(u"lineEdit_107")
        self.lineEdit_107.setEnabled(False)
        self.lineEdit_107.setGeometry(QRect(100, 170, 41, 30))
        palette8 = QPalette()
        palette8.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette8.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette8.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette8.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette8.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette8.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_107.setPalette(palette8)
        self.lineEdit_107.setEchoMode(QLineEdit.Normal)
        self.lineEdit_107.setReadOnly(False)
        self.lineEdit_108 = QLineEdit(self.groupBox_38)
        self.lineEdit_108.setObjectName(u"lineEdit_108")
        self.lineEdit_108.setEnabled(False)
        self.lineEdit_108.setGeometry(QRect(150, 170, 41, 30))
        palette9 = QPalette()
        palette9.setBrush(QPalette.Active, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette9.setBrush(QPalette.Active, QPalette.PlaceholderText, brush1)
        #endif
        palette9.setBrush(QPalette.Inactive, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette9.setBrush(QPalette.Inactive, QPalette.PlaceholderText, brush1)
        #endif
        palette9.setBrush(QPalette.Disabled, QPalette.Text, brush)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
        palette9.setBrush(QPalette.Disabled, QPalette.PlaceholderText, brush1)
        #endif
        self.lineEdit_108.setPalette(palette9)
        self.lineEdit_108.setEchoMode(QLineEdit.Normal)
        self.lineEdit_108.setReadOnly(False)
        self.label_158 = QLabel(self.groupBox_38)
        self.label_158.setObjectName(u"label_158")
        self.label_158.setGeometry(QRect(50, 170, 41, 30))
        self.label_158.setMidLineWidth(0)
        self.label_158.setAlignment(Qt.AlignRight | Qt.AlignTrailing
                                    | Qt.AlignVCenter)
        self.textEdit_10 = QTextEdit(Dialog)
        self.textEdit_10.setObjectName(u"textEdit_10")
        self.textEdit_10.setEnabled(False)
        self.textEdit_10.setGeometry(QRect(800, 20, 211, 201))
        self.textEdit_10.setSizeAdjustPolicy(
            QAbstractScrollArea.AdjustToContents)
        self.textEdit_10.setAutoFormatting(QTextEdit.AutoBulletList)
        self.textEdit_10.setTabChangesFocus(True)
        self.textEdit_10.setOverwriteMode(False)
        QWidget.setTabOrder(self.lineEdit, self.comboBox)
        QWidget.setTabOrder(self.comboBox, self.comboBox_12)
        QWidget.setTabOrder(self.comboBox_12, self.comboBox_14)
        QWidget.setTabOrder(self.comboBox_14, self.pushButton_3)
        QWidget.setTabOrder(self.pushButton_3, self.pushButton)
        QWidget.setTabOrder(self.pushButton, self.pushButton_2)
        QWidget.setTabOrder(self.pushButton_2, self.textEdit_10)
        QWidget.setTabOrder(self.textEdit_10, self.tableWidget_7)
        QWidget.setTabOrder(self.tableWidget_7, self.lineEdit_95)
        QWidget.setTabOrder(self.lineEdit_95, self.lineEdit_98)
        QWidget.setTabOrder(self.lineEdit_98, self.lineEdit_99)
        QWidget.setTabOrder(self.lineEdit_99, self.lineEdit_36)
        QWidget.setTabOrder(self.lineEdit_36, self.lineEdit_103)
        QWidget.setTabOrder(self.lineEdit_103, self.lineEdit_104)
        QWidget.setTabOrder(self.lineEdit_104, self.lineEdit_105)
        QWidget.setTabOrder(self.lineEdit_105, self.lineEdit_106)
        QWidget.setTabOrder(self.lineEdit_106, self.lineEdit_107)
        QWidget.setTabOrder(self.lineEdit_107, self.lineEdit_108)

        self.retranslateUi(Dialog)

        QMetaObject.connectSlotsByName(Dialog)
 def initializeGL(self):
     self.m_functions = self.context().functions()
     self.m_functions.initializeOpenGLFunctions()
     image = QImage(QSize(200, 200), QImage.Format_RGBA8888)
     image.fill(QColor(Qt.red))
     self.m_texture = QOpenGLTexture(image)
 def testDuplicateKeyword(self):
     r, g, b, a = 1, 2, 3, 4
     with self.assertRaises(TypeError) as cm:
         QColor(r, g, b, a, a=0)
     self.assertTrue("multiple" in cm.exception.args[0])
Exemple #5
0
def dark(app):
    """Apply Dark Theme to the Qt application instance.
        Args:
            app (QApplication): QApplication instance.
    """

    darkPalette = QPalette()

    # base
    darkPalette.setColor(QPalette.WindowText, QColor(180, 180, 180))
    darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
    darkPalette.setColor(QPalette.Light, QColor(180, 180, 180))
    darkPalette.setColor(QPalette.Midlight, QColor(90, 90, 90))
    darkPalette.setColor(QPalette.Dark, QColor(35, 35, 35))
    darkPalette.setColor(QPalette.Text, QColor(180, 180, 180))
    darkPalette.setColor(QPalette.BrightText, QColor(200, 200, 200))
    darkPalette.setColor(QPalette.ButtonText, QColor(180, 180, 180))
    darkPalette.setColor(QPalette.Base, QColor(42, 42, 42))
    darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
    darkPalette.setColor(QPalette.Shadow, QColor(20, 20, 20))
    darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
    darkPalette.setColor(QPalette.HighlightedText, QColor(180, 180, 180))
    darkPalette.setColor(QPalette.Link, QColor(56, 252, 196))
    darkPalette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
    darkPalette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53))
    darkPalette.setColor(QPalette.ToolTipText, QColor(180, 180, 180))

    # disabled
    darkPalette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127))
    darkPalette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127))
    darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127))
    darkPalette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80))
    darkPalette.setColor(
        QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127)
    )

    app.setPalette(darkPalette)

    # _apply_base_theme(app)
    with open(DIR_STYLES + "dark.qss", "r") as file:
        app.setStyleSheet(file.read())
Exemple #6
0
    def setupUi(self, Form):
        if not Form.objectName():
            Form.setObjectName(u"Form")
        Form.setWindowModality(Qt.ApplicationModal)
        Form.resize(400, 550)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
        Form.setSizePolicy(sizePolicy)
        Form.setMinimumSize(QSize(400, 550))
        Form.setMaximumSize(QSize(400, 550))
        font = QFont()
        font.setStyleStrategy(QFont.PreferDefault)
        Form.setFont(font)
        Form.setAutoFillBackground(False)
        self.verticalLayout_2 = QVBoxLayout(Form)
        self.verticalLayout_2.setSpacing(0)
        self.verticalLayout_2.setObjectName(u"verticalLayout_2")
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.widget_8 = QWidget(Form)
        self.widget_8.setObjectName(u"widget_8")
        sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy1.setHorizontalStretch(0)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(self.widget_8.sizePolicy().hasHeightForWidth())
        self.widget_8.setSizePolicy(sizePolicy1)
        self.widget_8.setMinimumSize(QSize(400, 150))
        self.widget_8.setMaximumSize(QSize(400, 150))
        self.horizontalLayout = QHBoxLayout(self.widget_8)
        self.horizontalLayout.setSpacing(0)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.widget = QWidget(self.widget_8)
        self.widget.setObjectName(u"widget")
        sizePolicy1.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth())
        self.widget.setSizePolicy(sizePolicy1)
        self.widget.setMinimumSize(QSize(200, 150))
        self.widget.setMaximumSize(QSize(200, 150))
        palette = QPalette()
        brush = QBrush(QColor(255, 255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Base, brush)
        palette.setBrush(QPalette.Active, QPalette.Window, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Window, brush)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush)
        palette.setBrush(QPalette.Disabled, QPalette.Window, brush)
        self.widget.setPalette(palette)
        self.widget.setAutoFillBackground(True)
        self.horizontalLayout_10 = QHBoxLayout(self.widget)
        self.horizontalLayout_10.setSpacing(0)
        self.horizontalLayout_10.setObjectName(u"horizontalLayout_10")
        self.horizontalLayout_10.setContentsMargins(0, 0, 0, 0)
        self.label = QLabel(self.widget)
        self.label.setObjectName(u"label")
        sizePolicy1.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
        self.label.setSizePolicy(sizePolicy1)
        self.label.setMinimumSize(QSize(150, 150))
        self.label.setMaximumSize(QSize(150, 150))
        self.label.setPixmap(QPixmap(u":/symbols/Spine_symbol.png"))
        self.label.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_10.addWidget(self.label)


        self.horizontalLayout.addWidget(self.widget)

        self.widget_9 = QWidget(self.widget_8)
        self.widget_9.setObjectName(u"widget_9")
        palette1 = QPalette()
        palette1.setBrush(QPalette.Active, QPalette.Base, brush)
        brush1 = QBrush(QColor(0, 74, 194, 255))
        brush1.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.Window, brush1)
        palette1.setBrush(QPalette.Inactive, QPalette.Base, brush)
        palette1.setBrush(QPalette.Inactive, QPalette.Window, brush1)
        palette1.setBrush(QPalette.Disabled, QPalette.Base, brush1)
        palette1.setBrush(QPalette.Disabled, QPalette.Window, brush1)
        self.widget_9.setPalette(palette1)
        self.widget_9.setAutoFillBackground(True)
        self.verticalLayout = QVBoxLayout(self.widget_9)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.label_spine_toolbox = QLabel(self.widget_9)
        self.label_spine_toolbox.setObjectName(u"label_spine_toolbox")
        sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy2.setHorizontalStretch(0)
        sizePolicy2.setVerticalStretch(0)
        sizePolicy2.setHeightForWidth(self.label_spine_toolbox.sizePolicy().hasHeightForWidth())
        self.label_spine_toolbox.setSizePolicy(sizePolicy2)
        self.label_spine_toolbox.setMinimumSize(QSize(0, 0))
        self.label_spine_toolbox.setMaximumSize(QSize(16777215, 16777215))
        self.label_spine_toolbox.setBaseSize(QSize(0, 0))
        font1 = QFont()
        font1.setFamily(u"Arial Black")
        font1.setPointSize(6)
        font1.setBold(False)
        font1.setWeight(50)
        self.label_spine_toolbox.setFont(font1)
        self.label_spine_toolbox.setStyleSheet(u"color: rgb(255, 255, 255);")
        self.label_spine_toolbox.setScaledContents(True)
        self.label_spine_toolbox.setAlignment(Qt.AlignCenter)

        self.verticalLayout.addWidget(self.label_spine_toolbox)

        self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)

        self.verticalLayout.addItem(self.verticalSpacer)

        self.label_spinedb_api = QLabel(self.widget_9)
        self.label_spinedb_api.setObjectName(u"label_spinedb_api")
        sizePolicy2.setHeightForWidth(self.label_spinedb_api.sizePolicy().hasHeightForWidth())
        self.label_spinedb_api.setSizePolicy(sizePolicy2)
        font2 = QFont()
        font2.setFamily(u"Arial Black")
        font2.setPointSize(6)
        self.label_spinedb_api.setFont(font2)
        self.label_spinedb_api.setStyleSheet(u"color: rgb(255, 255, 255);")
        self.label_spinedb_api.setAlignment(Qt.AlignCenter)

        self.verticalLayout.addWidget(self.label_spinedb_api)

        self.label_spine_engine = QLabel(self.widget_9)
        self.label_spine_engine.setObjectName(u"label_spine_engine")
        sizePolicy2.setHeightForWidth(self.label_spine_engine.sizePolicy().hasHeightForWidth())
        self.label_spine_engine.setSizePolicy(sizePolicy2)
        self.label_spine_engine.setFont(font2)
        self.label_spine_engine.setStyleSheet(u"color: rgb(255, 255, 255);")
        self.label_spine_engine.setAlignment(Qt.AlignCenter)

        self.verticalLayout.addWidget(self.label_spine_engine)

        self.label_spine_items = QLabel(self.widget_9)
        self.label_spine_items.setObjectName(u"label_spine_items")
        sizePolicy2.setHeightForWidth(self.label_spine_items.sizePolicy().hasHeightForWidth())
        self.label_spine_items.setSizePolicy(sizePolicy2)
        self.label_spine_items.setFont(font2)
        self.label_spine_items.setStyleSheet(u"color: rgb(255, 255, 255);")
        self.label_spine_items.setAlignment(Qt.AlignCenter)

        self.verticalLayout.addWidget(self.label_spine_items)

        self.verticalSpacer_3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)

        self.verticalLayout.addItem(self.verticalSpacer_3)


        self.horizontalLayout.addWidget(self.widget_9)


        self.verticalLayout_2.addWidget(self.widget_8)

        self.widget_3 = QWidget(Form)
        self.widget_3.setObjectName(u"widget_3")
        sizePolicy3 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        sizePolicy3.setHorizontalStretch(0)
        sizePolicy3.setVerticalStretch(0)
        sizePolicy3.setHeightForWidth(self.widget_3.sizePolicy().hasHeightForWidth())
        self.widget_3.setSizePolicy(sizePolicy3)
        self.widget_3.setMinimumSize(QSize(400, 60))
        self.widget_3.setMaximumSize(QSize(400, 1000))
        palette2 = QPalette()
        palette2.setBrush(QPalette.Active, QPalette.Base, brush)
        palette2.setBrush(QPalette.Active, QPalette.Window, brush)
        palette2.setBrush(QPalette.Inactive, QPalette.Base, brush)
        palette2.setBrush(QPalette.Inactive, QPalette.Window, brush)
        palette2.setBrush(QPalette.Disabled, QPalette.Base, brush)
        palette2.setBrush(QPalette.Disabled, QPalette.Window, brush)
        self.widget_3.setPalette(palette2)
        self.widget_3.setAutoFillBackground(True)
        self.horizontalLayout_4 = QHBoxLayout(self.widget_3)
        self.horizontalLayout_4.setSpacing(0)
        self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
        self.horizontalLayout_4.setContentsMargins(6, 6, 6, 6)
        self.textBrowser = QTextBrowser(self.widget_3)
        self.textBrowser.setObjectName(u"textBrowser")
        self.textBrowser.setMinimumSize(QSize(0, 0))
        self.textBrowser.setMaximumSize(QSize(400, 1000))
        font3 = QFont()
        font3.setPointSize(7)
        self.textBrowser.setFont(font3)
        self.textBrowser.setFrameShape(QFrame.StyledPanel)
        self.textBrowser.setFrameShadow(QFrame.Sunken)
        self.textBrowser.setLineWidth(1)
        self.textBrowser.setTextInteractionFlags(Qt.LinksAccessibleByMouse|Qt.TextSelectableByMouse)
        self.textBrowser.setOpenExternalLinks(True)

        self.horizontalLayout_4.addWidget(self.textBrowser)


        self.verticalLayout_2.addWidget(self.widget_3)

        self.widget_2 = QWidget(Form)
        self.widget_2.setObjectName(u"widget_2")
        sizePolicy1.setHeightForWidth(self.widget_2.sizePolicy().hasHeightForWidth())
        self.widget_2.setSizePolicy(sizePolicy1)
        self.widget_2.setMinimumSize(QSize(400, 255))
        self.widget_2.setMaximumSize(QSize(400, 255))
        palette3 = QPalette()
        palette3.setBrush(QPalette.Active, QPalette.Base, brush)
        brush2 = QBrush(QColor(118, 168, 246, 255))
        brush2.setStyle(Qt.SolidPattern)
        palette3.setBrush(QPalette.Active, QPalette.Window, brush2)
        palette3.setBrush(QPalette.Inactive, QPalette.Base, brush)
        palette3.setBrush(QPalette.Inactive, QPalette.Window, brush2)
        palette3.setBrush(QPalette.Disabled, QPalette.Base, brush2)
        palette3.setBrush(QPalette.Disabled, QPalette.Window, brush2)
        self.widget_2.setPalette(palette3)
        self.widget_2.setAutoFillBackground(True)
        self.verticalLayout_3 = QVBoxLayout(self.widget_2)
        self.verticalLayout_3.setSpacing(0)
        self.verticalLayout_3.setObjectName(u"verticalLayout_3")
        self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
        self.widget_5 = QWidget(self.widget_2)
        self.widget_5.setObjectName(u"widget_5")
        sizePolicy2.setHeightForWidth(self.widget_5.sizePolicy().hasHeightForWidth())
        self.widget_5.setSizePolicy(sizePolicy2)
        self.widget_5.setMinimumSize(QSize(0, 255))
        self.widget_5.setMaximumSize(QSize(16777215, 255))
        palette4 = QPalette()
        palette4.setBrush(QPalette.Active, QPalette.Base, brush)
        brush3 = QBrush(QColor(153, 204, 51, 255))
        brush3.setStyle(Qt.SolidPattern)
        palette4.setBrush(QPalette.Active, QPalette.Window, brush3)
        palette4.setBrush(QPalette.Inactive, QPalette.Base, brush)
        palette4.setBrush(QPalette.Inactive, QPalette.Window, brush3)
        palette4.setBrush(QPalette.Disabled, QPalette.Base, brush3)
        palette4.setBrush(QPalette.Disabled, QPalette.Window, brush3)
        self.widget_5.setPalette(palette4)
        self.widget_5.setAutoFillBackground(True)
        self.horizontalLayout_5 = QHBoxLayout(self.widget_5)
        self.horizontalLayout_5.setSpacing(0)
        self.horizontalLayout_5.setObjectName(u"horizontalLayout_5")
        self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
        self.widget_6 = QWidget(self.widget_5)
        self.widget_6.setObjectName(u"widget_6")
        palette5 = QPalette()
        palette5.setBrush(QPalette.Active, QPalette.Base, brush)
        palette5.setBrush(QPalette.Active, QPalette.Window, brush)
        palette5.setBrush(QPalette.Inactive, QPalette.Base, brush)
        palette5.setBrush(QPalette.Inactive, QPalette.Window, brush)
        palette5.setBrush(QPalette.Disabled, QPalette.Base, brush)
        palette5.setBrush(QPalette.Disabled, QPalette.Window, brush)
        self.widget_6.setPalette(palette5)
        self.widget_6.setAutoFillBackground(True)
        self.verticalLayout_6 = QVBoxLayout(self.widget_6)
        self.verticalLayout_6.setSpacing(0)
        self.verticalLayout_6.setObjectName(u"verticalLayout_6")
        self.verticalLayout_6.setContentsMargins(0, 0, 0, 0)
        self.widget_4 = QWidget(self.widget_6)
        self.widget_4.setObjectName(u"widget_4")
        sizePolicy1.setHeightForWidth(self.widget_4.sizePolicy().hasHeightForWidth())
        self.widget_4.setSizePolicy(sizePolicy1)
        self.widget_4.setMinimumSize(QSize(200, 85))
        self.widget_4.setMaximumSize(QSize(200, 85))
        self.horizontalLayout_2 = QHBoxLayout(self.widget_4)
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.label_5 = QLabel(self.widget_4)
        self.label_5.setObjectName(u"label_5")
        self.label_5.setMaximumSize(QSize(140, 39))
        self.label_5.setPixmap(QPixmap(u":/partner_logos/VTT_logo_2018.png"))
        self.label_5.setScaledContents(True)
        self.label_5.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_2.addWidget(self.label_5)


        self.verticalLayout_6.addWidget(self.widget_4)

        self.widget_10 = QWidget(self.widget_6)
        self.widget_10.setObjectName(u"widget_10")
        sizePolicy1.setHeightForWidth(self.widget_10.sizePolicy().hasHeightForWidth())
        self.widget_10.setSizePolicy(sizePolicy1)
        self.widget_10.setMinimumSize(QSize(200, 85))
        self.widget_10.setMaximumSize(QSize(200, 16777215))
        self.horizontalLayout_3 = QHBoxLayout(self.widget_10)
        self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
        self.label_7 = QLabel(self.widget_10)
        self.label_7.setObjectName(u"label_7")
        sizePolicy1.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth())
        self.label_7.setSizePolicy(sizePolicy1)
        self.label_7.setMaximumSize(QSize(67, 67))
        self.label_7.setPixmap(QPixmap(u":/partner_logos/UCD_Dublin_logo.png"))
        self.label_7.setScaledContents(True)
        self.label_7.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_3.addWidget(self.label_7)


        self.verticalLayout_6.addWidget(self.widget_10)

        self.widget_11 = QWidget(self.widget_6)
        self.widget_11.setObjectName(u"widget_11")
        sizePolicy1.setHeightForWidth(self.widget_11.sizePolicy().hasHeightForWidth())
        self.widget_11.setSizePolicy(sizePolicy1)
        self.widget_11.setMinimumSize(QSize(200, 85))
        self.widget_11.setMaximumSize(QSize(200, 85))
        self.horizontalLayout_6 = QHBoxLayout(self.widget_11)
        self.horizontalLayout_6.setObjectName(u"horizontalLayout_6")
        self.label_6 = QLabel(self.widget_11)
        self.label_6.setObjectName(u"label_6")
        self.label_6.setMaximumSize(QSize(68, 68))
        self.label_6.setPixmap(QPixmap(u":/partner_logos/KTH_logo.png"))
        self.label_6.setScaledContents(True)
        self.label_6.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_6.addWidget(self.label_6)


        self.verticalLayout_6.addWidget(self.widget_11)


        self.horizontalLayout_5.addWidget(self.widget_6)

        self.widget_7 = QWidget(self.widget_5)
        self.widget_7.setObjectName(u"widget_7")
        palette6 = QPalette()
        palette6.setBrush(QPalette.Active, QPalette.Base, brush)
        palette6.setBrush(QPalette.Active, QPalette.Window, brush)
        palette6.setBrush(QPalette.Inactive, QPalette.Base, brush)
        palette6.setBrush(QPalette.Inactive, QPalette.Window, brush)
        palette6.setBrush(QPalette.Disabled, QPalette.Base, brush)
        palette6.setBrush(QPalette.Disabled, QPalette.Window, brush)
        self.widget_7.setPalette(palette6)
        self.widget_7.setAutoFillBackground(True)
        self.verticalLayout_5 = QVBoxLayout(self.widget_7)
        self.verticalLayout_5.setSpacing(0)
        self.verticalLayout_5.setObjectName(u"verticalLayout_5")
        self.verticalLayout_5.setContentsMargins(0, 0, 0, 0)
        self.widget_12 = QWidget(self.widget_7)
        self.widget_12.setObjectName(u"widget_12")
        sizePolicy1.setHeightForWidth(self.widget_12.sizePolicy().hasHeightForWidth())
        self.widget_12.setSizePolicy(sizePolicy1)
        self.widget_12.setMinimumSize(QSize(200, 85))
        self.widget_12.setMaximumSize(QSize(200, 85))
        self.horizontalLayout_7 = QHBoxLayout(self.widget_12)
        self.horizontalLayout_7.setObjectName(u"horizontalLayout_7")
        self.label_4 = QLabel(self.widget_12)
        self.label_4.setObjectName(u"label_4")
        sizePolicy1.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
        self.label_4.setSizePolicy(sizePolicy1)
        self.label_4.setMaximumSize(QSize(166, 34))
        self.label_4.setPixmap(QPixmap(u":/partner_logos/Energy_Reform_logo.png"))
        self.label_4.setScaledContents(True)
        self.label_4.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_7.addWidget(self.label_4)


        self.verticalLayout_5.addWidget(self.widget_12)

        self.widget_13 = QWidget(self.widget_7)
        self.widget_13.setObjectName(u"widget_13")
        sizePolicy1.setHeightForWidth(self.widget_13.sizePolicy().hasHeightForWidth())
        self.widget_13.setSizePolicy(sizePolicy1)
        self.widget_13.setMinimumSize(QSize(200, 85))
        self.widget_13.setMaximumSize(QSize(200, 85))
        self.horizontalLayout_8 = QHBoxLayout(self.widget_13)
        self.horizontalLayout_8.setObjectName(u"horizontalLayout_8")
        self.label_2 = QLabel(self.widget_13)
        self.label_2.setObjectName(u"label_2")
        sizePolicy1.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
        self.label_2.setSizePolicy(sizePolicy1)
        self.label_2.setMaximumSize(QSize(90, 32))
        self.label_2.setPixmap(QPixmap(u":/partner_logos/KU_Leuven_logo.png"))
        self.label_2.setScaledContents(True)
        self.label_2.setAlignment(Qt.AlignCenter)

        self.horizontalLayout_8.addWidget(self.label_2)


        self.verticalLayout_5.addWidget(self.widget_13)

        self.widget_14 = QWidget(self.widget_7)
        self.widget_14.setObjectName(u"widget_14")
        sizePolicy4 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
        sizePolicy4.setHorizontalStretch(0)
        sizePolicy4.setVerticalStretch(0)
        sizePolicy4.setHeightForWidth(self.widget_14.sizePolicy().hasHeightForWidth())
        self.widget_14.setSizePolicy(sizePolicy4)
        self.widget_14.setMinimumSize(QSize(0, 85))
        self.widget_14.setMaximumSize(QSize(16777215, 85))
        self.horizontalLayout_9 = QHBoxLayout(self.widget_14)
        self.horizontalLayout_9.setSpacing(0)
        self.horizontalLayout_9.setObjectName(u"horizontalLayout_9")
        self.horizontalLayout_9.setContentsMargins(0, 0, 0, 0)
        self.label_3 = QLabel(self.widget_14)
        self.label_3.setObjectName(u"label_3")
        sizePolicy1.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
        self.label_3.setSizePolicy(sizePolicy1)
        self.label_3.setMinimumSize(QSize(200, 85))
        self.label_3.setMaximumSize(QSize(200, 85))
        font4 = QFont()
        font4.setFamily(u"Arial Black")
        font4.setPointSize(8)
        font4.setBold(True)
        font4.setWeight(75)
        self.label_3.setFont(font4)
        self.label_3.setStyleSheet(u"background-color: rgb(0, 74, 194);")
        self.label_3.setTextFormat(Qt.RichText)
        self.label_3.setAlignment(Qt.AlignCenter)
        self.label_3.setMargin(0)
        self.label_3.setOpenExternalLinks(True)

        self.horizontalLayout_9.addWidget(self.label_3)


        self.verticalLayout_5.addWidget(self.widget_14)


        self.horizontalLayout_5.addWidget(self.widget_7)


        self.verticalLayout_3.addWidget(self.widget_5)


        self.verticalLayout_2.addWidget(self.widget_2)


        self.retranslateUi(Form)

        QMetaObject.connectSlotsByName(Form)
 def _random_color():
     r = random.randint(0, 255)
     g = random.randint(0, 255)
     b = random.randint(0, 255)
     return QColor(r, g, b)
Exemple #8
0
 def get_color(self, color):
     """"""
     return QColor(*[int(color[s:s + 2], 16) for s in range(1, 6, 2)])
Exemple #9
0
class DesignContainer(QObject):

    # flow_themes = ['dark std', 'dark tron', 'ghostly', 'blender']
    flow_themes = [
        FlowTheme('dark std', QColor(188, 187, 242), 5, Qt.SolidLine,
                  QColor(188, 187, 242), 5, Qt.DashLine, NIPainter_DarkStd),
        FlowTheme('dark tron', QColor(0, 120, 180), 4, Qt.SolidLine,
                  QColor(0, 120, 180), 4, Qt.DashLine, NIPainter_DarkTron),
        FlowTheme('ghostly', QColor(0, 17, 25), 2, Qt.SolidLine,
                  QColor(0, 17, 25), 2, Qt.DashLine, NIPainter_Ghostly),
        FlowTheme('blender', QColor(0, 17, 25), 2, Qt.SolidLine,
                  QColor(0, 17, 25), 2, Qt.DashLine, NIPainter_Blender),
        FlowTheme('easy', QColor('#989c9f'), 2, Qt.SolidLine,
                  QColor('#989c9f'), 2, Qt.DashLine, NIPainter_Easy,
                  QColor('#212429')),
        FlowTheme('peasy', QColor('#989c9f'), 2, Qt.SolidLine,
                  QColor('#989c9f'), 2, Qt.DashLine, NIPainter_Peasy,
                  QColor('#3f4044'))
    ]

    start_flow_theme = flow_themes[-1]
    flow_theme = None  # initialized by MainWindow
    flow_theme_changed = Signal(str)
    performance_mode = 'fast'

    def set_flow_theme(self, new_theme: str = None):
        self.flow_theme = new_theme if new_theme is not None else self.start_flow_theme
        self.flow_theme_changed.emit(self.flow_theme.name)

    def set_performance_mode(self, new_mode):
        self.performance_mode = new_mode
        if new_mode == 'fast':
            Design.node_instance_shadows_shown = False
        else:
            Design.node_instance_shadows_shown = True

        # the performance mode affects the flow's foreground theme
        self.flow_theme_changed.emit(self.flow_theme)

    ryven_stylesheet = None
    node_instance_shadows_shown = False
    animations_enabled = True
Exemple #10
0
    def redraw(self):
        x = np.arange(256)
        alpha = 0.25
        rgb = self.rgb_radio.isChecked()
        red = self.red_radio.isChecked()
        green = self.green_radio.isChecked()
        blue = self.blue_radio.isChecked()
        value = self.value_radio.isChecked()
        smoothness = self.smooth_check.isChecked()
        grid = self.grid_check.isChecked()
        log = self.log_check.isChecked()
        try:
            self.axes.clear()
        except RecursionError:
            return
        y = None
        step = None if smoothness else 'mid'
        if value:
            y = self.hist[3]
            if smoothness:
                self.axes.plot(x, y, 'k')
            else:
                self.axes.step(x, y, 'k', where='mid')
            self.axes.fill_between(x, y, alpha=alpha, facecolor='k', step=step)
        else:
            if red or rgb:
                y = self.hist[0]
                if smoothness:
                    self.axes.plot(x, y, 'r')
                else:
                    self.axes.step(x, y, 'r', where='mid')
                self.axes.fill_between(x,
                                       y,
                                       alpha=alpha,
                                       facecolor='r',
                                       step=step)
            if green or rgb:
                y = self.hist[1]
                if smoothness:
                    self.axes.plot(x, y, 'g')
                else:
                    self.axes.step(x, y, 'g', where='mid')
                self.axes.fill_between(x,
                                       y,
                                       alpha=alpha,
                                       facecolor='g',
                                       step=step)
            if blue or rgb:
                y = self.hist[2]
                if smoothness:
                    self.axes.plot(x, y, 'b')
                else:
                    self.axes.step(x, y, 'b', where='mid')
                self.axes.fill_between(x,
                                       y,
                                       alpha=alpha,
                                       facecolor='b',
                                       step=step)
        if log:
            self.axes.set_yscale('log')
            self.axes.set_ylim(bottom=1)
        else:
            self.axes.set_yscale('linear')
            self.axes.set_ylim(bottom=0)
        self.axes.set_xlim([0, 255])
        self.axes.set_xlabel(self.tr('intensity value'))
        self.axes.set_ylabel(self.tr('pixel count'))
        self.axes.set_xticks([0, 64, 128, 192, 255])
        self.axes.grid(grid, which='both')

        if rgb:
            self.table_widget.setEnabled(False)
            self.marker_check.setEnabled(False)
            self.start_slider.setEnabled(False)
            self.end_slider.setEnabled(False)
            for i in range(self.table_widget.rowCount()):
                if self.table_widget.item(i, 1) is not None:
                    self.table_widget.item(i, 1).setText('')
                    self.table_widget.item(i, 1).setBackgroundColor(
                        QColor('white'))
        else:
            self.table_widget.setEnabled(True)
            self.marker_check.setEnabled(True)
            self.start_slider.setEnabled(True)
            self.end_slider.setEnabled(True)
            start = self.start_slider.value()
            end = self.end_slider.value()
            if end <= start:
                end = start + 1
            elif start >= end:
                start = end - 1
            total = np.sum(y)
            x = x[start:end + 1]
            y = y[start:end + 1]
            count = np.sum(y)
            if count != 0:
                argmin = np.argmin(y) + start
                argmax = np.argmax(y) + start
                mean = np.round(np.sum(x * y) / count, 2)
                stddev = np.round(np.sqrt(np.sum(((x - mean)**2) * y) / count),
                                  2)
                median = np.argmax(np.cumsum(y) > count / 2) + start
                percent = np.round(count / total * 100, 2)
                empty = len(x) - np.count_nonzero(y)
                nonzero = [
                    np.nonzero(y)[0][0] + start,
                    np.nonzero(y)[0][-1] + start
                ]
                fullness = np.round(count / (255 * np.max(y)) * 100, 2)
                y = y / np.max(y)
                sweep = len(y)
                smoothness = 0
                if sweep >= 5:
                    for i in range(2, sweep - 2):
                        yl = 2 * y[i - 1] - y[i - 2]
                        yr = 2 * y[i + 1] - y[i + 2]
                        smoothness += abs(y[i] - (yl + yr) / 2)
                    smoothness = np.round(
                        (1 - (smoothness / (sweep - 2))) * 100, 2)
                if self.marker_check.isChecked():
                    self.axes.axvline(argmin, linestyle='--', color='m')
                    self.axes.axvline(mean, linestyle='-', color='m')
                    self.axes.axvline(argmax, linestyle='-.', color='m')
                    self.axes.axvline(median, linestyle=':', color='m')
            else:
                argmin = argmax = mean = stddev = median = percent = smoothness = empty = nonzero = fullness = 0

            self.table_widget.setItem(0, 1, QTableWidgetItem(str(argmin)))
            self.table_widget.setItem(1, 1, QTableWidgetItem(str(argmax)))
            self.table_widget.setItem(2, 1, QTableWidgetItem(str(mean)))
            self.table_widget.setItem(3, 1, QTableWidgetItem(str(median)))
            self.table_widget.setItem(4, 1, QTableWidgetItem(str(stddev)))
            self.table_widget.setItem(5, 1, QTableWidgetItem(str(count)))
            self.table_widget.setItem(6, 1,
                                      QTableWidgetItem(str(percent) + '%'))
            self.table_widget.setItem(7, 1, QTableWidgetItem(str(nonzero)))
            self.table_widget.setItem(8, 1, QTableWidgetItem(str(empty)))
            self.table_widget.setItem(
                9, 1, QTableWidgetItem(str(self.unique_colors)))
            self.table_widget.setItem(
                10, 1, QTableWidgetItem(str(self.unique_ratio) + '%'))
            color_by_value(self.table_widget.item(10, 1), self.unique_ratio,
                           [25, 50, 75])
            self.table_widget.setItem(11, 1,
                                      QTableWidgetItem(str(smoothness) + '%'))
            color_by_value(self.table_widget.item(11, 1), smoothness,
                           [80, 90, 95])
            self.table_widget.setItem(12, 1,
                                      QTableWidgetItem(str(fullness) + '%'))
            color_by_value(self.table_widget.item(12, 1), fullness,
                           [5, 10, 20])
            self.table_widget.resizeColumnsToContents()
            if start != 0 or end != 255:
                self.axes.axvline(start, linestyle=':', color='k')
                self.axes.axvline(end, linestyle=':', color='k')
                _, top = self.axes.get_ylim()
                self.axes.fill_between(np.arange(start, end + 1),
                                       top,
                                       facecolor='y',
                                       alpha=alpha * 2)
        self.axes.figure.canvas.draw()
Exemple #11
0
from PySide2.QtCore import (QObject, Slot, Signal)
from PySide2.QtWidgets import (QAction, QActionGroup, QMenu, QPlainTextEdit)
from PySide2.QtGui import (QTextCursor, QColor, QTextCharFormat,
                           QTextBlockUserData)
from datetime import datetime
from mozlog.structuredlog import log_levels

from mozlog import get_default_logger

COLORS = {
    'DEBUG': QColor(6, 146, 6),  # green
    'INFO': QColor(250, 184, 4),  # deep yellow
    'WARNING': QColor(255, 0, 0, 127),  # red
    'CRITICAL': QColor(255, 0, 0, 127),
    'ERROR': QColor(255, 0, 0, 127),
}


class LogLevelData(QTextBlockUserData):
    def __init__(self, log_lvl):
        QTextBlockUserData.__init__(self)
        self.log_lvl = log_lvl


class LogView(QPlainTextEdit):
    def __init__(self, parent=None):
        QPlainTextEdit.__init__(self, parent)
        self.setMaximumBlockCount(1000)

        self.group = QActionGroup(self)
        self.actions = [
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(799, 408)
        icon = QIcon()
        icon.addFile(u":/newPrefix/cup.png", QSize(), QIcon.Normal, QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setStyleSheet(
            u"QMainWindow{background: url(:/backgrouns/backgrouns/colorful-paint-splash-hd-wallpapers-66011-1930804.png)}"
        )
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.centralwidget.setMinimumSize(QSize(100, 357))
        self.centralwidget.setMaximumSize(QSize(800, 357))
        palette = QPalette()
        brush = QBrush(QColor(255, 255, 255, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush1 = QBrush(QColor(37, 42, 86, 255))
        brush1.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Button, brush1)
        brush2 = QBrush(QColor(55, 63, 129, 255))
        brush2.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Light, brush2)
        brush3 = QBrush(QColor(46, 52, 107, 255))
        brush3.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Midlight, brush3)
        brush4 = QBrush(QColor(18, 21, 43, 255))
        brush4.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Dark, brush4)
        brush5 = QBrush(QColor(24, 28, 57, 255))
        brush5.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Mid, brush5)
        palette.setBrush(QPalette.Active, QPalette.Text, brush)
        palette.setBrush(QPalette.Active, QPalette.BrightText, brush)
        palette.setBrush(QPalette.Active, QPalette.ButtonText, brush)
        brush6 = QBrush(QColor(0, 0, 0, 255))
        brush6.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Base, brush6)
        palette.setBrush(QPalette.Active, QPalette.Window, brush1)
        palette.setBrush(QPalette.Active, QPalette.Shadow, brush6)
        palette.setBrush(QPalette.Active, QPalette.AlternateBase, brush4)
        brush7 = QBrush(QColor(255, 255, 220, 255))
        brush7.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.ToolTipBase, brush7)
        palette.setBrush(QPalette.Active, QPalette.ToolTipText, brush6)
        brush8 = QBrush(QColor(255, 255, 255, 128))
        brush8.setStyle(Qt.SolidPattern)

        palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Button, brush1)
        palette.setBrush(QPalette.Inactive, QPalette.Light, brush2)
        palette.setBrush(QPalette.Inactive, QPalette.Midlight, brush3)
        palette.setBrush(QPalette.Inactive, QPalette.Dark, brush4)
        palette.setBrush(QPalette.Inactive, QPalette.Mid, brush5)
        palette.setBrush(QPalette.Inactive, QPalette.Text, brush)
        palette.setBrush(QPalette.Inactive, QPalette.BrightText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush6)
        palette.setBrush(QPalette.Inactive, QPalette.Window, brush1)
        palette.setBrush(QPalette.Inactive, QPalette.Shadow, brush6)
        palette.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush4)
        palette.setBrush(QPalette.Inactive, QPalette.ToolTipBase, brush7)
        palette.setBrush(QPalette.Inactive, QPalette.ToolTipText, brush6)

        palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush4)
        palette.setBrush(QPalette.Disabled, QPalette.Button, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.Light, brush2)
        palette.setBrush(QPalette.Disabled, QPalette.Midlight, brush3)
        palette.setBrush(QPalette.Disabled, QPalette.Dark, brush4)
        palette.setBrush(QPalette.Disabled, QPalette.Mid, brush5)
        palette.setBrush(QPalette.Disabled, QPalette.Text, brush4)
        palette.setBrush(QPalette.Disabled, QPalette.BrightText, brush)
        palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush4)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.Window, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.Shadow, brush6)
        palette.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.ToolTipBase, brush7)
        palette.setBrush(QPalette.Disabled, QPalette.ToolTipText, brush6)
        #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)

        #endif
        self.centralwidget.setPalette(palette)
        self.centralwidget.setAutoFillBackground(False)
        self.centralwidget.setStyleSheet(
            u"centralwidget{background: url(:/backgrouns/wallpaper.jpg)}")
        self.horizontalLayoutWidget = QWidget(self.centralwidget)
        self.horizontalLayoutWidget.setObjectName(u"horizontalLayoutWidget")
        self.horizontalLayoutWidget.setGeometry(QRect(10, 0, 781, 351))
        self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.groupBox = QGroupBox(self.horizontalLayoutWidget)
        self.groupBox.setObjectName(u"groupBox")
        self.groupBox.setMinimumSize(QSize(375, 0))
        self.groupBox.setAutoFillBackground(False)
        self.groupBox.setStyleSheet(
            u"QGroupBox{background: url(:/backgrouns/Abstract_Background_with_Blue_Triangles.jpg)}"
        )
        self.groupBox.setFlat(False)
        self.scalePortList = QComboBox(self.groupBox)
        self.scalePortList.setObjectName(u"scalePortList")
        self.scalePortList.setGeometry(QRect(10, 60, 151, 21))
        self.pumpPortList = QComboBox(self.groupBox)
        self.pumpPortList.setObjectName(u"pumpPortList")
        self.pumpPortList.setGeometry(QRect(190, 61, 161, 21))
        self.pumpPortList.setAutoFillBackground(True)
        self.label = QLabel(self.groupBox)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(10, 30, 81, 21))
        font = QFont()
        font.setPointSize(10)
        self.label.setFont(font)
        self.label_2 = QLabel(self.groupBox)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setGeometry(QRect(190, 30, 81, 21))
        self.label_2.setFont(font)
        self.label_2.setStyleSheet(u"")
        self.serialCheck = QCheckBox(self.groupBox)
        self.serialCheck.setObjectName(u"serialCheck")
        self.serialCheck.setGeometry(QRect(280, 30, 81, 20))
        self.lcdNumber = QLCDNumber(self.groupBox)
        self.lcdNumber.setObjectName(u"lcdNumber")
        self.lcdNumber.setGeometry(QRect(190, 140, 64, 23))
        self.lcdNumber.setAutoFillBackground(True)
        self.lcdNumber.setSegmentStyle(QLCDNumber.Flat)
        self.dial = QDial(self.groupBox)
        self.dial.setObjectName(u"dial")
        self.dial.setGeometry(QRect(160, 90, 111, 51))
        self.dial.setMaximum(600)
        self.label_4 = QLabel(self.groupBox)
        self.label_4.setObjectName(u"label_4")
        self.label_4.setGeometry(QRect(144, 140, 31, 20))

        self.verticalLayout.addWidget(self.groupBox)

        self.groupBox_2 = QGroupBox(self.horizontalLayoutWidget)
        self.groupBox_2.setObjectName(u"groupBox_2")
        self.groupBox_2.setAutoFillBackground(False)
        self.groupBox_2.setStyleSheet(
            u"QGroupBox{background:url(:/backgrouns/fractalvisual.jpg)}")
        self.groupBox_2.setFlat(False)
        self.expStart = QPushButton(self.groupBox_2)
        self.expStart.setObjectName(u"expStart")
        self.expStart.setGeometry(QRect(250, 70, 91, 31))
        icon1 = QIcon()
        icon1.addFile(u":/newPrefix/resultset_next.png", QSize(), QIcon.Normal,
                      QIcon.Off)
        self.expStart.setIcon(icon1)
        self.expStart.setCheckable(True)
        self.weightBox = QLineEdit(self.groupBox_2)
        self.weightBox.setObjectName(u"weightBox")
        self.weightBox.setGeometry(QRect(210, 30, 113, 22))
        self.stopButton = QPushButton(self.groupBox_2)
        self.stopButton.setObjectName(u"stopButton")
        self.stopButton.setEnabled(False)
        self.stopButton.setGeometry(QRect(190, 70, 51, 31))
        icon2 = QIcon()
        icon2.addFile(u":/newPrefix/stop.png", QSize(), QIcon.Normal,
                      QIcon.Off)
        self.stopButton.setIcon(icon2)
        self.label_3 = QLabel(self.groupBox_2)
        self.label_3.setObjectName(u"label_3")
        self.label_3.setGeometry(QRect(120, 30, 91, 21))
        palette1 = QPalette()
        brush9 = QBrush(QColor(193, 177, 55, 255))
        brush9.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.WindowText, brush9)
        brush10 = QBrush(QColor(168, 162, 90, 255))
        brush10.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.Text, brush10)
        brush11 = QBrush(QColor(189, 177, 47, 255))
        brush11.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.ToolTipText, brush11)
        brush12 = QBrush(QColor(168, 162, 90, 128))
        brush12.setStyle(Qt.SolidPattern)

        palette1.setBrush(QPalette.Inactive, QPalette.WindowText, brush9)
        palette1.setBrush(QPalette.Inactive, QPalette.Text, brush10)
        palette1.setBrush(QPalette.Inactive, QPalette.ToolTipText, brush11)

        brush13 = QBrush(QColor(120, 120, 120, 255))
        brush13.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Disabled, QPalette.WindowText, brush13)
        palette1.setBrush(QPalette.Disabled, QPalette.Text, brush13)
        palette1.setBrush(QPalette.Disabled, QPalette.ToolTipText, brush11)
        brush14 = QBrush(QColor(0, 0, 0, 128))
        brush14.setStyle(Qt.SolidPattern)

        self.label_3.setPalette(palette1)
        self.label_3.setFont(font)

        self.verticalLayout.addWidget(self.groupBox_2)

        self.horizontalLayout.addLayout(self.verticalLayout)

        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setSpacing(26)
        self.verticalLayout_3.setObjectName(u"verticalLayout_3")
        self.resultBox = QPlainTextEdit(self.horizontalLayoutWidget)
        self.resultBox.setObjectName(u"resultBox")
        self.resultBox.setMaximumSize(QSize(400, 400))
        self.resultBox.setReadOnly(True)

        self.verticalLayout_3.addWidget(self.resultBox)

        self.progressBar = QProgressBar(self.horizontalLayoutWidget)
        self.progressBar.setObjectName(u"progressBar")
        self.progressBar.setMaximumSize(QSize(400, 16777215))
        self.progressBar.setValue(24)

        self.verticalLayout_3.addWidget(self.progressBar)

        self.horizontalLayout.addLayout(self.verticalLayout_3)

        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 799, 26))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        self.expStart.toggled.connect(self.stopButton.setEnabled)
        self.stopButton.clicked.connect(self.expStart.setEnabled)
        self.expStart.toggled.connect(self.expStart.setDisabled)
        self.stopButton.clicked.connect(self.expStart.setChecked)
        self.dial.valueChanged.connect(self.lcdNumber.display)

        QMetaObject.connectSlotsByName(MainWindow)
Exemple #13
0
    def __init__(
        self,
        orientation=-1,  # for compatibility with QSlider
        min=0,
        max=1,
        val=0,
        marks=None,
        *args,
        **kwargs,
    ):
        super(VideoSlider, self).__init__(*args, **kwargs)

        self.scene = QtWidgets.QGraphicsScene()
        self.setScene(self.scene)
        self.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)

        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        self.setMouseTracking(True)

        self._get_val_tooltip = None

        self.tick_index_offset = 1
        self.zoom_factor = 1

        self._track_rows = 0
        self._track_height = 5
        self._max_tracks_stacked = 120
        self._track_stack_skip_count = 10
        self._header_label_height = 20
        self._header_graph_height = 30
        self._header_height = self._header_label_height  # room for frame labels
        self._min_height = 19 + self._header_height

        self._base_font = QtGui.QFont()
        self._base_font.setPixelSize(10)

        self._tick_marks = []

        # Add border rect
        outline_rect = QtCore.QRectF(0, 0, 200, self._min_height - 3)
        self.box_rect = outline_rect
        # self.outlineBox = self.scene.addRect(outline_rect)
        # self.outlineBox.setPen(QPen(QColor("black", alpha=0)))

        # Add drag handle rect
        self._handle_width = 6
        handle_rect = QtCore.QRect(
            0, self._handle_top, self._handle_width, self._handle_height
        )
        self.setMinimumHeight(self._min_height)
        self.setMaximumHeight(self._min_height)
        self.handle = self.scene.addRect(handle_rect)
        self.handle.setPen(QPen(QColor(80, 80, 80)))
        self.handle.setBrush(QColor(128, 128, 128, 128))

        # Add (hidden) rect to highlight selection
        self.select_box = self.scene.addRect(
            QtCore.QRect(0, 1, 0, outline_rect.height() - 2)
        )
        self.select_box.setPen(QPen(QColor(80, 80, 255)))
        self.select_box.setBrush(QColor(80, 80, 255, 128))
        self.select_box.hide()

        self.zoom_box = self.scene.addRect(
            QtCore.QRect(0, 1, 0, outline_rect.height() - 2)
        )
        self.zoom_box.setPen(QPen(QColor(80, 80, 80, 64)))
        self.zoom_box.setBrush(QColor(80, 80, 80, 64))
        self.zoom_box.hide()

        self.scene.setBackgroundBrush(QBrush(QColor(200, 200, 200)))

        self.clearSelection()
        self.setEnabled(True)
        self.setMinimum(min)
        self.setMaximum(max)
        self.setValue(val)
        self.setMarks(marks)

        pen = QPen(QColor(80, 80, 255), 0.5)
        pen.setCosmetic(True)
        self.poly = self.scene.addPath(QPainterPath(), pen, self.select_box.brush())
        self.headerSeries = dict()
        self._draw_header()
Exemple #14
0
    def paint(self, painter, option, widget=None):

        painter.setRenderHint(QPainter.Antialiasing)
        brush = QBrush(QColor(100, 100, 100, 150))  # QBrush(QColor('#3B9CD9'))
        painter.setBrush(brush)
        std_pen = QPen(
            QColor(30, 43, 48)
        )  # QColor(30, 43, 48)  # used for header title and minimal std dark border
        std_pen.setWidthF(1.5)
        # painter.setPen(std_pen)

        if self.parent_node.design_style == 'extended':

            header_pen = std_pen  # differs from std_pen in tron design

            if Design.flow_style == 'dark std':
                self.draw_dark_extended_background(painter)

                if option.state & QStyle.State_MouseOver:  # make title color white when mouse hovers
                    c = self.parent_node.color.lighter()
                    header_pen = QPen(c)
                    header_pen.setWidth(2)

            elif Design.flow_style == 'dark tron':
                self.draw_tron_extended_background(painter)

                c = self.parent_node.color
                if option.state & QStyle.State_MouseOver:  # make title color lighter when mouse hovers
                    c = self.parent_node.color.lighter()
                header_pen = QPen(c)
                header_pen.setWidth(2)

            # HEADER
            painter.setFont(self.display_name_font)
            painter.setPen(header_pen)
            painter.drawText(self.get_title_rect(),
                             Qt.AlignVCenter | Qt.AlignLeft,
                             self.parent_node.title)
            painter.setBrush(Qt.NoBrush)
            painter.setPen(QPen(Qt.white, 1))

        elif self.parent_node.design_style == 'minimalistic':

            if Design.flow_style == 'dark std':
                self.draw_dark_minimalistic(painter, std_pen)
                if option.state & QStyle.State_MouseOver:  # make title color light when mouse hovers
                    pen = QPen(self.parent_node.color.lighter())
                    painter.setPen(pen)

            elif Design.flow_style == 'dark tron':
                if option.state & QStyle.State_MouseOver:  # use special dark background color when mouse hovers
                    self.draw_tron_minimalistic(
                        painter,
                        background_color=self.parent_node.color.darker())
                else:
                    self.draw_tron_minimalistic(painter)

            # HEADER
            painter.setFont(self.display_name_font)
            painter.drawText(self.boundingRect(), Qt.AlignCenter,
                             self.parent_node.title)
Exemple #15
0
    "Issues": "https://github.com/khopa/dcs_liberation/issues"
}

LABELS_OPTIONS = ["Full", "Abbreviated", "Dot Only", "Off"]
SKILL_OPTIONS = ["Average", "Good", "High", "Excellent"]

FONT_SIZE = 8
FONT_NAME = "Arial"
# FONT = QFont("Arial", 12, weight=5, italic=True)
FONT_PRIMARY = QFont(FONT_NAME, FONT_SIZE, weight=5, italic=False)
FONT_PRIMARY_I = QFont(FONT_NAME, FONT_SIZE, weight=5, italic=True)
FONT_PRIMARY_B = QFont(FONT_NAME, FONT_SIZE, weight=75, italic=False)
FONT_MAP = QFont(FONT_NAME, 10, weight=75, italic=False)

COLORS: Dict[str, QColor] = {
    "white": QColor(255, 255, 255),
    "white_transparent": QColor(255, 255, 255, 35),
    "light_red": QColor(231, 92, 83, 90),
    "red": QColor(200, 80, 80),
    "dark_red": QColor(140, 20, 20),
    "red_transparent": QColor(227, 32, 0, 20),
    "transparent": QColor(255, 255, 255, 0),
    "light_blue": QColor(105, 182, 240, 90),
    "blue": QColor(0, 132, 255),
    "dark_blue": QColor(45, 62, 80),
    "sea_blue": QColor(52, 68, 85),
    "sea_blue_transparent": QColor(52, 68, 85, 150),
    "blue_transparent": QColor(0, 132, 255, 20),
    "purple": QColor(187, 137, 255),
    "yellow": QColor(238, 225, 123),
    "bright_red": QColor(150, 80, 80),
Exemple #16
0
    def __init__(self, parentgrid, theme=1):
        '''parentgrid: grid para ubicar el grafico | teme 1: predeterminado, teme 2: personalizado'''

        # 0. DATOS A REGISTRAR *-*-*-*-*-*-*-*-*-*-*
        dato_titulo = "Ejemplo"
        dato_nombres = ["Uno", "Dos", "Tres", "Cuatro"]
        dato_colores = ["#e3722d", "#f0b904", "#6caa3f", "#42A5F8"]
        dato_datos = [
            # ---"Uno" ------ "Dos" --------- "Tres" --------- "Cuatro" ---
            randint(80, 800),
            randint(80, 800),
            randint(80, 800),
            randint(80, 800)
        ]

        # 1. PIESLICE *-*-*-*-*-*-*-*-*-*-*
        listapieslice = self.creador_pieslice(valores=dato_datos,
                                              colores=dato_colores)

        # 2. PIESERIES *-*-*-*-*-*-*-*-*-*-*
        pieSeries = self.creador_pieseries(lista_pieslice=listapieslice,
                                           marcaindice=[1])

        # 3. PIESLICE LABELS *-*-*-*-*-*-*-*-*-*-*
        self.creador_pieslicelabels(lista_pieslice=listapieslice,
                                    valores=dato_datos,
                                    nombres=dato_nombres,
                                    decimales=1)

        # 4. CHART *-*-*-*-*-*-*-*-*-*-*
        chart = self.creador_chart(pieseries=pieSeries,
                                   titulo=dato_titulo,
                                   theme=theme)

        # 5. CHARTVIEW *-*-*-*-*-*-*-*-*-*-*
        chartView = QtCharts.QChartView(chart)
        chartView.setRenderHint(QPainter.Antialiasing)

        if (theme == 1):
            # TEMA PREDETERMINADO *-*-*-*-*-*-*-*-*-*-*

            # temas disponibles /-/-/-/
            'ChartThemeLight | ChartThemeBlueCerulean | ChartThemeDark | ChartThemeBrownSand'
            'ChartThemeBlueNcs | ChartThemeHighContrast | ChartThemeBlueIcy | ChartThemeQt'
            chart.setTheme(QtCharts.QChart.ChartThemeDark)
        else:
            # TEMA PERSONALIZADO *-*-*-*-*-*-*-*-*-*-*

            # definir color de letras /-/-/-/
            chartView.chart().setTitleBrush(QColor("white"))  # titulo
            chartView.chart().legend().setLabelColor(
                QColor("white"))  # etiquetas

            # personalizacion de fondo /-/-/-/
            chartView.chart().setBackgroundVisible(False)  # quitar color
            chartView.setBackgroundBrush(QColor("#141f24"))  # asignar color

        # 6. CONFIGURACIONES *-*-*-*-*-*-*-*-*-*-*

        # leyenda /-/-/-/
        'MarkerShapeDefault | MarkerShapeRectangle | MarkerShapeCircle | MarkerShapeFromSeries'
        chartView.chart().legend().setMarkerShape(
            QtCharts.QLegend.MarkerShapeCircle)

        # tamaño de letra /-/-/-/
        chartView.chart().setTitleFont(self.font_size(25))  # tamaño de titulo
        chartView.chart().legend().setFont(self.font_size(12))

        # fondo /-/-/-/
        chartView.chart().layout().setContentsMargins(0, 0, 0,
                                                      0)  # quitar margenes
        chartView.chart().setBackgroundRoundness(0)  # quitar bordes

        # font sub titulos /-/-/-/
        for sli in pieSeries.slices():
            sli.setLabelFont(self.font_size(14))

        # 7. RESTABLECER WIDGETS *-*-*-*-*-*-*-*-*-*-*
        'limpiar todos los elementos del widget'
        for i in reversed(range(parentgrid.count())):
            parentgrid.itemAt(i).widget().deleteLater()

        # 8. INSERTAR GRAFICO *-*-*-*-*-*-*-*-*-*-*
        parentgrid.addWidget(chartView, 0, 0)
Exemple #17
0
    def setupUi(self, Config):
        if Config.objectName():
            Config.setObjectName(u"Config")
        Config.resize(600, 650)
        Config.setSizeGripEnabled(True)
        self.vboxLayout = QVBoxLayout(Config)
        self.vboxLayout.setSpacing(6)
        self.vboxLayout.setContentsMargins(11, 11, 11, 11)
        self.vboxLayout.setObjectName(u"vboxLayout")
        self.vboxLayout.setContentsMargins(8, 8, 8, 8)
        self.hboxLayout = QHBoxLayout()
        self.hboxLayout.setSpacing(6)
        self.hboxLayout.setObjectName(u"hboxLayout")
        self.hboxLayout.setContentsMargins(0, 0, 0, 0)
        self.ButtonGroup1 = QGroupBox(Config)
        self.ButtonGroup1.setObjectName(u"ButtonGroup1")
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.ButtonGroup1.sizePolicy().hasHeightForWidth())
        self.ButtonGroup1.setSizePolicy(sizePolicy)
        self.vboxLayout1 = QVBoxLayout(self.ButtonGroup1)
        self.vboxLayout1.setSpacing(6)
        self.vboxLayout1.setContentsMargins(11, 11, 11, 11)
        self.vboxLayout1.setObjectName(u"vboxLayout1")
        self.vboxLayout1.setContentsMargins(11, 11, 11, 11)
        self.size_176_220 = QRadioButton(self.ButtonGroup1)
        self.size_176_220.setObjectName(u"size_176_220")

        self.vboxLayout1.addWidget(self.size_176_220)

        self.size_240_320 = QRadioButton(self.ButtonGroup1)
        self.size_240_320.setObjectName(u"size_240_320")

        self.vboxLayout1.addWidget(self.size_240_320)

        self.size_320_240 = QRadioButton(self.ButtonGroup1)
        self.size_320_240.setObjectName(u"size_320_240")

        self.vboxLayout1.addWidget(self.size_320_240)

        self.size_640_480 = QRadioButton(self.ButtonGroup1)
        self.size_640_480.setObjectName(u"size_640_480")

        self.vboxLayout1.addWidget(self.size_640_480)

        self.size_800_600 = QRadioButton(self.ButtonGroup1)
        self.size_800_600.setObjectName(u"size_800_600")

        self.vboxLayout1.addWidget(self.size_800_600)

        self.size_1024_768 = QRadioButton(self.ButtonGroup1)
        self.size_1024_768.setObjectName(u"size_1024_768")

        self.vboxLayout1.addWidget(self.size_1024_768)

        self.hboxLayout1 = QHBoxLayout()
        self.hboxLayout1.setSpacing(6)
        self.hboxLayout1.setObjectName(u"hboxLayout1")
        self.hboxLayout1.setContentsMargins(0, 0, 0, 0)
        self.size_custom = QRadioButton(self.ButtonGroup1)
        self.size_custom.setObjectName(u"size_custom")
        sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy1.setHorizontalStretch(0)
        sizePolicy1.setVerticalStretch(0)
        sizePolicy1.setHeightForWidth(
            self.size_custom.sizePolicy().hasHeightForWidth())
        self.size_custom.setSizePolicy(sizePolicy1)

        self.hboxLayout1.addWidget(self.size_custom)

        self.size_width = QSpinBox(self.ButtonGroup1)
        self.size_width.setObjectName(u"size_width")
        self.size_width.setMinimum(1)
        self.size_width.setMaximum(1280)
        self.size_width.setSingleStep(16)
        self.size_width.setValue(400)

        self.hboxLayout1.addWidget(self.size_width)

        self.size_height = QSpinBox(self.ButtonGroup1)
        self.size_height.setObjectName(u"size_height")
        self.size_height.setMinimum(1)
        self.size_height.setMaximum(1024)
        self.size_height.setSingleStep(16)
        self.size_height.setValue(300)

        self.hboxLayout1.addWidget(self.size_height)

        self.vboxLayout1.addLayout(self.hboxLayout1)

        self.hboxLayout.addWidget(self.ButtonGroup1)

        self.ButtonGroup2 = QGroupBox(Config)
        self.ButtonGroup2.setObjectName(u"ButtonGroup2")
        self.vboxLayout2 = QVBoxLayout(self.ButtonGroup2)
        self.vboxLayout2.setSpacing(6)
        self.vboxLayout2.setContentsMargins(11, 11, 11, 11)
        self.vboxLayout2.setObjectName(u"vboxLayout2")
        self.vboxLayout2.setContentsMargins(11, 11, 11, 11)
        self.depth_1 = QRadioButton(self.ButtonGroup2)
        self.depth_1.setObjectName(u"depth_1")

        self.vboxLayout2.addWidget(self.depth_1)

        self.depth_4gray = QRadioButton(self.ButtonGroup2)
        self.depth_4gray.setObjectName(u"depth_4gray")

        self.vboxLayout2.addWidget(self.depth_4gray)

        self.depth_8 = QRadioButton(self.ButtonGroup2)
        self.depth_8.setObjectName(u"depth_8")

        self.vboxLayout2.addWidget(self.depth_8)

        self.depth_12 = QRadioButton(self.ButtonGroup2)
        self.depth_12.setObjectName(u"depth_12")

        self.vboxLayout2.addWidget(self.depth_12)

        self.depth_15 = QRadioButton(self.ButtonGroup2)
        self.depth_15.setObjectName(u"depth_15")

        self.vboxLayout2.addWidget(self.depth_15)

        self.depth_16 = QRadioButton(self.ButtonGroup2)
        self.depth_16.setObjectName(u"depth_16")

        self.vboxLayout2.addWidget(self.depth_16)

        self.depth_18 = QRadioButton(self.ButtonGroup2)
        self.depth_18.setObjectName(u"depth_18")

        self.vboxLayout2.addWidget(self.depth_18)

        self.depth_24 = QRadioButton(self.ButtonGroup2)
        self.depth_24.setObjectName(u"depth_24")

        self.vboxLayout2.addWidget(self.depth_24)

        self.depth_32 = QRadioButton(self.ButtonGroup2)
        self.depth_32.setObjectName(u"depth_32")

        self.vboxLayout2.addWidget(self.depth_32)

        self.depth_32_argb = QRadioButton(self.ButtonGroup2)
        self.depth_32_argb.setObjectName(u"depth_32_argb")

        self.vboxLayout2.addWidget(self.depth_32_argb)

        self.hboxLayout.addWidget(self.ButtonGroup2)

        self.vboxLayout.addLayout(self.hboxLayout)

        self.hboxLayout2 = QHBoxLayout()
        self.hboxLayout2.setSpacing(6)
        self.hboxLayout2.setObjectName(u"hboxLayout2")
        self.hboxLayout2.setContentsMargins(0, 0, 0, 0)
        self.TextLabel1_3 = QLabel(Config)
        self.TextLabel1_3.setObjectName(u"TextLabel1_3")

        self.hboxLayout2.addWidget(self.TextLabel1_3)

        self.skin = QComboBox(Config)
        self.skin.addItem("")
        self.skin.setObjectName(u"skin")
        sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        sizePolicy2.setHorizontalStretch(0)
        sizePolicy2.setVerticalStretch(0)
        sizePolicy2.setHeightForWidth(
            self.skin.sizePolicy().hasHeightForWidth())
        self.skin.setSizePolicy(sizePolicy2)

        self.hboxLayout2.addWidget(self.skin)

        self.vboxLayout.addLayout(self.hboxLayout2)

        self.touchScreen = QCheckBox(Config)
        self.touchScreen.setObjectName(u"touchScreen")

        self.vboxLayout.addWidget(self.touchScreen)

        self.lcdScreen = QCheckBox(Config)
        self.lcdScreen.setObjectName(u"lcdScreen")

        self.vboxLayout.addWidget(self.lcdScreen)

        self.spacerItem = QSpacerItem(20, 10, QSizePolicy.Minimum,
                                      QSizePolicy.Expanding)

        self.vboxLayout.addItem(self.spacerItem)

        self.TextLabel1 = QLabel(Config)
        self.TextLabel1.setObjectName(u"TextLabel1")
        sizePolicy.setHeightForWidth(
            self.TextLabel1.sizePolicy().hasHeightForWidth())
        self.TextLabel1.setSizePolicy(sizePolicy)
        self.TextLabel1.setWordWrap(True)

        self.vboxLayout.addWidget(self.TextLabel1)

        self.GroupBox1 = QGroupBox(Config)
        self.GroupBox1.setObjectName(u"GroupBox1")
        self.gridLayout = QGridLayout(self.GroupBox1)
        self.gridLayout.setSpacing(6)
        self.gridLayout.setContentsMargins(11, 11, 11, 11)
        self.gridLayout.setObjectName(u"gridLayout")
        self.gridLayout.setHorizontalSpacing(6)
        self.gridLayout.setVerticalSpacing(6)
        self.gridLayout.setContentsMargins(11, 11, 11, 11)
        self.TextLabel3 = QLabel(self.GroupBox1)
        self.TextLabel3.setObjectName(u"TextLabel3")

        self.gridLayout.addWidget(self.TextLabel3, 6, 0, 1, 1)

        self.bslider = QSlider(self.GroupBox1)
        self.bslider.setObjectName(u"bslider")
        palette = QPalette()
        brush = QBrush(QColor(128, 128, 128, 255))
        brush.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush1 = QBrush(QColor(0, 0, 255, 255))
        brush1.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Button, brush1)
        brush2 = QBrush(QColor(127, 127, 255, 255))
        brush2.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Light, brush2)
        brush3 = QBrush(QColor(38, 38, 255, 255))
        brush3.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Midlight, brush3)
        brush4 = QBrush(QColor(0, 0, 127, 255))
        brush4.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Dark, brush4)
        brush5 = QBrush(QColor(0, 0, 170, 255))
        brush5.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Mid, brush5)
        brush6 = QBrush(QColor(0, 0, 0, 255))
        brush6.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Text, brush6)
        brush7 = QBrush(QColor(255, 255, 255, 255))
        brush7.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.BrightText, brush7)
        palette.setBrush(QPalette.Active, QPalette.ButtonText, brush)
        palette.setBrush(QPalette.Active, QPalette.Base, brush7)
        brush8 = QBrush(QColor(220, 220, 220, 255))
        brush8.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Window, brush8)
        palette.setBrush(QPalette.Active, QPalette.Shadow, brush6)
        brush9 = QBrush(QColor(10, 95, 137, 255))
        brush9.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.Highlight, brush9)
        palette.setBrush(QPalette.Active, QPalette.HighlightedText, brush7)
        palette.setBrush(QPalette.Active, QPalette.Link, brush6)
        palette.setBrush(QPalette.Active, QPalette.LinkVisited, brush6)
        brush10 = QBrush(QColor(232, 232, 232, 255))
        brush10.setStyle(Qt.SolidPattern)
        palette.setBrush(QPalette.Active, QPalette.AlternateBase, brush10)
        palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Button, brush1)
        palette.setBrush(QPalette.Inactive, QPalette.Light, brush2)
        palette.setBrush(QPalette.Inactive, QPalette.Midlight, brush3)
        palette.setBrush(QPalette.Inactive, QPalette.Dark, brush4)
        palette.setBrush(QPalette.Inactive, QPalette.Mid, brush5)
        palette.setBrush(QPalette.Inactive, QPalette.Text, brush6)
        palette.setBrush(QPalette.Inactive, QPalette.BrightText, brush7)
        palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
        palette.setBrush(QPalette.Inactive, QPalette.Base, brush7)
        palette.setBrush(QPalette.Inactive, QPalette.Window, brush8)
        palette.setBrush(QPalette.Inactive, QPalette.Shadow, brush6)
        palette.setBrush(QPalette.Inactive, QPalette.Highlight, brush9)
        palette.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7)
        palette.setBrush(QPalette.Inactive, QPalette.Link, brush6)
        palette.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6)
        palette.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10)
        palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        palette.setBrush(QPalette.Disabled, QPalette.Button, brush1)
        palette.setBrush(QPalette.Disabled, QPalette.Light, brush2)
        palette.setBrush(QPalette.Disabled, QPalette.Midlight, brush3)
        palette.setBrush(QPalette.Disabled, QPalette.Dark, brush4)
        palette.setBrush(QPalette.Disabled, QPalette.Mid, brush5)
        palette.setBrush(QPalette.Disabled, QPalette.Text, brush6)
        palette.setBrush(QPalette.Disabled, QPalette.BrightText, brush7)
        palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush)
        palette.setBrush(QPalette.Disabled, QPalette.Base, brush7)
        palette.setBrush(QPalette.Disabled, QPalette.Window, brush8)
        palette.setBrush(QPalette.Disabled, QPalette.Shadow, brush6)
        palette.setBrush(QPalette.Disabled, QPalette.Highlight, brush9)
        palette.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7)
        palette.setBrush(QPalette.Disabled, QPalette.Link, brush6)
        palette.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6)
        palette.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10)
        self.bslider.setPalette(palette)
        self.bslider.setMaximum(400)
        self.bslider.setValue(100)
        self.bslider.setOrientation(Qt.Horizontal)

        self.gridLayout.addWidget(self.bslider, 6, 1, 1, 1)

        self.blabel = QLabel(self.GroupBox1)
        self.blabel.setObjectName(u"blabel")

        self.gridLayout.addWidget(self.blabel, 6, 2, 1, 1)

        self.TextLabel2 = QLabel(self.GroupBox1)
        self.TextLabel2.setObjectName(u"TextLabel2")

        self.gridLayout.addWidget(self.TextLabel2, 4, 0, 1, 1)

        self.gslider = QSlider(self.GroupBox1)
        self.gslider.setObjectName(u"gslider")
        palette1 = QPalette()
        palette1.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush11 = QBrush(QColor(0, 255, 0, 255))
        brush11.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.Button, brush11)
        brush12 = QBrush(QColor(127, 255, 127, 255))
        brush12.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.Light, brush12)
        brush13 = QBrush(QColor(38, 255, 38, 255))
        brush13.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.Midlight, brush13)
        brush14 = QBrush(QColor(0, 127, 0, 255))
        brush14.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.Dark, brush14)
        brush15 = QBrush(QColor(0, 170, 0, 255))
        brush15.setStyle(Qt.SolidPattern)
        palette1.setBrush(QPalette.Active, QPalette.Mid, brush15)
        palette1.setBrush(QPalette.Active, QPalette.Text, brush6)
        palette1.setBrush(QPalette.Active, QPalette.BrightText, brush7)
        palette1.setBrush(QPalette.Active, QPalette.ButtonText, brush)
        palette1.setBrush(QPalette.Active, QPalette.Base, brush7)
        palette1.setBrush(QPalette.Active, QPalette.Window, brush8)
        palette1.setBrush(QPalette.Active, QPalette.Shadow, brush6)
        palette1.setBrush(QPalette.Active, QPalette.Highlight, brush9)
        palette1.setBrush(QPalette.Active, QPalette.HighlightedText, brush7)
        palette1.setBrush(QPalette.Active, QPalette.Link, brush6)
        palette1.setBrush(QPalette.Active, QPalette.LinkVisited, brush6)
        palette1.setBrush(QPalette.Active, QPalette.AlternateBase, brush10)
        palette1.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        palette1.setBrush(QPalette.Inactive, QPalette.Button, brush11)
        palette1.setBrush(QPalette.Inactive, QPalette.Light, brush12)
        palette1.setBrush(QPalette.Inactive, QPalette.Midlight, brush13)
        palette1.setBrush(QPalette.Inactive, QPalette.Dark, brush14)
        palette1.setBrush(QPalette.Inactive, QPalette.Mid, brush15)
        palette1.setBrush(QPalette.Inactive, QPalette.Text, brush6)
        palette1.setBrush(QPalette.Inactive, QPalette.BrightText, brush7)
        palette1.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
        palette1.setBrush(QPalette.Inactive, QPalette.Base, brush7)
        palette1.setBrush(QPalette.Inactive, QPalette.Window, brush8)
        palette1.setBrush(QPalette.Inactive, QPalette.Shadow, brush6)
        palette1.setBrush(QPalette.Inactive, QPalette.Highlight, brush9)
        palette1.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7)
        palette1.setBrush(QPalette.Inactive, QPalette.Link, brush6)
        palette1.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6)
        palette1.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10)
        palette1.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        palette1.setBrush(QPalette.Disabled, QPalette.Button, brush11)
        palette1.setBrush(QPalette.Disabled, QPalette.Light, brush12)
        palette1.setBrush(QPalette.Disabled, QPalette.Midlight, brush13)
        palette1.setBrush(QPalette.Disabled, QPalette.Dark, brush14)
        palette1.setBrush(QPalette.Disabled, QPalette.Mid, brush15)
        palette1.setBrush(QPalette.Disabled, QPalette.Text, brush6)
        palette1.setBrush(QPalette.Disabled, QPalette.BrightText, brush7)
        palette1.setBrush(QPalette.Disabled, QPalette.ButtonText, brush)
        palette1.setBrush(QPalette.Disabled, QPalette.Base, brush7)
        palette1.setBrush(QPalette.Disabled, QPalette.Window, brush8)
        palette1.setBrush(QPalette.Disabled, QPalette.Shadow, brush6)
        palette1.setBrush(QPalette.Disabled, QPalette.Highlight, brush9)
        palette1.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7)
        palette1.setBrush(QPalette.Disabled, QPalette.Link, brush6)
        palette1.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6)
        palette1.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10)
        self.gslider.setPalette(palette1)
        self.gslider.setMaximum(400)
        self.gslider.setValue(100)
        self.gslider.setOrientation(Qt.Horizontal)

        self.gridLayout.addWidget(self.gslider, 4, 1, 1, 1)

        self.glabel = QLabel(self.GroupBox1)
        self.glabel.setObjectName(u"glabel")

        self.gridLayout.addWidget(self.glabel, 4, 2, 1, 1)

        self.TextLabel7 = QLabel(self.GroupBox1)
        self.TextLabel7.setObjectName(u"TextLabel7")

        self.gridLayout.addWidget(self.TextLabel7, 0, 0, 1, 1)

        self.TextLabel8 = QLabel(self.GroupBox1)
        self.TextLabel8.setObjectName(u"TextLabel8")

        self.gridLayout.addWidget(self.TextLabel8, 0, 2, 1, 1)

        self.gammaslider = QSlider(self.GroupBox1)
        self.gammaslider.setObjectName(u"gammaslider")
        palette2 = QPalette()
        palette2.setBrush(QPalette.Active, QPalette.WindowText, brush)
        palette2.setBrush(QPalette.Active, QPalette.Button, brush7)
        palette2.setBrush(QPalette.Active, QPalette.Light, brush7)
        palette2.setBrush(QPalette.Active, QPalette.Midlight, brush7)
        brush16 = QBrush(QColor(127, 127, 127, 255))
        brush16.setStyle(Qt.SolidPattern)
        palette2.setBrush(QPalette.Active, QPalette.Dark, brush16)
        brush17 = QBrush(QColor(170, 170, 170, 255))
        brush17.setStyle(Qt.SolidPattern)
        palette2.setBrush(QPalette.Active, QPalette.Mid, brush17)
        palette2.setBrush(QPalette.Active, QPalette.Text, brush6)
        palette2.setBrush(QPalette.Active, QPalette.BrightText, brush7)
        palette2.setBrush(QPalette.Active, QPalette.ButtonText, brush)
        palette2.setBrush(QPalette.Active, QPalette.Base, brush7)
        palette2.setBrush(QPalette.Active, QPalette.Window, brush8)
        palette2.setBrush(QPalette.Active, QPalette.Shadow, brush6)
        palette2.setBrush(QPalette.Active, QPalette.Highlight, brush9)
        palette2.setBrush(QPalette.Active, QPalette.HighlightedText, brush7)
        palette2.setBrush(QPalette.Active, QPalette.Link, brush6)
        palette2.setBrush(QPalette.Active, QPalette.LinkVisited, brush6)
        palette2.setBrush(QPalette.Active, QPalette.AlternateBase, brush10)
        palette2.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        palette2.setBrush(QPalette.Inactive, QPalette.Button, brush7)
        palette2.setBrush(QPalette.Inactive, QPalette.Light, brush7)
        palette2.setBrush(QPalette.Inactive, QPalette.Midlight, brush7)
        palette2.setBrush(QPalette.Inactive, QPalette.Dark, brush16)
        palette2.setBrush(QPalette.Inactive, QPalette.Mid, brush17)
        palette2.setBrush(QPalette.Inactive, QPalette.Text, brush6)
        palette2.setBrush(QPalette.Inactive, QPalette.BrightText, brush7)
        palette2.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
        palette2.setBrush(QPalette.Inactive, QPalette.Base, brush7)
        palette2.setBrush(QPalette.Inactive, QPalette.Window, brush8)
        palette2.setBrush(QPalette.Inactive, QPalette.Shadow, brush6)
        palette2.setBrush(QPalette.Inactive, QPalette.Highlight, brush9)
        palette2.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7)
        palette2.setBrush(QPalette.Inactive, QPalette.Link, brush6)
        palette2.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6)
        palette2.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10)
        palette2.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        palette2.setBrush(QPalette.Disabled, QPalette.Button, brush7)
        palette2.setBrush(QPalette.Disabled, QPalette.Light, brush7)
        palette2.setBrush(QPalette.Disabled, QPalette.Midlight, brush7)
        palette2.setBrush(QPalette.Disabled, QPalette.Dark, brush16)
        palette2.setBrush(QPalette.Disabled, QPalette.Mid, brush17)
        palette2.setBrush(QPalette.Disabled, QPalette.Text, brush6)
        palette2.setBrush(QPalette.Disabled, QPalette.BrightText, brush7)
        palette2.setBrush(QPalette.Disabled, QPalette.ButtonText, brush)
        palette2.setBrush(QPalette.Disabled, QPalette.Base, brush7)
        palette2.setBrush(QPalette.Disabled, QPalette.Window, brush8)
        palette2.setBrush(QPalette.Disabled, QPalette.Shadow, brush6)
        palette2.setBrush(QPalette.Disabled, QPalette.Highlight, brush9)
        palette2.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7)
        palette2.setBrush(QPalette.Disabled, QPalette.Link, brush6)
        palette2.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6)
        palette2.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10)
        self.gammaslider.setPalette(palette2)
        self.gammaslider.setMaximum(400)
        self.gammaslider.setValue(100)
        self.gammaslider.setOrientation(Qt.Horizontal)

        self.gridLayout.addWidget(self.gammaslider, 0, 1, 1, 1)

        self.TextLabel1_2 = QLabel(self.GroupBox1)
        self.TextLabel1_2.setObjectName(u"TextLabel1_2")

        self.gridLayout.addWidget(self.TextLabel1_2, 2, 0, 1, 1)

        self.rlabel = QLabel(self.GroupBox1)
        self.rlabel.setObjectName(u"rlabel")

        self.gridLayout.addWidget(self.rlabel, 2, 2, 1, 1)

        self.rslider = QSlider(self.GroupBox1)
        self.rslider.setObjectName(u"rslider")
        palette3 = QPalette()
        palette3.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush18 = QBrush(QColor(255, 0, 0, 255))
        brush18.setStyle(Qt.SolidPattern)
        palette3.setBrush(QPalette.Active, QPalette.Button, brush18)
        brush19 = QBrush(QColor(255, 127, 127, 255))
        brush19.setStyle(Qt.SolidPattern)
        palette3.setBrush(QPalette.Active, QPalette.Light, brush19)
        brush20 = QBrush(QColor(255, 38, 38, 255))
        brush20.setStyle(Qt.SolidPattern)
        palette3.setBrush(QPalette.Active, QPalette.Midlight, brush20)
        brush21 = QBrush(QColor(127, 0, 0, 255))
        brush21.setStyle(Qt.SolidPattern)
        palette3.setBrush(QPalette.Active, QPalette.Dark, brush21)
        brush22 = QBrush(QColor(170, 0, 0, 255))
        brush22.setStyle(Qt.SolidPattern)
        palette3.setBrush(QPalette.Active, QPalette.Mid, brush22)
        palette3.setBrush(QPalette.Active, QPalette.Text, brush6)
        palette3.setBrush(QPalette.Active, QPalette.BrightText, brush7)
        palette3.setBrush(QPalette.Active, QPalette.ButtonText, brush)
        palette3.setBrush(QPalette.Active, QPalette.Base, brush7)
        palette3.setBrush(QPalette.Active, QPalette.Window, brush8)
        palette3.setBrush(QPalette.Active, QPalette.Shadow, brush6)
        palette3.setBrush(QPalette.Active, QPalette.Highlight, brush9)
        palette3.setBrush(QPalette.Active, QPalette.HighlightedText, brush7)
        palette3.setBrush(QPalette.Active, QPalette.Link, brush6)
        palette3.setBrush(QPalette.Active, QPalette.LinkVisited, brush6)
        palette3.setBrush(QPalette.Active, QPalette.AlternateBase, brush10)
        palette3.setBrush(QPalette.Inactive, QPalette.WindowText, brush)
        palette3.setBrush(QPalette.Inactive, QPalette.Button, brush18)
        palette3.setBrush(QPalette.Inactive, QPalette.Light, brush19)
        palette3.setBrush(QPalette.Inactive, QPalette.Midlight, brush20)
        palette3.setBrush(QPalette.Inactive, QPalette.Dark, brush21)
        palette3.setBrush(QPalette.Inactive, QPalette.Mid, brush22)
        palette3.setBrush(QPalette.Inactive, QPalette.Text, brush6)
        palette3.setBrush(QPalette.Inactive, QPalette.BrightText, brush7)
        palette3.setBrush(QPalette.Inactive, QPalette.ButtonText, brush)
        palette3.setBrush(QPalette.Inactive, QPalette.Base, brush7)
        palette3.setBrush(QPalette.Inactive, QPalette.Window, brush8)
        palette3.setBrush(QPalette.Inactive, QPalette.Shadow, brush6)
        palette3.setBrush(QPalette.Inactive, QPalette.Highlight, brush9)
        palette3.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7)
        palette3.setBrush(QPalette.Inactive, QPalette.Link, brush6)
        palette3.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6)
        palette3.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10)
        palette3.setBrush(QPalette.Disabled, QPalette.WindowText, brush)
        palette3.setBrush(QPalette.Disabled, QPalette.Button, brush18)
        palette3.setBrush(QPalette.Disabled, QPalette.Light, brush19)
        palette3.setBrush(QPalette.Disabled, QPalette.Midlight, brush20)
        palette3.setBrush(QPalette.Disabled, QPalette.Dark, brush21)
        palette3.setBrush(QPalette.Disabled, QPalette.Mid, brush22)
        palette3.setBrush(QPalette.Disabled, QPalette.Text, brush6)
        palette3.setBrush(QPalette.Disabled, QPalette.BrightText, brush7)
        palette3.setBrush(QPalette.Disabled, QPalette.ButtonText, brush)
        palette3.setBrush(QPalette.Disabled, QPalette.Base, brush7)
        palette3.setBrush(QPalette.Disabled, QPalette.Window, brush8)
        palette3.setBrush(QPalette.Disabled, QPalette.Shadow, brush6)
        palette3.setBrush(QPalette.Disabled, QPalette.Highlight, brush9)
        palette3.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7)
        palette3.setBrush(QPalette.Disabled, QPalette.Link, brush6)
        palette3.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6)
        palette3.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10)
        self.rslider.setPalette(palette3)
        self.rslider.setMaximum(400)
        self.rslider.setValue(100)
        self.rslider.setOrientation(Qt.Horizontal)

        self.gridLayout.addWidget(self.rslider, 2, 1, 1, 1)

        self.PushButton3 = QPushButton(self.GroupBox1)
        self.PushButton3.setObjectName(u"PushButton3")

        self.gridLayout.addWidget(self.PushButton3, 8, 0, 1, 3)

        self.MyCustomWidget1 = GammaView(self.GroupBox1)
        self.MyCustomWidget1.setObjectName(u"MyCustomWidget1")

        self.gridLayout.addWidget(self.MyCustomWidget1, 0, 3, 9, 1)

        self.vboxLayout.addWidget(self.GroupBox1)

        self.hboxLayout3 = QHBoxLayout()
        self.hboxLayout3.setSpacing(6)
        self.hboxLayout3.setObjectName(u"hboxLayout3")
        self.hboxLayout3.setContentsMargins(0, 0, 0, 0)
        self.spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                       QSizePolicy.Minimum)

        self.hboxLayout3.addItem(self.spacerItem1)

        self.buttonOk = QPushButton(Config)
        self.buttonOk.setObjectName(u"buttonOk")
        self.buttonOk.setAutoDefault(True)

        self.hboxLayout3.addWidget(self.buttonOk)

        self.buttonCancel = QPushButton(Config)
        self.buttonCancel.setObjectName(u"buttonCancel")
        self.buttonCancel.setAutoDefault(True)

        self.hboxLayout3.addWidget(self.buttonCancel)

        self.vboxLayout.addLayout(self.hboxLayout3)

        self.retranslateUi(Config)
        self.size_width.valueChanged.connect(self.size_custom.click)
        self.size_height.valueChanged.connect(self.size_custom.click)

        self.buttonOk.setDefault(True)

        QMetaObject.connectSlotsByName(Config)
 def initForm(self) -> None:
     self.progressbutton2.bgColor = QColor(40, 45, 48)
     self.progressbutton3.bgColor = QColor(214, 77, 84)
     self.progressbutton4.bgColor = QColor(162, 121, 197)
     self.progressbutton5.bgColor = QColor(0, 150, 121)
     self.progressbutton6.bgColor = QColor(71, 164, 233)
Exemple #19
0
 def __init__(self, parent=None):
     QQuickPaintedItem.__init__(self, parent)
     self._color = QColor()
Exemple #20
0
class AztecDiamondRenderer(QOpenGLWidget):
    HOLE_BORDER = QColor(210, 210, 210)
    DOMINO_BORDER = QColor(30, 30, 30)
    ARROWS = QColor(120, 120, 100)

    square_colors = {
        (board.BLACK, board.NO_COLOR): QColor(0x101010),
        (board.WHITE, board.NO_COLOR): QColor(0x101010)
    }
    for color, value in {
        board.GRAY: (120, 120, 120),
        board.RED: (190, 90, 90),
        board.YELLOW: (190, 190, 90),
        board.GREEN: (90, 190, 90),
        board.BLUE: (90, 90, 190),
    }.items():
        square_colors[board.BLACK, color] = QColor(*map(lambda n: max(0, n - 10), value))
        square_colors[board.WHITE, color] = QColor(*map(lambda n: min(255, n + 10), value))

    boardChanged = Signal(QSize)
    skipaheadProgress = Signal(int)
    skipaheadComplete = Signal()

    class _SkipAheadWorker(QObject):
        progressed = Signal(int)
        completed = Signal(board.Board)

        def __init__(self, board, n, parent=None):
            super().__init__(parent=parent)
            self.board = board
            self.n = n

        @Slot()
        def run(self):
            for i in range(self.n):
                self.board.advance_magic()
                self.board.fill_holes(self.board.get_holes())
                self.progressed.emit(i)
            self.completed.emit(self.board)

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self._worker = None
        self._worker_thread = None
        self.board = board.Board(2)
        self.holes = []
        self.base_square_size = 500
        self.hole_borders_enabled = True
        self.domino_borders_enabled = False
        self.domino_arrows_enabled = True
        self.checkerboard_enabled = True
        self.setMinimumSize(self.base_square_size, self.base_square_size)
        policy = self.sizePolicy()
        policy.setHeightForWidth(True)
        self.setSizePolicy(policy)
        self.boardChanged.connect(self.recalculate_holes)
        self.boardChanged.emit(self.minimumSize())

    def recalculate_holes(self):
        self.holes = self.board.get_holes()

    def advance_magic(self, repaint=True):
        self.board.advance_magic()
        self.boardChanged.emit(self.minimumSize())
        if repaint:
            self.repaint()

    def skip_ahead(self, n):
        self._worker_thread = QThread(self)
        self._worker = self._SkipAheadWorker(deepcopy(self.board), n - 1)
        self._worker_thread.started.connect(self._worker.run)
        self._worker.progressed.connect(self.skipaheadProgress.emit)
        self._worker.completed.connect(self._on_worker_complete)
        self._worker.moveToThread(self._worker_thread)
        self._worker_thread.start(QThread.LowPriority)

    @Slot(board.Board)
    def _on_worker_complete(self, board):
        self.board = board
        self._worker = None
        self._worker_thread.quit()
        self.advance_magic(repaint=False)
        self.recalculate_holes()
        self.fill_holes()
        self.skipaheadComplete.emit()
        self.repaint()

    def fill_holes(self):
        self.board.fill_holes(self.holes)
        self.repaint()

    def paintEvent(self, event):
        if not self.board:
            return
        self.base_square_size = min(self.size().width(), self.size().height())
        painter = QPainter(self)
        painter.setPen(Qt.NoPen)
        painter.setBrush(self.palette().color(self.backgroundRole()))
        painter.drawRect(self.rect())
        board_radius = len(self.board.data) // 2
        square_size = self.base_square_size / board_radius / 2
        offset_x = self.size().width() // 2
        offset_y = self.size().height() // 2
        for y in range(-board_radius, board_radius):
            for x in range(-board_radius, board_radius):
                if (color := self.board.get_square_color(x, y)) != board.NO_COLOR:
                    painter.setBrush(QBrush(self.square_colors[
                        self.board.get_square_parity(x, y) if self.checkerboard_enabled else board.BLACK, color
                    ]))
                    painter.drawRect(QRectF(
                        x * square_size + offset_x, y * square_size + offset_y,
                        square_size + 0.5, square_size + 0.5
                    ))
        if self.domino_borders_enabled:
            painter.setPen(QPen(QBrush(self.DOMINO_BORDER), max(1, square_size / 20)))
            painter.setBrush(Qt.NoBrush)
            for y in range(-board_radius, board_radius):
                for x in range(-board_radius, board_radius):
                    if self.board.get_square_parity(x, y) == board.BLACK and (other := self.board.get_square_neighbor(x, y)):
                        painter.drawRect(QRectF(
                            min(x, other[0]) * square_size + offset_x, min(y, other[1]) * square_size + offset_y,
                            max(other[0] - x + 1, x - other[0] + 1) * square_size,
                            max(other[1] - y + 1, y - other[1] + 1) * square_size
                        ))
class TraceStatistics:

    BBL_FILL_COLOR = QColor(0, 0xf0, 0xf0, 0xf)
    BBL_BORDER_COLOR = QColor(0, 0xf0, 0xf0)
    BBL_EMPTY_COLOR = QColor("white")

    def __init__(self, workspace, trace, baddr):
        self.workspace = workspace
        self.trace: Dict[str, Any] = trace
        self.bbl_addrs = trace["bb_addrs"]
        self.syscalls = trace["syscalls"]
        self.id = trace["id"]
        self.created_at = trace["created_at"]
        self.input_id = trace["input_id"]
        self.complete = trace["complete"]
        self.mapping: Optional[List[ObjectAndBase]] = None
        if 'map' in trace:
            map_dict: Dict[str, int] = trace["map"]
            self.mapping = [
                ObjectAndBase(name, base_addr)
                for name, base_addr in map_dict.items()
            ]
            self.mapping = list(sorted(
                self.mapping,
                key=lambda o: o.base_addr))  # sort it based on base addresses
        self.trace_func: List[TraceFunc] = []
        self.func_addr_in_trace: Set[int] = set()
        self._func_color = {}
        self.count = None
        self._mark_color = {}
        self._positions = defaultdict(list)
        self.mapped_trace = []

        self.project = self.workspace.instance.project
        if self.project.am_none:
            self.project_baddr = None
        else:
            # only used if self.mapping is not available
            self.project_baddr = self.project.loader.main_object.mapped_base
        self.runtime_baddr = baddr  # this will not be used if self.mapping is available

        self._cached_object_project_base_addrs: Dict[str, int] = {}

        self._statistics(self.bbl_addrs)

    def find_object_base_in_project(self, object_name: str) -> Optional[int]:
        """
        Find the base address of an object in angr project. Returns None if the project is not mapped. Results are
        cached in self._cached_object_project_base_addrs.

        :param object_name: Name of the object to look for.
        :return:            The base address of the loaded object in angr Project.
        """

        try:
            return self._cached_object_project_base_addrs[object_name]
        except KeyError:
            pass

        base_addr = None
        base_obj_name = os.path.basename(object_name)
        for obj in self.project.loader.all_objects:
            if not hasattr(obj, "binary"):
                continue
            if obj.binary and os.path.basename(obj.binary) == base_obj_name:
                # found it!
                # we assume binary names are unique. if they are not, someone should the logic here.
                base_addr = obj.mapped_base
                break

        if base_addr is None:
            l.warning(
                "Cannot find object %s in angr project. Maybe it has not been loaded. Exclude it from the "
                "trace.", object_name)
        self._cached_object_project_base_addrs[object_name] = base_addr
        return base_addr

    def get_func_color(self, func_name):
        if func_name in self._func_color:
            return self._func_color[func_name]
        else:
            color = self._random_color()
            self._func_color[func_name] = color
        return color

    def set_mark_color(self, p, color):
        self._mark_color[p] = color

    def get_mark_color(self, addr, i):
        try:
            mark_index = self._get_position(addr, i)
            mark_color = self._mark_color[mark_index]
        except (IndexError, KeyError) as e:
            l.error(e)
            return self.BBL_EMPTY_COLOR
        return mark_color

    def get_positions(self, addr):
        return self._positions[addr]

    def get_count(self, ins):
        return len(self._positions[ins])

    def get_bbl_from_position(self, position):
        return self.trace_func[position].bbl_addr

    def get_func_name_from_position(self, position):
        return self.trace_func[position].func_name

    def get_func_from_position(self, position):
        return self.trace_func[position].func

    def _apply_trace_offset(self, addr) -> Optional[int]:
        if self.mapping is not None and self.mapping:
            # find the base address that this address belongs to
            idx = bisect_left(self.mapping, addr)
            obj = None
            if 0 <= idx < len(self.mapping):
                # check if addr == object.base
                obj = self.mapping[idx]
                if addr == obj.base_addr:
                    # yes
                    pass
                elif idx > 0:
                    obj = self.mapping[idx - 1]
            else:  # idx == len(self.mapping)
                obj = self.mapping[idx - 1]

            if obj is not None:
                project_base_addr = self.find_object_base_in_project(
                    obj.obj_name)
                if project_base_addr is not None:
                    return addr + (project_base_addr - obj.base_addr)
                else:
                    # not found - the object is probably not loaded in angr? ignore it
                    return None

        # fall back
        if self.project_baddr is not None:
            offset = self.project_baddr - self.runtime_baddr
            return addr + offset
        else:
            # this object is probably created before an angr project is created. just give up.
            return None

    def _statistics(self, trace_addrs):
        """
        :param trace: basic block address list
        """
        self.mapped_trace = []
        for addr in trace_addrs:
            converted_addr = self._apply_trace_offset(addr)
            if converted_addr is not None:
                self.mapped_trace.append(converted_addr)

        bbls = filter(self._get_bbl, self.mapped_trace)
        functions = self.workspace.instance.project.kb.functions

        for p, bbl_addr in enumerate(bbls):
            node = self.workspace.instance.cfg.get_any_node(bbl_addr)
            # if node is None:  # try again without assuming node is start of a basic block
            #     node = self.workspace.instance.cfg.get_any_node(bbl_addr, anyaddr=True)

            func = None
            if node is not None:
                if node.instruction_addrs is not None:
                    instr_addrs = node.instruction_addrs
                else:
                    # relift
                    block = self.workspace.instance.project.factory.block(
                        bbl_addr)
                    instr_addrs = block.instruction_addrs
                for addr in instr_addrs:
                    self._positions[addr].append(p)

                func_addr = node.function_address
                if func_addr is not None and functions.contains_addr(
                        func_addr):
                    func = functions.get_by_addr(func_addr)
                    func_name = func.demangled_name
                else:
                    func_name = "Unknown"
                self.func_addr_in_trace.add(func_addr)
            else:
                # Node is not found in the CFG. It's possible that the library is not loaded
                func_name = hex(
                    bbl_addr
                )  # default to using bbl_addr as name if none is not found
                # l.warning("Node at %x is None, using bbl_addr as function name", bbl_addr)
            self.trace_func.append(TraceFunc(bbl_addr, func_name, func))

            if p % 5000 == 0:
                print("... trace loading progress: %.02f%%" %
                      (p * 100 / len(self.mapped_trace)))

        print("Trace is loaded.")
        self.count = len(self.trace_func)

    def _get_bbl(self, addr):
        try:
            return self.workspace.instance.project.factory.block(addr)
        except SimEngineError:
            return None

    def _func_addr(self, a):
        return self.workspace.instance.cfg.get_any_node(a).function_address

    def _func_name(self, a):
        return self.workspace.instance.project.kb.functions[self._func_addr(
            a)].demangled_name

    @staticmethod
    def _random_color():
        r = random.randint(0, 255)
        g = random.randint(0, 255)
        b = random.randint(0, 255)
        return QColor(r, g, b)

    def _get_position(self, addr, i):
        return self._positions[addr][i]
Exemple #22
0
import sys

from PySide2.QtWidgets import QApplication, QGridLayout, QTableView, QAbstractItemView, QLineEdit, QDialog
from PySide2.QtCore import QTranslator, QLibraryInfo, Qt, QSortFilterProxyModel
from PySide2.QtGui import QColor, QFont

from driver import AllTables
from tablemodel import TableModel
from personcard import QInvisibleButton

green = QColor(170, 170, 90)
blue = QColor(70, 180, 180)
red = QColor(180, 70, 180)

mainfont = QFont("Arial", 10)


class TreeCard(QDialog):
    def __init__(self, db=0, mode=0):
        super().__init__()

        layout = QGridLayout()
        #self.central_widget.setLayout(layout)
        self.resize(800, self.height())
        self.lb_find = QInvisibleButton('Поиск')
        self.lb_find.setFont(mainfont)
        self.te_find = QLineEdit()
        self.te_find.setFont(mainfont)
        self.pid = 0

        layout.addWidget(self.te_find, 0, 0, 1, 1)
 def testUndefinedKeyword(self):
     r, g, b, a = 1, 2, 3, 4
     # From the jira issue:
     with self.assertRaises(AttributeError) as cm:
         QColor(r, g, b, a, alpha=0)
     self.assertTrue("unsupported" in cm.exception.args[0])
Exemple #24
0
    def paint(self, painter, option, widget):  #pylint: disable=unused-argument
        if self.selected:
            painter.setPen(self._config.disasm_view_operand_select_color)
            painter.setBrush(self._config.disasm_view_operand_select_color)
            painter.drawRect(0, 0, self.width, self.height)
        else:
            for _, selected_operand_desc in self.infodock.selected_operands.items(
            ):
                if self._equals_for_highlighting_purposes(
                        selected_operand_desc):
                    painter.setBrush(
                        self._config.disasm_view_operand_highlight_color)
                    painter.setPen(
                        self._config.disasm_view_operand_highlight_color)
                    painter.drawRect(0, 0, self.width, self.height)
                    break

        if self._branch_target or self._branch_targets:
            if self._is_target_func:
                painter.setPen(self._config.disasm_view_target_addr_color)
            else:
                painter.setPen(self._config.disasm_view_antitarget_addr_color)
        else:
            if self.disasm_view.show_variable and self.variable is not None:
                # show-variable is enabled and this operand has a linked variable
                #fallback = True
                #if self.infodock.induction_variable_analysis is not None:
                #    r = self.infodock.induction_variable_analysis.variables.get(self.variable.ident, None)
                #    if r is not None and r.expr.__class__.__name__ == "InductionExpr":
                #        painter.setPen(Qt.darkYellow)
                #        fallback = False
                pass

            painter.setPen(QColor(0x00, 0x00, 0x80))

        painter.setRenderHints(QPainter.Antialiasing
                               | QPainter.SmoothPixmapTransform
                               | QPainter.HighQualityAntialiasing)
        painter.setFont(self._config.disasm_font)
        y = self._config.disasm_font_ascent

        # draw label
        # [rax]
        text = self._label
        x = self._label_width
        painter.drawText(0, y, text)

        # draw variable
        # {s_10}
        if self.disasm_view.show_variable and self._variable_label:
            x += self.LABEL_VARIABLE_SPACING * self.currentDevicePixelRatioF()
            painter.setPen(QColor(0x00, 0x80, 0x00))
            painter.drawText(x, y, self._variable_label)
            painter.setPen(QColor(0x00, 0x00, 0x80))
            x += self._variable_label_width

        # draw additional branch targets
        if self._branch_targets_text:
            painter.setPen(Qt.darkYellow)
            x += self.BRANCH_TARGETS_SPACING * self.currentDevicePixelRatioF()
            painter.drawText(x, y, self._branch_targets_text)
            x += self._branch_targets_text_width

        if self.variable is not None and self.disasm_view.show_variable_identifier:
            x += self.VARIABLE_IDENT_SPACING
            painter.setPen(Qt.darkGreen)
            painter.drawText(x, y, self._variable_ident)
            x += self._variable_ident_width

        # restores the color
        painter.setPen(QColor(0, 0, 0x80))
Exemple #25
0
    def on_view_tb_clicked(self):
        self.table.clear()
        # 设置表格列数
        self.table.setColumnCount(3)
        # 设置表格行数
        self.table.setRowCount(10)
        # 隐藏水平表头
        # self.tableWidget.horizontalHeader().setVisible(False)
        self.table.setHorizontalHeaderLabels(['时间', '温度', '湿度'])
        start_date,end_date = self.get_date()
        try:
            query = self.conn.show_data(self.sel_name,start_date,end_date)

            # j表示行数,i表示列数,d表示
            j = 0
            while query.next():
                # 当数据大于默认的行数时,在最后一行加入一个空行
                if j >= self.table.rowCount():
                    self.table.insertRow(j)
                for i in range(3):
                    if i == 0:
                        newitem = QTableWidgetItem(str(query.value(0).toString('yyyy/M/d h:mm:ss')))
                        self.table.setItem(j, i, newitem)
                    elif i == 1:
                        newitem = QTableWidgetItem(str(query.value(1)))
                        if query.value(1) >= self.one_high or query.value(1) <= self.one_low:
                            self.bgbruse = newitem.background()
                            newitem.setBackground(QColor(125, 32, 67))
                            self.table.setItem(j, i, newitem)  # 把数字转换成字符串
                        else:
                            self.table.setItem(j, i, newitem)
                    elif i == 2:
                        newitem = QTableWidgetItem(str(query.value(2)))
                        if query.value(2) >= self.two_high or query.value(2) <= self.two_low:
                            self.bgbruse = newitem.background()
                            newitem.setBackground(QColor(125, 32, 67))
                            self.table.setItem(j, i, newitem)  # 把数字转换成字符串
                        else:
                            self.table.setItem(j, i, newitem)

                j += 1
            self.items = {}
            # 获取总行数
            self.set_items(self.table.rowCount())
            d = []
            wendu = []
            shidu = []
            for c in range(self.table.rowCount()):
                # print(self.table.item(c,0).text())
                d.append(self.table.item(c,0).text())
                wendu.append(self.table.item(c,1).text())
                shidu.append(self.table.item(c,2).text())
            # self._static_ax.plot(d,wendu)
            # self._static_ax.plot(d,shidu)
            # plt.xticks(rotation=45)
            # plt.plot(d,[30]*len(wendu))
            # plt.plot(d,[10]*len(wendu))
            # plt.plot(d, wendu)
            # # plt.plot(d, shidu)
            # plt.show()


            for k,v in self.items.items():
                self.table.item(v[2] - 1, 0).setBackground(QColor(255, 0, 0))
                self.table.item(v[2], 0).setBackground(QColor(0, 255, 0))
            self.statusBar.showMessage(f"总共有 {len(self.items)} 处丢失数据")
        except BaseException as m:
            # print(m)
            # print(type(m))
            QMessageBox.information(self,
                                    "消息框标题",
                                    "请先选择一个需要查询的表",
                                    )
Exemple #26
0
    def paint_k_line(self, painter, event):
        batch_k_line_info = self.model.get_current_stock_k_info()
        # 显示K线区域宽度
        line_area_width = event.rect().width() - self.PRICE_AREA_WIDTH
        line_area_height = event.rect().height()
        real_each_width = self.each_line_width + self.KLINE_PADDING
        # 第一步:统计显示多少根K线
        show_num = line_area_width // real_each_width
        # 第二步:统计显示的开始index以及最后index
        self.calculate_start_last_index(batch_k_line_info, show_num)
        # 第三步:统计一下最大和最小价差
        max_price = 0
        min_price = 10000000
        for i in range(self.start_index, self.last_index + 1):
            if batch_k_line_info.info_list[i].high > max_price:
                max_price = batch_k_line_info.info_list[i].high
            if batch_k_line_info.info_list[i].low < min_price:
                min_price = batch_k_line_info.info_list[i].low
        min_max_delta = max_price - min_price

        # 第三点一步:绘制一下窗格系统,将窗格横向分割成10个小窗格
        pen = QPen()
        color = QColor()
        color.setRgb(212, 208, 208)
        pen.setColor(color)
        painter.setPen(pen)

        each_win_height = line_area_height / 10
        for i in range(1, 11):
            temp_line = QLine(0, each_win_height * i, line_area_width,
                              each_win_height * i)
            painter.drawLine(temp_line)

        # 第四步:开始绘制单根的K线
        x: int = 0
        y: int = 0
        height: int = 0
        for i in range(self.start_index, self.last_index + 1):
            x = real_each_width * (i - self.start_index)
            y = (max_price - batch_k_line_info.info_list[i].high
                 ) / min_max_delta * line_area_height
            height = (batch_k_line_info.info_list[i].high - batch_k_line_info.info_list[i].low) / min_max_delta * \
                     line_area_height
            self.paint_single_k_line(painter, x, y, self.each_line_width,
                                     height, batch_k_line_info.info_list[i])

        # 第五步:最右侧绘制一个显示栏,用于显示价格(分成四个等份)
        price_font = QFont()
        price_font.setPointSize(self.FONT_SIZE)
        painter.setFont(price_font)
        right_end_line = QLine(line_area_width, 0, line_area_width,
                               event.rect().height())
        painter.drawLine(right_end_line)

        each_price_level_height = event.rect().height() / 4
        for i in range(0, 4):
            cur_price = max_price - min_max_delta * (self.FONT_SIZE + each_price_level_height * i) / \
                        event.rect().height()
            painter.drawText(line_area_width + self.PRICE_MARGIN_LEFT,
                             self.FONT_SIZE + each_price_level_height * i,
                             str(cur_price))

        # 第六步:绘制一下当前鼠标所在K线的位置,加一个十字线,贯穿整个窗口
        k_line_num = self.curr_mouse_position.x() // real_each_width
        # 处理一下,避免垂直的线越过K线显示区,到了右边价格显示区
        if k_line_num > (self.last_index - self.start_index):
            point_x = line_area_width
        else:
            point_x = k_line_num * real_each_width + real_each_width / 2
        horizon_line = QLine(0, self.curr_mouse_position.y(), line_area_width,
                             self.curr_mouse_position.y())
        painter.drawLine(horizon_line)

        vertical_line = QLine(point_x, 0, point_x, event.rect().height())
        painter.drawLine(vertical_line)

        # 绘制一下当前的价格
        price_back_ground_height = self.FONT_SIZE + 4
        mouse_on_price = max_price - min_max_delta * self.curr_mouse_position.y(
        ) / event.rect().height()
        mouse_on_price_back = QRect(
            line_area_width,
            self.curr_mouse_position.y() - price_back_ground_height + 2,
            self.PRICE_AREA_WIDTH, price_back_ground_height)
        painter.drawRect(mouse_on_price_back)
        price_fill_back = QRect(
            line_area_width + 1,
            self.curr_mouse_position.y() - price_back_ground_height + 3,
            self.PRICE_AREA_WIDTH - 2, price_back_ground_height - 2)
        painter.fillRect(price_fill_back, QColor(184, 243, 144))
        painter.drawText(line_area_width + self.PRICE_MARGIN_LEFT,
                         self.curr_mouse_position.y(), str(mouse_on_price))
Exemple #27
0
    def paint(self, painter, option, widget=None):
        if Design.flow_theme == 'dark std':
            color = QColor(
                '#2E688C'
            ) if self.parent_port_instance.type_ == 'data' else QColor(
                '#3880ad')
            if option.state & QStyle.State_MouseOver:
                color = color.lighter()

            brush = QBrush(QColor(color))
            painter.setBrush(brush)
            painter.setPen(Qt.NoPen)

            painter.drawEllipse(
                QRectF(self.padding, self.padding, self.painting_width,
                       self.painting_height))

        elif Design.flow_theme == 'dark tron':
            color = ''
            if self.parent_port_instance.type_ == 'exec':
                color = '#FFFFFF'
            elif self.parent_port_instance.type_ == 'data':
                color = self.parent_node_instance.parent_node.color
            pen = QPen(color)
            pen.setWidth(2)
            painter.setPen(pen)
            if len(self.parent_port_instance.connected_port_instances) > 0 or \
                    option.state & QStyle.State_MouseOver:  # also fill when mouse hovers
                c = self.parent_node_instance.parent_node.color
                r = c.red()
                g = c.green()
                b = c.blue()
                brush = QBrush(QColor(r, g, b, 100))
                painter.setBrush(brush)
            else:
                painter.setBrush(Qt.NoBrush)

            painter.drawEllipse(
                QRectF(self.padding, self.padding, self.painting_width,
                       self.painting_height))

        elif Design.flow_theme == 'ghostly' or Design.flow_theme == 'blender':
            color = ''
            if self.parent_port_instance.type_ == 'exec':
                color = '#FFFFFF'

                if len(self.parent_port_instance.connected_port_instances) > 0 or \
                        option.state & QStyle.State_MouseOver:  # also fill when mouse hovers
                    brush = QBrush(QColor(255, 255, 255, 100))
                    painter.setBrush(brush)
                else:
                    painter.setBrush(Qt.NoBrush)
            elif self.parent_port_instance.type_ == 'data':
                color = self.parent_node_instance.parent_node.color

                if len(self.parent_port_instance.connected_port_instances) > 0 or \
                        option.state & QStyle.State_MouseOver:  # also fill when mouse hovers
                    c = self.parent_node_instance.parent_node.color
                    r = c.red()
                    g = c.green()
                    b = c.blue()
                    brush = QBrush(QColor(r, g, b, 100))
                    painter.setBrush(brush)
                else:
                    painter.setBrush(Qt.NoBrush)

            pen = QPen(color)
            pen.setWidth(1)
            painter.setPen(pen)

            rect = QRectF()
            rect.moveCenter(QPointF(self.width / 2, self.height / 2))
            rect.setWidth(self.painting_width)
            rect.setHeight(self.painting_height)
            painter.drawEllipse(QPointF(self.width / 2, self.height / 2),
                                self.painting_width / 3,
                                self.painting_height / 3)
Exemple #28
0
from PySide2.QtCore import QAbstractTableModel, QModelIndex, Qt, QUrl, Signal, Slot
from PySide2.QtGui import QColor, QDesktopServices
from PySide2.QtWidgets import QTableView, QTextBrowser

from mozregression.bisector import NightlyHandler

# Custom colors
GRAY_WHITE = QColor(243, 243, 243)
VERDICT_TO_ROW_COLORS = {
    "g": QColor(152, 251, 152),  # light green
    "b": QColor(250, 113, 113),  # light red
    "s": QColor(253, 248, 107),  # light yellow
    "r": QColor(225, 225, 225),  # light gray
}


class ReportItem(object):
    """
    A base item in the report view
    """
    def __init__(self):
        self.data = {}
        self.downloading = False
        self.waiting_evaluation = False
        self.progress = 0

    def update_pushlogurl(self, bisection):
        if bisection.handler.found_repo:
            self.data["pushlog_url"] = bisection.handler.get_pushlog_url()
        else:
            self.data["pushlog_url"] = "Not available"
Exemple #29
0
    def fade(self, start_color: tuple, end_color: tuple, duration:int):
        self.fade_anim.setStartValue(QColor(*start_color))
        self.fade_anim.setEndValue(QColor(*end_color))
        self.fade_anim.setDuration(duration)

        self.fade_anim.start(QAbstractAnimation.KeepWhenStopped)
Exemple #30
0
    QHBoxLayout,
    QLabel,
    QLayout,
    QMainWindow,
    QPushButton,
    QVBoxLayout,
    QWidget,
)

IMG_BOMB = QImage("./icons/bug.png")
IMG_FLAG = QImage("./icons/flag.png")
IMG_START = QImage("./icons/rocket.png")
IMG_CLOCK = QImage("./icons/clock-select.png")

NUM_COLORS = {
    1: QColor("#f44336"),
    2: QColor("#9C27B0"),
    3: QColor("#3F51B5"),
    4: QColor("#03A9F4"),
    5: QColor("#00BCD4"),
    6: QColor("#4CAF50"),
    7: QColor("#E91E63"),
    8: QColor("#FF9800"),
}

# tag::levels[]
LEVELS = [("Easy", 8, 10), ("Medium", 16, 40), ("Hard", 24, 99)]
# end::levels[]

STATUS_READY = 0
STATUS_PLAYING = 1