def Tableview_setFont(self, family="Microsoft YaHei", size=7, bold=False, weight=10):
     font = QFont()
     font.setFamily(family)
     font.setPointSize(size)
     font.setBold(bold)
     font.setWeight(weight)
     return font
Beispiel #2
0
    def __init__(self, text, callback=None):
        super(MessageDialog, self).__init__()
        self.setWindowTitle('Butter')
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setWindowFlags(Qt.FramelessWindowHint)

        layout = QVBoxLayout()
        self.setLayout(layout)

        label = QLabel()
        label.setStyleSheet("""QLabel {
            background-color: rgba(0, 0, 0, 200);
            color: rgb(255, 255, 255);
        }""")
        label.setText(text)
        label.setMargin(20)

        font = QFont()
        font.setPixelSize(32)
        font.setWeight(QFont.Bold)
        label.setFont(font)

        layout.addWidget(label)

        self.callback = callback
        self.exec_()
Beispiel #3
0
    def generateSMSitem(self, time_str, from_str, msg):
        hbox = QHBoxLayout()
        vbox = QVBoxLayout()

        date_label = QLabel()
        date_label.setText(time_str)
        hbox.addWidget(date_label)

        from_label = QLabel()
        from_label.setText(from_str)
        font = QFont()
        font.setBold(True)
        font.setWeight(75)
        from_label.setFont(font)
        hbox.addWidget(from_label)
        hbox.addStretch()

        msg_field = QLabel()
        msg_field.setStyleSheet("background: #fff;padding:5px;")
        msg_field.setText(msg)

        vbox.addLayout(hbox)
        vbox.addWidget(msg_field)
        vbox.addStretch()
        return vbox
Beispiel #4
0
	def fillTableWidget(self, data, tableWidget):
		tableWidget.setRowCount(data.shape[0])
		tableWidget.setColumnCount(data.shape[1])

		tmp = ["Date de dépistage", "Poste de dépistage", "Code du patient", "Sexe du patient",
				"Tranche d'age", "Conseiller pour le test", "Effectivement dépisté", 
				"CD ayant reçu son résultat", "Résultat du test", "Positif ayant reçu son résultat",
				"Positif bénéficiant d'un CD4"]
		header = list()
		for i,v in enumerate(tmp):
			item = QTableWidgetItem(v)
			item.setTextAlignment(Qt.AlignJustify|Qt.AlignVCenter)
			font = QFont()
			font.setPointSize(10)
			font.setBold(True)
			font.setWeight(75)
			item.setFont(font)
			header.append(item)
			tableWidget.setHorizontalHeaderItem(i, item)
	
		tableWidget.horizontalHeader().setVisible(True)

		for i in range(data.shape[0]):
			for j in range(data.shape[1]):
				tableWidget.setItem(i, j,QTableWidgetItem(str(data.iloc[i, j])) )
    def setupUi(self, Wait_Screen):
        if Wait_Screen.objectName():
            Wait_Screen.setObjectName(u"Wait_Screen")
        Wait_Screen.resize(641, 251)
        Wait_Screen.setStyleSheet(u"color: rgb(255, 255, 255);\n"
                                  "background-color: rgb(35, 35, 35);")
        self.Label = QLabel(Wait_Screen)
        self.Label.setObjectName(u"Label")
        self.Label.setGeometry(QRect(0, 0, 641, 251))
        font = QFont()
        font.setFamily(u"MS Reference Sans Serif")
        font.setPointSize(12)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.Label.setFont(font)
        self.Label.setStyleSheet(u"QLabel {\n"
                                 "	color: rgb(255, 255, 255);\n"
                                 "	background-color: rgb(35, 35, 35);\n"
                                 "	border: 2px solid;\n"
                                 "	border-color: rgb(255, 255, 255);\n"
                                 "	font: 12pt;\n"
                                 "    font-weight: bold;\n"
                                 "}")
        self.Label.setAlignment(Qt.AlignCenter)

        self.retranslateUi(Wait_Screen)

        QMetaObject.connectSlotsByName(Wait_Screen)
Beispiel #6
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.setWindowModality(QtCore.Qt.ApplicationModal)
        Dialog.resize(832, 364)
        self.gridLayout = qtw.QGridLayout(Dialog)
        self.gridLayout.setObjectName("gridLayout")
        self.label = qtw.QLabel(Dialog)
        self.label.setMaximumSize(QtCore.QSize(500, 300))
        self.label.setText("")
        self.label.setPixmap(QPixmap("init.png"))
        self.label.setScaledContents(True)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
        self.label_2 = qtw.QLabel(Dialog)
        self.label_2.setMaximumSize(QtCore.QSize(16777215, 320))
        font = QFont()
        font.setWeight(75)
        font.setBold(True)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 1, 1, 1, 1)
        self.buttonBox = qtw.QDialogButtonBox(Dialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(qtw.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1)

        self.retranslateUi(Dialog)
        # QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
        self.buttonBox.accepted.connect(Dialog.accept)
        # QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
        self.buttonBox.rejected.connect(Dialog.accept)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
def Splash(self):
    app.processEvents()
    splash = QtWidgets.QSplashScreen(QtGui.QPixmap(":ico/23.png"))

    font = QFont()
    font.setPixelSize(72)
    font.setWeight(QFont.Bold)
    font.setFixedPitch(True)
    splash.setFont(font)

    #splash.setFont(font)
    #splash.showMessage(str(count[0]), QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom, QtCore.Qt.white )
    splash.show()
    for i in range(0, 6):
        time.sleep(1.5)
        splash = QtWidgets.QSplashScreen(QtGui.QPixmap(":ico/23.png"))

        if i <= 4.0:
            splash.showMessage(str(count[i]), QtCore.Qt.AlignHCenter | QtCore.Qt.AlignHCenter | QtCore.Qt.AlignHCenter| QtCore.Qt.WindowStaysOnTopHint, QtCore.Qt.darkRed)
            font = splash.font()
            font.setPixelSize(640)
            font.setWeight(QFont.Bold)
            splash.setFont(font)
            splash.show()
        else:
            QtWidgets.QApplication.processEvents()
        splash.show()
Beispiel #8
0
    def draw_pieChart(self):  # Draw the pie chart
        chart = self.ui.chartViewPie.chart()

        chart.legend().setAlignment(Qt.AlignRight)  # AlignRight,AlignBottom
        chart.removeAllSeries()  # Delete all series

        seriesPie = QPieSeries()  # Pie chart series
        seriesPie.setHoleSize(self.ui.spinHoleSize.value())  # Hole size
        seriesPie.setPieSize(self.ui.spinPieSize.value())  # Pie size
        sec_count = 5  # Number of properties
        seriesPie.setLabelsVisible(True)  # Label

        pro, num = self.pie_data()
        for i in range(sec_count):
            seriesPie.append(pro[i], num[i])

        seriesPie.setLabelsVisible(True)  # Label

        # Pie hoverd when mouse selected
        seriesPie.hovered.connect(self.do_pieHovered)
        chart.addSeries(seriesPie)
        chart.setTitle("Proportion of data records for each property")
        font = QFont()
        font.setPointSize(12)
        font.setWeight(75)
        chart.setTitleFont(font)

        font = QFont()
        font.setPointSize(12)
        font.setBold(False)
        font.setWeight(35)
        legend = chart.legend()
        legend.setFont(font)
def Splash(self):
    app = QtWidgets.QApplication(sys.argv)
    QProcess.startDetached(app.processEvents())
    splash = QtWidgets.QSplashScreen(QtGui.QPixmap(":ico/23.png"))

    font = QFont()
    font.setPixelSize(72)
    font.setWeight(QFont.Bold)
    font.setFixedPitch(True)
    splash.setFont(font)

    #splash.setFont(font)
    #splash.showMessage(str(count[0]), QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom, QtCore.Qt.white )
    splash.show()
    for i in range(0, 6):
        time.sleep(1.5)
        splash = QtWidgets.QSplashScreen(QtGui.QPixmap(":ico/23.png"))

        if i <= 4.0:
            splash.showMessage(
                str(count[i]), QtCore.Qt.AlignHCenter | QtCore.Qt.AlignHCenter
                | QtCore.Qt.AlignHCenter | QtCore.Qt.WindowStaysOnTopHint,
                QtCore.Qt.darkRed)
            font = splash.font()
            font.setPixelSize(640)
            font.setWeight(QFont.Bold)
            splash.setFont(font)
            splash.show()
        else:
            QProcess.startDetached(app.processEvents())
        splash.show()
    while splash.finish:
        break
    print "ok"
    rec_main.Ui_MainWindow.show()
Beispiel #10
0
 def __init__(self, parent, line, graphicType, **kwrds):
     self.parent = parent
     self.line = line
     kwrds['color'] = self.set_color(color=kwrds['color'])
     if 'va' in kwrds:
         self.va = kwrds['va']
         del kwrds['va']
         if self.va == 'down':
             anchor, angle, tailLen, pos = [0.5, -2], 90, 30, (0, 5)
         elif self.va == 'up':
             anchor, angle, tailLen, pos = [0.5, 2], -90, 30, (0, -10)
         pg.TextItem.__init__(self,
                              text='',
                              anchor=anchor,
                              fill=pg.mkBrush(0, 0, 0, 0),
                              **kwrds)
     self.graphicType = graphicType
     self.reference = False
     self.highlight = False
     self.info = False
     self.setPointer()
     font = QFont("SansSerif", 10)
     font.setBold(True)
     font.setWeight(75)
     self.setFont(font)
     self.setActive()
Beispiel #11
0
    def doStep(self, painter):

        text = "ZetCode"

        brush = QBrush(QColor("#575555"))
        painter.setPen(QPen(brush, 1))

        f = QFont("Verdana", self.h)
        f.setWeight(QFont.DemiBold)
        fm = QFontMetrics(f)
        textWidth = fm.width(text)

        painter.setFont(f)

        if self.h > 10:
            self.opacity -= 0.01
            painter.setOpacity(self.opacity)

        if self.opacity <= 0:
            self.killTimer(self.timerId)

        h = self.height()
        w = self.width()

        painter.translate(QPoint(w / 2, h / 2))
        painter.drawText(-textWidth / 2, 0, text)
    def setupUi(self, window):

        vertical = QVBoxLayout(window)
        vertical.setContentsMargins(11, 10, 10, 5)

        contract_label = QLabel()
        contract_label.setAlignment(Qt.AlignCenter)
        font = QFont()
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        contract_label.setFont(font)
        contract_label.setText(self.cont_name)
        vertical.addWidget(contract_label)

        horizonal = QHBoxLayout(window)
        horizonal.setContentsMargins(0, 5, 0, 5)

        self.applyChange_buttion = QPushButton()
        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.applyChange_buttion.setSizePolicy(sizePolicy)
        self.applyChange_buttion.setObjectName("applyChange_buttion")
        self.applyChange_buttion.setText("Apply Change")
        horizonal.addWidget(self.applyChange_buttion)

        spacerItem = QSpacerItem(20, 40, QSizePolicy.MinimumExpanding,
                                 QSizePolicy.Minimum)
        horizonal.addItem(spacerItem)

        vertical.addLayout(horizonal)

        self.contractView = QTableView()
        self.contractView.setObjectName("contractView")
        vertical.addWidget(self.contractView)
Beispiel #13
0
    def __init__(self, context):
        """
        Code Editor
        :param context: shared properties in application
        """
        super().__init__()
        self.log = log.getLogger(self.__class__.__name__)

        self.context = context

        self.cursorLocation = None
        self.setUndoRedoEnabled(True)

        font = QFont()
        font.setPointSize(self.context.editor['font.pointSize'])
        font.setFamily(self.context.editor['font.family'])
        font.setWeight(self.context.editor['font.weight'])
        font.setStretch(self.context.editor['font.stretch'])
        self.setFont(font)

        self.lineNumberArea = LineNumberArea(self)

        self.blockCountChanged.connect(self.updateLineNumberAreaWidth)
        self.updateRequest.connect(self.updateLineNumberArea)
        self.cursorPositionChanged.connect(self.highlightCurrentLine)

        self.updateLineNumberAreaWidth(0)
Beispiel #14
0
    def init_ui(self):
        self.setMinimumWidth(900)
        self.setMinimumHeight(600)
        self.setAutoFillBackground(True)
        pal = self.palette()
        pal.setColor(self.backgroundRole(), Qt.white)
        self.setPalette(pal)

        layout = QVBoxLayout()
        self.setLayout(layout)

        font = QFont()
        font.setWeight(500)
        font.setPointSize(22)

        loginHeader = QLabel("REGISTER")
        loginHeader.setFont(font)
        loginHeader.setAlignment(Qt.AlignCenter)

        layout.addWidget(loginHeader)
        # create form group
        layout.addWidget(self.create_group())
        to_login = QPushButton("already have an account? > login")
        to_login.clicked.connect(lambda: self.__controller.to_login())
        layout.addWidget(to_login)
Beispiel #15
0
    def selectSlice(self, account):
        """
        Explodes a certaing slice that corresponds to
        an account
        """
        for slce in self.series.slices():
            if slce.label().split(' ')[0] == account:
                # Explode slice
                slce.setExploded(True)
                font = QFont()
                font.setBold(True)
                font.setWeight(QFont.ExtraBold)
                font.setUnderline(True)
                slce.setLabelFont(font)
                slce.setLabelColor(QColor("white"))
                slce.setLabelPosition(QPieSlice.LabelOutside)
            else:
                slce.setExploded(False)
                slce.setLabelFont(QFont())
                # # slce.setLabelPosition(QPieSlice.LabelInsideTangential)
                font = QFont()
                slce.setLabelColor(QColor("#3f3f39"))
                slce.setLabelFont(font)
                slce.setLabelPosition(QPieSlice.LabelInsideNormal)

        self.hideLittleSlices(selected=account)
Beispiel #16
0
def get_label_text(parent, geometry=QRect(0, 0, 800, 480), bold=False, text='',
                   font_px=20, font_family='MicrosoftYaHei', font_color='#000000'):
    """
    获取一个文字label实例
    :param parent:
    :param geometry: 位置大小
    :param bold: 加粗
    :param text: 文字
    :param font_px: 大小
    :param font_family:字体
    :param font_color: 颜色
    :return: Qlabel实例
    """
    label = QLabel(parent)
    label.setGeometry(geometry)
    label.setText(text)
    label.setAlignment(Qt.AlignCenter)

    style_sheet = 'QLabel{color: ' + font_color + '}'



    font = QFont()
    font.setFamily(font_family)
    font.setPixelSize(font_px)
    # font.setBold(bold)
    if bold:
        font.setWeight(70)
    label.setFont(font)

    label.setStyleSheet(style_sheet)

    return label
    def __init__(self, label='', line_name='na', required=False, parent=None):
        QWidget.__init__(self)
        self.layout = QHBoxLayout()
        self.qlbl = QLabel(label, self)
        self.added_line = QLineEdit()
        self.added_line.setObjectName(line_name)
        self.layout.addWidget(self.qlbl)
        self.layout.addWidget(self.added_line)

        if required:
            self.required_label = QLabel(self)
            font = QFont()
            font.setFamily("Arial")
            font.setPointSize(9)
            font.setBold(False)
            font.setItalic(False)
            font.setWeight(50)
            self.required_label.setFont(font)
            self.required_label.setScaledContents(True)
            self.required_label.setAlignment(QtCore.Qt.AlignHCenter
                                             | QtCore.Qt.AlignVCenter)
            self.required_label.setIndent(0)

            self.required_label.setText(
                QtCore.QCoreApplication.translate(
                    "USGSContactInfoWidget",
                    "<html><head/><body><p align=\"center\"><span style=\" font-size:18pt; color:#55aaff;\">*</span></p></body></html>"
                ))
            self.layout.addWidget(self.required_label)

        self.layout.setContentsMargins(1, 1, 1, 1)
        self.layout.setSpacing(6)
        self.setLayout(self.layout)
Beispiel #18
0
        def create_chart(self):
            self.chart.setTitle(
                'Grafiek aantal externe werken per status - opnameweek ' +
                jrwk)
            font = QFont("Sans Serif", 10)
            font.setWeight(QFont.Bold)
            self.chart.setTitleFont(font)
            set0 = QBarSet('Aantal externe werken per status')

            set0 << rpr[0][2] << rpr[1][2] << rpr[2][2] << rpr[3][2] << rpr[4][
                2] << rpr[5][2] << rpr[6][2] << rpr[7][2]

            barseries = QBarSeries()
            barseries.append(set0)
            barseries.append

            categories = [
                "Status A", "Status B", "Status C", "Status D", "Status E",
                "Status F", "Status G", "Status H"
            ]

            self.chart.addSeries(barseries)
            self.chart.axisX()
            self.chart.createDefaultAxes()
            axisX = QBarCategoryAxis()
            axisX.append(categories)
            self.chart.setAxisX(axisX, barseries)
            axisX.setRange(str("Status A"), str("Status H"))
Beispiel #19
0
 def data(self, index, role=Qt.DisplayRole):
     col = index.column()
     row = index.row()
     if role == Qt.DisplayRole:
         if col == 0:
             return self.fields[row]
         else:
             return self.values[row]
     elif role == Qt.BackgroundRole:
         if self.fields[row] in emails() and col > 0:
             e = emailLS(self.values[row]).email_is_what
             if not e:
                 return QColor(Qt.red)
         return QColor(Qt.white)
     elif role == Qt.ForegroundRole:
         if self.fields[row] in emails() and col > 0:
             e = emailLS(self.values[row]).email_is_what
             if not e:
                 return QColor(Qt.white)
         return QColor(Qt.black)
     elif role == Qt.TextAlignmentRole:
         return self.align[col]
     elif role == Qt.FontRole:
         if self.fields[row] in emails() and col > 0:
             e = emailLS(self.values[row]).email_is_what
             if not e:
                 font = QFont()
                 font.setWeight(QFont.Bold)
                 return font
     return None
 def _setupUi(self):
     self.setWindowTitle(tr("Schedule Modification Scope"))
     self.resize(333, 133)
     self.verticalLayout = QVBoxLayout(self)
     self.label = QLabel(tr("Do you want this change to affect all future occurrences of this schedule?"))
     font = QFont()
     font.setWeight(75)
     font.setBold(True)
     self.label.setFont(font)
     self.label.setWordWrap(True)
     self.verticalLayout.addWidget(self.label)
     self.label_2 = QLabel(tr(
         "You can force global scope (in other words, changing all future occurrences) by "
         "holding Shift when you perform the change."
     ))
     self.label_2.setWordWrap(True)
     self.verticalLayout.addWidget(self.label_2)
     self.horizontalLayout = QHBoxLayout()
     self.cancelButton = QPushButton(tr("Cancel"))
     self.cancelButton.setShortcut("Esc")
     self.horizontalLayout.addWidget(self.cancelButton)
     spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
     self.horizontalLayout.addItem(spacerItem)
     self.globalScopeButton = QPushButton(tr("All future occurrences"))
     self.globalScopeButton.setAutoDefault(False)
     self.horizontalLayout.addWidget(self.globalScopeButton)
     self.localScopeButton = QPushButton(tr("Just this one"))
     self.localScopeButton.setAutoDefault(False)
     self.localScopeButton.setDefault(True)
     self.horizontalLayout.addWidget(self.localScopeButton)
     self.verticalLayout.addLayout(self.horizontalLayout)
Beispiel #21
0
def update_font(basefont,
                weight=None,
                italic=None,
                underline=None,
                pixelSize=None,
                pointSize=None):
    """
    Return a copy of `basefont` :class:`QFont` with updated properties.
    """
    font = QFont(basefont)

    if weight is not None:
        font.setWeight(weight)

    if italic is not None:
        font.setItalic(italic)

    if underline is not None:
        font.setUnderline(underline)

    if pixelSize is not None:
        font.setPixelSize(pixelSize)

    if pointSize is not None:
        font.setPointSize(pointSize)

    return font
 def _setupUi(self):
     self.setWindowTitle(tr("Schedule Modification Scope"))
     self.resize(333, 133)
     self.verticalLayout = QVBoxLayout(self)
     self.label = QLabel(
         tr("Do you want this change to affect all future occurrences of this schedule?"
            ))
     font = QFont()
     font.setWeight(75)
     font.setBold(True)
     self.label.setFont(font)
     self.label.setWordWrap(True)
     self.verticalLayout.addWidget(self.label)
     self.label_2 = QLabel(
         tr("You can force global scope (in other words, changing all future occurrences) by "
            "holding Shift when you perform the change."))
     self.label_2.setWordWrap(True)
     self.verticalLayout.addWidget(self.label_2)
     self.horizontalLayout = QHBoxLayout()
     self.cancelButton = QPushButton(tr("Cancel"))
     self.cancelButton.setShortcut("Esc")
     self.horizontalLayout.addWidget(self.cancelButton)
     spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                              QSizePolicy.Minimum)
     self.horizontalLayout.addItem(spacerItem)
     self.globalScopeButton = QPushButton(tr("All future occurrences"))
     self.globalScopeButton.setAutoDefault(False)
     self.horizontalLayout.addWidget(self.globalScopeButton)
     self.localScopeButton = QPushButton(tr("Just this one"))
     self.localScopeButton.setAutoDefault(False)
     self.localScopeButton.setDefault(True)
     self.horizontalLayout.addWidget(self.localScopeButton)
     self.verticalLayout.addLayout(self.horizontalLayout)
Beispiel #23
0
 def setupUi(self, StartPage_Url):
     StartPage_Url.setObjectName("StartPage_Url")
     self.centralwidget = QWidget(StartPage_Url)
     self.centralwidget.setObjectName("centralwidget")
     self.btn_go = QPushButton(self.centralwidget)
     self.btn_go.setGeometry(QRect(250, 150, 88, 33))
     self.btn_go.setObjectName("btn_go")
     self.btn_go.clicked.connect(lambda: self.TypeFinder())
     self.L_Heading = QLabel(self.centralwidget)
     self.L_Heading.setGeometry(QRect(120, 20, 331, 20))
     font = QFont()
     font.setPointSize(14)
     font.setBold(True)
     font.setItalic(True)
     font.setWeight(75)
     self.L_Heading.setFont(font)
     self.L_Heading.setLayoutDirection(Qt.LeftToRight)
     self.L_Heading.setAutoFillBackground(True)
     self.L_Heading.setObjectName("L_Heading")
     self.groupBox = QGroupBox(self.centralwidget)
     self.groupBox.setGeometry(QRect(20, 200, 231, 111))
     self.groupBox.setObjectName("groupBox_for_typeSelection")
     self.label = QLabel(self.groupBox)
     self.label.setGeometry(QRect(40, 20, 111, 17))
     self.label.setObjectName("Title_label")
     self.label_2 = QLabel(self.groupBox)
     self.label_2.setGeometry(QRect(40, 40, 121, 17))
     self.label_2.setObjectName("label_info")
     self.label_5 = QLabel(self.groupBox)
     self.label_5.setGeometry(QRect(40, 60, 141, 20))
     self.label_5.setObjectName("label_5")
     self.label_3 = QLabel(self.groupBox)
     self.label_3.setGeometry(QRect(40, 80, 141, 20))
     self.label_3.setObjectName("label_3")
     self.label_4 = QLabel(self.centralwidget)
     self.label_4.setGeometry(QRect(200, 310, 451, 20))
     self.label_4.setObjectName("label_info")
     self.url_txtbox = QLineEdit(self.centralwidget)
     self.url_txtbox.setGeometry(QRect(72, 70, 431, 33))
     self.url_txtbox.setObjectName("url_txtbox")
     self.url_txtbox.returnPressed.connect(self.TypeFinder)
     StartPage_Url.setCentralWidget(self.centralwidget)
     self.menubar = QMenuBar(StartPage_Url)
     self.menubar.setGeometry(QRect(0, 0, 586, 25))
     self.menubar.setObjectName("menubar")
     self.menuAbout = QMenu(self.menubar)
     self.menuAbout.setObjectName("menuAbout")
     self.about_opt = QMenu(self.menubar)
     self.about_opt.setObjectName("about_opt")
     StartPage_Url.setMenuBar(self.menubar)
     self.statusbar = QStatusBar(StartPage_Url)
     self.statusbar.setObjectName("statusbar")
     StartPage_Url.setStatusBar(self.statusbar)
     self.pings = QAction(StartPage_Url)
     self.pings.setObjectName("pings")
     self.menuAbout.addAction(self.pings)
     self.pings.triggered.connect(lambda: self.ping())
     self.menubar.addAction(self.menuAbout.menuAction())
     self.retranslateUi(StartPage_Url)
     QMetaObject.connectSlotsByName(StartPage_Url)
Beispiel #24
0
class Button(QGraphicsObject):
    clicked = pyqtSignal()

    def __init__(self, text, parent=None):
        super(Button, self).__init__(parent)
        self.text = text
        self.color = QColor(255, 0, 128)
        self.font = QFont()
        self.font.setWeight(QFont.Bold)
        self.font.setPixelSize(BUTTON_HEIGHT / 2)

    def paint(self, painter, option, widget):
        painter.setBrush(Qt.yellow)
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT, 10, 10)
        painter.setPen(self.color)

        painter.setFont(self.font)
        text_width = painter.fontMetrics().width(self.text)
        text_height = painter.fontMetrics().height()
        painter.drawText(
            (BUTTON_WIDTH - text_width) / 2,
            (BUTTON_HEIGHT + text_height) / 2 - BUTTON_HEIGHT / 10, self.text)

    def boundingRect(self):
        return QRectF(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT)

    def mousePressEvent(self, event):
        self.color = Qt.black
        self.update()

    def mouseReleaseEvent(self, event):
        self.color = QColor(255, 0, 128)
        self.clicked.emit()
        self.update()
Beispiel #25
0
def Splash(self):
    app.processEvents()
    splash = QtWidgets.QSplashScreen(QtGui.QPixmap(":ico/23.png"))

    font = QFont()
    font.setPixelSize(72)
    font.setWeight(QFont.Bold)
    font.setFixedPitch(True)
    splash.setFont(font)

    #splash.setFont(font)
    #splash.showMessage(str(count[0]), QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom, QtCore.Qt.white )
    splash.show()
    for i in range(0, 6):
        time.sleep(1)
        splash = QtWidgets.QSplashScreen(QtGui.QPixmap(":ico/23.png"))

        if i <= 4.0:
            splash.showMessage(
                str(count[i]), QtCore.Qt.AlignHCenter | QtCore.Qt.AlignHCenter
                | QtCore.Qt.AlignHCenter | QtCore.Qt.WindowStaysOnTopHint,
                QtCore.Qt.darkRed)
            font = splash.font()
            font.setPixelSize(640)
            font.setWeight(QFont.Bold)
            splash.setFont(font)
            splash.show()
        else:
            QtWidgets.QApplication.processEvents()
        splash.show()
 def aggiungi_item(self, lista, nome):
     item = QListWidgetItem(nome)
     item.setTextAlignment(Qt.AlignCenter)
     font = QFont("Arial", 16)
     font.setWeight(50)
     item.setFont(font)
     lista.addItem(item)
Beispiel #27
0
    def paintEvent(self, event):
        # Check whether this orb is enhanced
        if type(self.parent) == Board:
            enh = self.parent.enhanced[self.position]
        else:
            enh = False

        painter = QPainter(self)
        painter.drawPixmap(event.rect().adjusted(2,2,-2,-2), self.pixmap())

        w = event.rect().width()

        if enh:
            path = QPainterPath()

            pen = QPen()
            pen.setWidth(1);
            pen.setBrush(Qt.white)

            brush = QBrush(Qt.yellow)

            font = QFont()
            font.setPointSize(20)
            font.setWeight(QFont.Black)
            
            path.addText(event.rect().x()+w-15,event.rect().y()+w-5,font,'+')

            painter.setPen(pen)
            painter.setBrush(brush)
            painter.setFont(font)

            painter.drawPath(path)
    def create_res(self):
        tmp = self.simi_base[:]
        for idx, k in enumerate(tmp):
            if k == '':
                tmp[idx] = u'.'
        tmp_sql = "SELECT * FROM `plate_nums` where occupied = 0  and plate_num regexp '{regexp}' limit 15".format(
            regexp=''.join(tmp))
        res = dbOper().query(tmp_sql)

        if not res:
            self.error_plate_format.setText(u"抱歉,查询无结果\n请尝试输入其他条件")
            self.error_plate_format.show()
        else:
            for idx, item in enumerate(res):
                button = QPushButton()
                self.res_box.addWidget(button, idx / 3, idx % 3)
                self.res_box.setAlignment(Qt.AlignHCenter)
                tmp_plate = u'沪' + item['prefix'] + '/ ' + item['plate_num']
                button.setText(tmp_plate)
                res_font = QFont()
                res_font.setPointSize(30)
                res_font.setBold(True)
                res_font.setItalic(False)
                res_font.setWeight(20)
                button.setFont(res_font)
                button.kv = item
                button.clicked.connect(self.after_select)
            self.begin_button.setDisabled(1)
Beispiel #29
0
 def on_actionCompanyProducts_triggered(self):
     d = QDialog(self)
     d.resize(
         self.mem.settings.value("wdgCompanies/frmCompanyProducts",
                                 QSize(800, 600)))
     title = self.tr("Products of {}").format(self.companies.selected.name)
     d.setWindowTitle(title)
     lay = QVBoxLayout(d)
     font = QFont()
     font.setPointSize(14)
     font.setBold(True)
     font.setWeight(75)
     lbl = QLabel(d)
     lbl.setText(title)
     lbl.setFont(font)
     lbl.setAlignment(Qt.AlignCenter)
     lay.addWidget(lbl)
     companyproducts = self.mem.data.products.ProductAllManager_of_same_company(
         self.companies.selected)
     table = myQTableWidget(d)
     table.setObjectName("tblCompanyProducts")
     table.settings(self.mem, "wdgCompanies")
     companyproducts.qtablewidget(table)
     lay.addWidget(table)
     d.exec_()
     self.mem.settings.setValue("wdgCompanies/frmCompanyProducts", d.size())
Beispiel #30
0
    def generate_labels_style(self):
        self.title_label = QLabel(self)
        self.title_label.setGeometry(190, 250, 241, 20)
        font = QFont()
        font.setPointSize(18)
        font.setBold(True)
        font.setWeight(75)

        self.title_label.setFont(font)
        self.title_label.setAlignment(Qt.AlignCenter)
        self.title_label.setObjectName("title_label")

        self.conditions_label = QLabel(self)
        self.conditions_label.setGeometry(90, 310, 181, 40)
        self.conditions_label.setObjectName("conditions_label")

        self.temperature_label = QLabel(self)
        self.temperature_label.setGeometry(90, 340, 181, 40)
        self.temperature_label.setObjectName("temperature_label")

        self.min_temp_label = QLabel(self)
        self.min_temp_label.setGeometry(90, 380, 190, 40)
        self.min_temp_label.setObjectName("min_temp_label")

        self.max_temp_label = QLabel(self)
        self.max_temp_label.setGeometry(90, 420, 190, 40)
        self.max_temp_label.setObjectName("max_temp_label")
Beispiel #31
0
    def create_license_tab(self):
        text = ('TPRL Calculator является свободным программным обеспечением: вы можете '
                'распространять и/или изменять его на условиях Стандартной общественной '
                'лицензии GNU в том виде, в каком она была опубликованной Фондом свободного '
                'программного обеспечения (FSF); либо Лицензии версии 3, либо (на Ваше '
                'усмотрение) любой более поздней версии.\n\n'
                'Эта программа распространяется в надежде, что она будет полезной, но БЕЗ КАКИХ '
                'БЫ ТО НИ БЫЛО ГАРАНТИЙНЫХ ОБЯЗАТЕЛЬСТВ; даже без косвенных гарантийных '
                'обязательств, связанных с ПОТРЕБИТЕЛЬСКИМИ СВОЙСТВАМИ и ПРИГОДНОСТЬЮ ДЛЯ '
                'ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Для подробностей смотрите Стандартную Общественную '
                'Лицензию GNU.\n\n'
                'Вы должны были получить копию Стандартной Общественной Лицензии GNU вместе с '
                'этой программой.\nЕсли это не так, см. <https://www.gnu.org/licenses/>.')
        license_font = QFont()
        license_font.setPointSize(10)
        license_font.setBold(False)
        license_font.setWeight(25)
        self.license_text = QLabel(text, self.license_tab)
        self.license_text.setOpenExternalLinks(True)
        self.license_text.setFont(license_font)
        self.license_text.setGeometry(QRect(5, 0, 460, 240))
        self.license_text.setContentsMargins(0, 0, 0, 0)
        self.license_text.setWordWrap(True)
        self.license_text.setObjectName("label_about_title")

        self.btn_license = QPushButton(self.license_tab)
        self.btn_license.setGeometry(160, 260, 150, 20)
        self.btn_license.setObjectName("btn_license")
        self.btn_license.setText("Лицензия GPL")
        self.btn_license.clicked.connect(self.open_license)
Beispiel #32
0
 def show_tablewidget(self, dict_data):
     '''在tableWidget显示dict_data'''
     tableWidget = self.tableWidget
     '''排序'''
     df = DataFrame(dict_data).sort_values(by='count',ascending = False)
     _temp = df.to_dict('index')
     dict_data = list(_temp.values())
     self.data = dict_data
     '''tableWidget的初始化'''
     list_col = ['key','count','ps','pron','pos','acceptation','sen']
     len_col = len(list_col)
     len_index = len(dict_data)
     tableWidget.setRowCount(len_index)#设置行数
     tableWidget.setColumnCount(len_col)#设置列数
     tableWidget.setHorizontalHeaderLabels(['单词', '词频', '音标','发音','词性','释义','例句']) # 设置垂直方向上的名字
     tableWidget.setVerticalHeaderLabels([str(i) for i in range(1, len_index + 1)]) # 设置水平方向上的名字
     '''填充数据'''
     for index in  range(len_index):
         for col in range(len_col):
             name_col = list_col[col]
             if name_col == 'pron':
                 item = QTableWidgetItem('播放')
                 item.setTextAlignment(Qt.AlignCenter)
                 font = QFont()
                 font.setBold(True)
                 font.setWeight(75)
                 item.setFont(font)
                 item.setBackground(QColor(218, 218, 218))
                 item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                 tableWidget.setItem(index, col, item)
             else:
                 tableWidget.setItem(index,col,QTableWidgetItem(str(dict_data[index][name_col])))
     tableWidget.resizeColumnsToContents()
     tableWidget.setColumnWidth(5, 500)
Beispiel #33
0
	def __init__(self, parent = None, message = None, itemType = "log"):
		QListWidgetItem.__init__(self)
		self.itemType = itemType

		if (itemType == "log"):
			self.setText("--- " + str(message))
		elif (itemType == "in"):
			self.setText("<<< " + str(message))
		elif (itemType == "out"):
			self.setText(">>> " + str(message))
		else:
			self.setText(str(message))

		font = QFont()
		font.setFamily("Monospace")
		if (itemType == "in") or (itemType == "out"):
			font.setBold(True)
			font.setWeight(75)
		else:
			font.setBold(False)
			font.setWeight(50)
		self.setFont(font)

		brush = QBrush(QColor(0, 0, 0))
		if (itemType == "in"):
			brush = QBrush(QColor(0, 0, 85))
		elif (itemType == "out"):
			brush = QBrush(QColor(0, 85, 0))
		brush.setStyle(Qt.NoBrush)
		self.setForeground(brush)
Beispiel #34
0
    def setupUi(self, window):      
        
        vertical = QVBoxLayout(window)
        vertical.setContentsMargins(11, 10, 10, 5)
        
        horizonal = QHBoxLayout(window)
        horizonal.setContentsMargins(25, 10, 10, 5)
        
        oldlabel = QLabel()
        newlabel = QLabel()
        oldlabel.setAlignment(Qt.AlignCenter)
        newlabel.setAlignment(Qt.AlignCenter)
        font = QFont()
        font.setPointSize(13)
        font.setBold(True)
        font.setWeight(75)
        oldlabel.setFont(font)
        newlabel.setFont(font)
        oldlabel.setText(self.oldName)
        newlabel.setText(self.newName)
        horizonal.addWidget(oldlabel)
        horizonal.addWidget(newlabel)
        
        vertical.addLayout(horizonal)     

        self.editView = QTableView()
        self.editView.setObjectName("editView")
        vertical.addWidget(self.editView)
        


        
Beispiel #35
0
 def __init__(self):
     super(PayrecWidget, self).__init__()
     self.ui = Ui_PayrecWidget()
     self.ui.setupUi(self)
     font = QFont()
     font.setFamily("Comic Sans MS")
     font.setPointSize(10)
     font.setBold(True)
     font.setWeight(75)
     self.ui.rec_label.setFont(font)
     self.ui.gsf_label.setFont(font)
Beispiel #36
0
 def __set_text_after_save_file(self, data, path):
     """
     Specifies the text after the file has been sent
     """
     tab = self.set_data_to_correct_tab(data['type'])
     font = QFont()
     font.setWeight(QFont.Bold)
     item = QListWidgetItem(tab.children()[0])
     item.setFont(font)
     message = "the file was saved on the following path: %s" % path
     item.setText("%s: %s" % (self.members[data['username']].username,
                              message))
Beispiel #37
0
 def setItemTextFormat(item, f):
     font = QFont(data.font)
     if f.hasProperty(QTextFormat.ForegroundBrush):
         item.setForeground(0, f.foreground().color())
     else:
         item.setForeground(0, data.baseColors['text'])
     if f.hasProperty(QTextFormat.BackgroundBrush):
         item.setBackground(0, f.background().color())
     else:
         item.setBackground(0, QBrush())
     font.setWeight(f.fontWeight())
     font.setItalic(f.fontItalic())
     font.setUnderline(f.fontUnderline())
     item.setFont(0, font)
Beispiel #38
0
    def __init__(self, parent=None):
        super(PageVolumeSize, self).__init__(parent)
        self.setObjectName("PageVolumeSize")
        self.setTitle(self.tr("Volume Size"))

        self.measure = {"KB": 1024, "MB": 1024*1024, "GB": 1024*1024*1024}

        horizontalLayout = QtWidgets.QHBoxLayout()
        horizontalLayout.setObjectName("horizontalLayout")
        self.sizelineEdit = QtWidgets.QLineEdit()
        self.sizelineEdit.setObjectName("sizelineEdit")
        self.sizelineEdit.setText('10')
        self.sizelineEdit.setInputMask("0000000")
        #self.sizelineEdit.setMaxLength(5)
        horizontalLayout.addWidget(self.sizelineEdit)

        self.comboBox = QtWidgets.QComboBox()
        self.comboBox.setObjectName("comboBox")
        [self.comboBox.addItem(i) for i in self.measure.keys()]

        horizontalLayout.addWidget(self.comboBox)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        horizontalLayout.addItem(spacerItem)

        label = QtWidgets.QLabel()
        font = QFont()
        font.setBold(True)
        font.setWeight(75)
        label.setFont(font)
        label.setObjectName("label")
        floc="/home"
        label.setText(self.tr("Free space available: %s" % getfreespace(floc)))
        #label.setText("Free space available: 81,3 GB")

        label1 = QtWidgets.QLabel()
        label1.setWordWrap(True)
        label1.setObjectName("label1")
        label1.setText(self.tr("Please specify the size of the container to create. Note that the minimum possible size of a volume is 292KB."))

        spacerItem1 = QtWidgets.QSpacerItem(20, 267, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)

        verticalLayout = QtWidgets.QVBoxLayout(self)
        verticalLayout.setObjectName("verticalLayout")
        verticalLayout.addLayout(horizontalLayout)
        verticalLayout.addWidget(label)
        verticalLayout.addWidget(label1)
        verticalLayout.addItem(spacerItem1)

        QtCore.QMetaObject.connectSlotsByName(self)
Beispiel #39
0
    def create_font_array(self, char_height=62, pixel_margin=1, font_family='Courier', font_weight=50):
        # Load font and get the dimensions of one character (assuming monospaced font)
        f = QFont(font_family)
        f.setPixelSize(char_height)
        f.setWeight(font_weight)
        fm = QFontMetrics(f, QImage())

        char_width = char_height = 0
        char_y = 999

        for i in range(32, 127):
            bb = fm.boundingRect(chr(i))
            char_width = max(char_width, bb.width())
            char_height = max(char_height, bb.height())
            char_y = min(char_y, bb.y())

        imgsize = (char_width + 2 * pixel_margin, char_height + 2 * pixel_margin)
        self.char_ar = float(imgsize[1]) / imgsize[0]

        # init the image and the painter that will draw the characters to each image
        img = QImage(imgsize[0], imgsize[1], QImage.Format_ARGB32)
        ptr = c_void_p(int(img.constBits()))
        painter = QPainter(img)
        painter.setFont(f)
        painter.setPen(QColor(255, 255, 255, 255))

        # Set-up the texture array
        self.tex_id = gl.glGenTextures(1)
        gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, self.tex_id)
        gl.glTexImage3D(gl.GL_TEXTURE_2D_ARRAY, 0, gl.GL_RGBA8, imgsize[0], imgsize[1], 127 - 32, 0, gl.GL_BGRA, gl.GL_UNSIGNED_BYTE, None)
        gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
        gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
        gl.glTexParameterf(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_BORDER)
        gl.glTexParameterf(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_BORDER)
        # We're using the ASCII range 32-126; space, uppercase, lower case, numbers, brackets, punctuation marks
        for i in range(32, 127):
            img.fill(0)
            painter.drawText(pixel_margin, pixel_margin - char_y, chr(i))
            gl.glTexSubImage3D(gl.GL_TEXTURE_2D_ARRAY, 0, 0, 0, i - 32, imgsize[0], imgsize[1], 1, gl.GL_BGRA, gl.GL_UNSIGNED_BYTE, ptr)

        # We're done, close the painter, and return the texture ID, char width and char height
        painter.end()
Beispiel #40
0
class LabeledBar(QProgressBar):
    def __init__(self, parent=None):
        super(LabeledBar, self).__init__(parent)
        self.text = ''
        self.setTextVisible(False)
        self.font = QFont()
        self.font.setPointSize(8)
        self.font.setBold(True)
        self.font.setWeight(75)

    def paintEvent(self, event):
        super(LabeledBar, self).paintEvent(event)
        qp = QPainter()
        qp.begin(self)
        self.drawText(qp)
        qp.end()

    def drawText(self, qp):
        qp.setOpacity(1.0)
        qp.setFont(self.font)
        qp.drawText(self.rect(), Qt.AlignCenter, self.text)
Beispiel #41
0
    def __init__(self, *args):
        super(MyDragDropBox, self).__init__(*args)
        Lumberjack.info('spawning a << MyDragDropBox >>')
        print(Fore.GREEN + '--=== DRAGDROPBOX ===--')
        print(Fore.GREEN + 'Here come the inits!')
        print(Fore.GREEN + 'args: ', args)
        print(Fore.GREEN + '==--- DRAGDROPBOX ---==')

        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.DropLabel = QLabel(self)
        font = QFont()
        font.setPointSize(12)
        font.setBold(False)
        font.setUnderline(False)
        font.setWeight(50)
        self.DropLabel.setFont(font)
        self.DropLabel.setAlignment(Qt.AlignCenter)
        self.DropLabel.setObjectName("DropLabel")
        self.verticalLayout.addWidget(self.DropLabel)
        self.edit = False
Beispiel #42
0
    def transform(self, value):
        if not value:
            return None
        style_map = {"normal": QFont.StyleNormal, "italic": QFont.StyleItalic, "oblique": QFont.StyleOblique}
        weight_map = {"normal": QFont.Normal, "bold": QFont.Bold}
        font = QFont()
        font.setStyle(QFont.StyleNormal)
        font.setWeight(QFont.Normal)

        match = self.font_regex.match(value)
        style = match.group("style")
        weight = match.group("weight")
        namedweight = match.group("namedweight")
        size = match.group("size")
        family = match.group("family")
        if style:
            font.setStyle(style_map[style])
        if namedweight:
            font.setWeight(weight_map[namedweight])
        if weight:
            # based on qcssparser.cpp:setFontWeightFromValue
            font.setWeight(min(int(weight) / 8, 99))
        if size:
            if size.lower().endswith("pt"):
                font.setPointSizeF(float(size[:-2]))
            elif size.lower().endswith("px"):
                font.setPixelSize(int(size[:-2]))
        # The Qt CSS parser handles " and ' before passing the string to
        # QFont.setFamily. We could do proper CSS-like parsing here, but since
        # hopefully nobody will ever have a font with quotes in the family (if
        # that's even possible), we take a much more naive approach.
        family = family.replace('"', "").replace("'", "")
        font.setFamily(family)
        return font
    def data(self, index, role=Qt.DisplayRole):

        if index.isValid() and not self.mapToSource(index).isValid():
            row = index.row()

            if role == Qt.DisplayRole:
                return self._map[row].text()

            elif role == Qt.ForegroundRole:
                return QBrush(Qt.darkBlue)
            elif role == Qt.BackgroundRole:
                return QBrush(QColor(Qt.blue).lighter(190))
            elif role == Qt.TextAlignmentRole:
                return Qt.AlignCenter
            elif role == Qt.FontRole:
                f = QFont()
                # f.setPointSize(f.pointSize() + 1)
                f.setWeight(QFont.Bold)
                return f
        else:
            # FIXME: sometimes, the name of the character is not displayed
            return self.sourceModel().data(self.mapToSource(index), role)
Beispiel #44
0
 def _setupUi(self):
     self.setWindowTitle(tr("About {}").format(QCoreApplication.instance().applicationName()))
     self.resize(400, 190)
     sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     sizePolicy.setHorizontalStretch(0)
     sizePolicy.setVerticalStretch(0)
     sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
     self.setSizePolicy(sizePolicy)
     self.horizontalLayout = QHBoxLayout(self)
     self.logoLabel = QLabel(self)
     self.logoLabel.setPixmap(QPixmap(':/%s_big' % self.app.LOGO_NAME))
     self.horizontalLayout.addWidget(self.logoLabel)
     self.verticalLayout = QVBoxLayout()
     self.nameLabel = QLabel(self)
     font = QFont()
     font.setWeight(75)
     font.setBold(True)
     self.nameLabel.setFont(font)
     self.nameLabel.setText(QCoreApplication.instance().applicationName())
     self.verticalLayout.addWidget(self.nameLabel)
     self.versionLabel = QLabel(self)
     self.versionLabel.setText(tr("Version {}").format(QCoreApplication.instance().applicationVersion()))
     self.verticalLayout.addWidget(self.versionLabel)
     self.label_3 = QLabel(self)
     self.verticalLayout.addWidget(self.label_3)
     self.label_3.setText(tr("Licensed under GPLv3"))
     self.label = QLabel(self)
     font = QFont()
     font.setWeight(75)
     font.setBold(True)
     self.label.setFont(font)
     self.verticalLayout.addWidget(self.label)
     self.buttonBox = QDialogButtonBox(self)
     self.buttonBox.setOrientation(Qt.Horizontal)
     self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)
     self.verticalLayout.addWidget(self.buttonBox)
     self.horizontalLayout.addLayout(self.verticalLayout)
Beispiel #45
0
    def to_py(self, value):
        self._basic_py_validation(value, str)
        if not value:
            return None

        style_map = {
            'normal': QFont.StyleNormal,
            'italic': QFont.StyleItalic,
            'oblique': QFont.StyleOblique,
        }
        weight_map = {
            'normal': QFont.Normal,
            'bold': QFont.Bold,
        }
        font = QFont()
        font.setStyle(QFont.StyleNormal)
        font.setWeight(QFont.Normal)

        match = self.font_regex.match(value)
        if not match:  # pragma: no cover
            # This should never happen, as the regex always matches everything
            # as family.
            raise configexc.ValidationError(value, "must be a valid font")

        style = match.group('style')
        weight = match.group('weight')
        namedweight = match.group('namedweight')
        size = match.group('size')
        family = match.group('family')
        if style:
            font.setStyle(style_map[style])
        if namedweight:
            font.setWeight(weight_map[namedweight])
        if weight:
            # based on qcssparser.cpp:setFontWeightFromValue
            font.setWeight(min(int(weight) / 8, 99))
        if size:
            if size.lower().endswith('pt'):
                font.setPointSizeF(float(size[:-2]))
            elif size.lower().endswith('px'):
                font.setPixelSize(int(size[:-2]))
            else:
                # This should never happen as the regex only lets pt/px
                # through.
                raise ValueError("Unexpected size unit in {!r}!".format(
                    size))  # pragma: no cover
        # The Qt CSS parser handles " and ' before passing the string to
        # QFont.setFamily. We could do proper CSS-like parsing here, but since
        # hopefully nobody will ever have a font with quotes in the family (if
        # that's even possible), we take a much more naive approach.
        family = family.replace('"', '').replace("'", '')
        if family == 'monospace':
            family = self.monospace_fonts
        font.setFamily(family)
        return font
Beispiel #46
0
    def populate(self):
        """Populate the tree view with data from the installed extensions.
        """

        # TODO/Question:
        # Would it make sense to move this to a dedicated model class
        # complementing the FailedModel?

        root = self.tree.model().invisibleRootItem()
        extensions = app.extensions()
        for ext in extensions.installed_extensions():
            ext_infos = extensions.infos(ext)
            display_name = ext_infos.get(ext, ext) if ext_infos else ext.name()
            loaded_extension = extensions.get(ext)
            if loaded_extension:
                display_name += ' ({})'.format(loaded_extension.load_time())

            name_item = QStandardItem(display_name)
            name_item.extension_name = ext
            name_item.setCheckable(True)
            self.name_items[ext] = name_item
            icon = extensions.icon(ext)
            if icon:
                name_item.setIcon(icon)
            root.appendRow([name_item])
            for entry in [
                'extension-name',
                'short-description',
                'description',
                'version',
                'api-version',
                'dependencies',
                'maintainers',
                'repository',
                'website',
                'license'
            ]:
                label_item = QStandardItem('{}:'.format(
                    self.config_labels[entry]))
                label_item.setTextAlignment(Qt.AlignTop)
                bold = QFont()
                bold.setWeight(QFont.Bold)
                label_item.setFont(bold)
                details = ext_infos.get(entry, "") if ext_infos else ""
                if type(details) == list:
                    details = '\n'.join(details)
                details_item = QStandardItem(details)
                details_item.setTextAlignment(Qt.AlignTop)
                if entry == 'api-version':
                    # Check for correct(ly formatted) api-version entry
                    # and highlight it in case of mismatch
                    api_version = appinfo.extension_api
                    if not details:
                        details_item.setFont(bold)
                        details_item.setText(
                            _("Misformat: {api}").format(details))
                    elif not details == api_version:
                            details_item.setFont(bold)
                            details_item.setText('{} ({}: {})'.format(
                                details,
                                appinfo.appname,
                                api_version))
                name_item.appendRow([label_item, details_item])
Beispiel #47
0
    def paint(self, painter, option, index):

        item = index.internalPointer()
        colors = outlineItemColors(item)

        style = qApp.style()

        opt = QStyleOptionViewItem(option)
        self.initStyleOption(opt, index)

        iconRect = style.subElementRect(style.SE_ItemViewItemDecoration, opt)
        textRect = style.subElementRect(style.SE_ItemViewItemText, opt)

        # Background
        style.drawPrimitive(style.PE_PanelItemViewItem, opt, painter)

        if settings.viewSettings["Tree"]["Background"] != "Nothing" and not opt.state & QStyle.State_Selected:

            col = colors[settings.viewSettings["Tree"]["Background"]]

            if col != QColor(Qt.transparent):
                col2 = QColor(Qt.white)
                if opt.state & QStyle.State_Selected:
                    col2 = opt.palette.brush(QPalette.Normal, QPalette.Highlight).color()
                col = mixColors(col, col2, .2)

            painter.save()
            painter.setBrush(col)
            painter.setPen(Qt.NoPen)

            rect = opt.rect
            if self._view:
                r2 = self._view.visualRect(index)
                rect = self._view.viewport().rect()
                rect.setLeft(r2.left())
                rect.setTop(r2.top())
                rect.setBottom(r2.bottom())

            painter.drawRoundedRect(rect, 5, 5)
            painter.restore()

        # Icon
        mode = QIcon.Normal
        if not opt.state & QStyle.State_Enabled:
            mode = QIcon.Disabled
        elif opt.state & QStyle.State_Selected:
            mode = QIcon.Selected
        state = QIcon.On if opt.state & QStyle.State_Open else QIcon.Off
        icon = opt.icon.pixmap(iconRect.size(), mode=mode, state=state)
        if opt.icon and settings.viewSettings["Tree"]["Icon"] != "Nothing":
            color = colors[settings.viewSettings["Tree"]["Icon"]]
            colorifyPixmap(icon, color)
        opt.icon = QIcon(icon)
        opt.icon.paint(painter, iconRect, opt.decorationAlignment, mode, state)

        # Text
        if opt.text:
            painter.save()
            if settings.viewSettings["Tree"]["Text"] != "Nothing":
                col = colors[settings.viewSettings["Tree"]["Text"]]
                if col == Qt.transparent:
                    col = Qt.black
                painter.setPen(col)
            f = QFont(opt.font)
            painter.setFont(f)
            fm = QFontMetrics(f)
            elidedText = fm.elidedText(opt.text, Qt.ElideRight, textRect.width())
            painter.drawText(textRect, Qt.AlignLeft, elidedText)

            extraText = ""
            if item.isFolder() and settings.viewSettings["Tree"]["InfoFolder"] != "Nothing":
                if settings.viewSettings["Tree"]["InfoFolder"] == "Count":
                    extraText = item.childCount()
                    extraText = " [{}]".format(extraText)
                elif settings.viewSettings["Tree"]["InfoFolder"] == "WC":
                    extraText = item.data(Outline.wordCount.value)
                    extraText = " ({})".format(extraText)
                elif settings.viewSettings["Tree"]["InfoFolder"] == "Progress":
                    extraText = int(toFloat(item.data(Outline.goalPercentage.value)) * 100)
                    if extraText:
                        extraText = " ({}%)".format(extraText)
                elif settings.viewSettings["Tree"]["InfoFolder"] == "Summary":
                    extraText = item.data(Outline.summarySentance.value)
                    if extraText:
                        extraText = " - {}".format(extraText)

            if item.isText() and settings.viewSettings["Tree"]["InfoText"] != "Nothing":
                if settings.viewSettings["Tree"]["InfoText"] == "WC":
                    extraText = item.data(Outline.wordCount.value)
                    extraText = " ({})".format(extraText)
                elif settings.viewSettings["Tree"]["InfoText"] == "Progress":
                    extraText = int(toFloat(item.data(Outline.goalPercentage.value)) * 100)
                    if extraText:
                        extraText = " ({}%)".format(extraText)
                elif settings.viewSettings["Tree"]["InfoText"] == "Summary":
                    extraText = item.data(Outline.summarySentance.value)
                    if extraText:
                        extraText = " - {}".format(extraText)


            if extraText:
                r = QRect(textRect)
                r.setLeft(r.left() + fm.width(opt.text + " "))

                painter.save()
                f = painter.font()
                f.setWeight(QFont.Normal)
                painter.setFont(f)
                painter.setPen(Qt.darkGray)
                painter.drawText(r, Qt.AlignLeft | Qt.AlignBottom, extraText)
                painter.restore()

            painter.restore()
 def get_font_title():
     font = QFont()
     font.setPointSize(15)
     font.setWeight(75)
     font.setBold(True)
     return font
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(430, 486)
        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8("images/icon.ico")), QIcon.Normal, QIcon.Off)
        Dialog.setWindowIcon(icon)
        self.formLayoutWidget_2 = QWidget(Dialog)
        self.formLayoutWidget_2.setGeometry(QRect(230, 80, 181, 131))
        self.formLayoutWidget_2.setObjectName(_fromUtf8("formLayoutWidget_2"))
        self.formLayout_2 = QFormLayout(self.formLayoutWidget_2)
        self.formLayout_2.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        self.formLayout_2.setObjectName(_fromUtf8("formLayout_2"))
        self.label_5 = QLabel(self.formLayoutWidget_2)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.formLayout_2.setWidget(0, QFormLayout.LabelRole, self.label_5)
        self.ball_box = QComboBox(self.formLayoutWidget_2)
        self.ball_box.setObjectName(_fromUtf8("ball_box"))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.ball_box.addItem(_fromUtf8(""))
        self.formLayout_2.setWidget(0, QFormLayout.FieldRole, self.ball_box)
        self.label_6 = QLabel(self.formLayoutWidget_2)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.formLayout_2.setWidget(2, QFormLayout.LabelRole, self.label_6)
        self.status_box = QComboBox(self.formLayoutWidget_2)
        self.status_box.setObjectName(_fromUtf8("status_box"))
        self.status_box.addItem(_fromUtf8(""))
        self.status_box.addItem(_fromUtf8(""))
        self.status_box.addItem(_fromUtf8(""))
        self.status_box.addItem(_fromUtf8(""))
        self.status_box.addItem(_fromUtf8(""))
        self.status_box.addItem(_fromUtf8(""))
        self.formLayout_2.setWidget(2, QFormLayout.FieldRole, self.status_box)
        spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.formLayout_2.setItem(1, QFormLayout.FieldRole, spacerItem)
        spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.formLayout_2.setItem(3, QFormLayout.FieldRole, spacerItem1)
        self.captured_edit = QLineEdit(self.formLayoutWidget_2)
        self.captured_edit.setObjectName(_fromUtf8("captured_edit"))
        self.formLayout_2.setWidget(4, QFormLayout.FieldRole, self.captured_edit)
        self.label = QLabel(self.formLayoutWidget_2)
        self.label.setObjectName(_fromUtf8("label"))
        self.formLayout_2.setWidget(4, QFormLayout.LabelRole, self.label)
        self.formLayoutWidget_3 = QWidget(Dialog)
        self.formLayoutWidget_3.setGeometry(QRect(20, 80, 171, 131))
        self.formLayoutWidget_3.setObjectName(_fromUtf8("formLayoutWidget_3"))
        self.formLayout_3 = QFormLayout(self.formLayoutWidget_3)
        self.formLayout_3.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
        self.formLayout_3.setObjectName(_fromUtf8("formLayout_3"))
        self.label_8 = QLabel(self.formLayoutWidget_3)
        self.label_8.setObjectName(_fromUtf8("label_8"))
        self.formLayout_3.setWidget(0, QFormLayout.LabelRole, self.label_8)
        self.pokemon_Name_box = QComboBox(self.formLayoutWidget_3)
        self.pokemon_Name_box.setObjectName(_fromUtf8("pokemon_Name_box"))
        self.formLayout_3.setWidget(0, QFormLayout.FieldRole, self.pokemon_Name_box)
        spacerItem2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.formLayout_3.setItem(1, QFormLayout.FieldRole, spacerItem2)
        self.label_9 = QLabel(self.formLayoutWidget_3)
        self.label_9.setObjectName(_fromUtf8("label_9"))
        self.formLayout_3.setWidget(2, QFormLayout.LabelRole, self.label_9)
        self.level_edit = QLineEdit(self.formLayoutWidget_3)
        self.level_edit.setObjectName(_fromUtf8("level_edit"))
        self.formLayout_3.setWidget(2, QFormLayout.FieldRole, self.level_edit)
        self.label_10 = QLabel(self.formLayoutWidget_3)
        self.label_10.setObjectName(_fromUtf8("label_10"))
        self.formLayout_3.setWidget(3, QFormLayout.LabelRole, self.label_10)
        self.hp_edit = QLineEdit(self.formLayoutWidget_3)
        self.hp_edit.setObjectName(_fromUtf8("hp_edit"))
        self.formLayout_3.setWidget(3, QFormLayout.FieldRole, self.hp_edit)
        self.spriteLabel = QLabel(self.formLayoutWidget_3)
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spriteLabel.sizePolicy().hasHeightForWidth())
        self.spriteLabel.setSizePolicy(sizePolicy)
        self.spriteLabel.setText(_fromUtf8(""))
        self.spriteLabel.setObjectName(_fromUtf8("spriteLabel"))
        self.formLayout_3.setWidget(1, QFormLayout.LabelRole, self.spriteLabel)
        self.textBrowser = QTextBrowser(Dialog)
        self.textBrowser.setGeometry(QRect(20, 260, 391, 192))
        self.textBrowser.setObjectName(_fromUtf8("textBrowser"))
        self.label_3 = QLabel(Dialog)
        self.label_3.setGeometry(QRect(335, 460, 71, 20))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.label_4 = QLabel(Dialog)
        self.label_4.setGeometry(QRect(20, 30, 251, 16))
        font = QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.logolabel = QLabel(Dialog)
        self.logolabel.setGeometry(QRect(280, 20, 121, 51))
        self.logolabel.setText(_fromUtf8(""))
        self.logolabel.setObjectName(_fromUtf8("logolabel"))
        pixmap = QPixmap("images/logo.png")
        self.logolabel.setPixmap(pixmap)
        self.logolabel.setMask(pixmap.mask())
        self.calculateButton = QPushButton(Dialog)
        self.calculateButton.setGeometry(QRect(340, 230, 72, 23))
        self.calculateButton.setObjectName(_fromUtf8("calculateButton"))

        self.retranslateUi(Dialog)
        QMetaObject.connectSlotsByName(Dialog)
Beispiel #50
0
    def load(self, path: str, is_first_call: bool = True) -> None:
        if path == self._path:
            return

        with open(os.path.join(path, "theme.json"), encoding = "utf-8") as f:
            Logger.log("d", "Loading theme file: %s", os.path.join(path, "theme.json"))
            data = json.load(f)

        # Iteratively load inherited themes
        try:
            theme_id = data["metadata"]["inherits"]
            self.load(Resources.getPath(Resources.Themes, theme_id), is_first_call = False)
        except FileNotFoundError:
            Logger.log("e", "Could not find inherited theme %s", theme_id)
        except KeyError:
            pass  # No metadata or no inherits keyword in the theme.json file

        if "colors" in data:
            for name, color in data["colors"].items():
                c = QColor(color[0], color[1], color[2], color[3])
                self._colors[name] = c

        fonts_dir = os.path.join(path, "fonts")
        if os.path.isdir(fonts_dir):
            for file in os.listdir(fonts_dir):
                if "ttf" in file:
                    QFontDatabase.addApplicationFont(os.path.join(fonts_dir, file))

        if "fonts" in data:
            system_font_size = QCoreApplication.instance().font().pointSize()
            for name, font in data["fonts"].items():
                q_font = QFont()
                q_font.setFamily(font.get("family", QCoreApplication.instance().font().family()))

                if font.get("bold"):
                    q_font.setBold(font.get("bold", False))
                else:
                    q_font.setWeight(font.get("weight", 50))

                q_font.setLetterSpacing(QFont.AbsoluteSpacing, font.get("letterSpacing", 0))
                q_font.setItalic(font.get("italic", False))
                q_font.setPointSize(int(font.get("size", 1) * system_font_size))
                q_font.setCapitalization(QFont.AllUppercase if font.get("capitalize", False) else QFont.MixedCase)

                self._fonts[name] = q_font

        if "sizes" in data:
            for name, size in data["sizes"].items():
                s = QSizeF()
                s.setWidth(round(size[0] * self._em_width))
                s.setHeight(round(size[1] * self._em_height))

                self._sizes[name] = s

        iconsdir = os.path.join(path, "icons")
        if os.path.isdir(iconsdir):
            for icon in os.listdir(iconsdir):
                name = os.path.splitext(icon)[0]
                self._icons[name] = QUrl.fromLocalFile(os.path.join(iconsdir, icon))

        imagesdir = os.path.join(path, "images")
        if os.path.isdir(imagesdir):
            for image in os.listdir(imagesdir):
                name = os.path.splitext(image)[0]
                self._images[name] = QUrl.fromLocalFile(os.path.join(imagesdir, image))

        styles = os.path.join(path, "styles.qml")
        if os.path.isfile(styles):
            c = QQmlComponent(self._engine, styles)
            context = QQmlContext(self._engine, self._engine)
            context.setContextProperty("Theme", self)
            self._styles = c.create(context)

            if c.isError():
                for error in c.errors():
                    Logger.log("e", error.toString())

        Logger.log("d", "Loaded theme %s", path)
        self._path = path

        # only emit the theme loaded signal once after all the themes in the inheritance chain have been loaded
        if is_first_call:
            self.themeLoaded.emit()
Beispiel #51
0
    def paintEvent(self,event):
        global monster_data
        global dmg
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.drawPixmap(event.rect(),self.pixmap)

        if self.card is not None and self.card.ID is not 0:
            card = self.card
            # Draw card level at the bottom centered
            pen = QPen()
            if np.floor(card.lv) == monster_data[card.ID]['max_level']:
                lvstr = 'Lv.Max'
                brush = QBrush(QColor(252,232,131))
            else:
                lvstr = 'Lv.%d' % np.floor(card.lv)
                brush = QBrush(Qt.white)

            path = QPainterPath()
            pen.setWidth(0);
            pen.setBrush(Qt.black)

            font = QFont()
            font.setPointSize(11)
            font.setWeight(QFont.Black)
            
            path.addText(event.rect().x(),event.rect().y()+48,font,lvstr)

            rect = path.boundingRect()
            target = (event.rect().x()+event.rect().width())/2

            # center the rect in event.rect()
            path.translate(target-rect.center().x(), 0)

            painter.setPen(pen)
            painter.setBrush(QBrush(Qt.black))
            painter.drawPath(path.translated(.5,.5))

            painter.setPen(pen)
            painter.setBrush(brush)

            painter.drawPath(path)

            # Draw +eggs at the top right
            eggs = card.plus_atk+card.plus_hp+card.plus_rcv
            if eggs > 0:
                eggstr = '+%d' % eggs
                pen.setBrush(Qt.yellow)
                brush = QBrush(Qt.yellow)

                path = QPainterPath()
                pen.setWidth(0)
                pen.setBrush(Qt.black)
                font = QFont()
                font.setPointSize(11)
                font.setWeight(QFont.Black)
                path.addText(event.rect().x(),event.rect().y()+12,font,eggstr)

                path.translate(50-path.boundingRect().right()-3,0)
                #painter.setFont(font)
                painter.setPen(pen)
                painter.setBrush(QBrush(Qt.black))
                painter.drawPath(path.translated(.5,.5))

                painter.setPen(pen)
                painter.setBrush(brush)
                painter.drawPath(path)
                #painter.drawText(event.rect().adjusted(0,0,0,0),Qt.AlignRight, eggstr)

            # Draw awakenings at the top left in a green circle
            if card.current_awakening > 0:
                path = QPainterPath()
                rect = QRectF(event.rect()).adjusted(4,4,-36,-36)
                path.addEllipse(rect)
                painter.setBrush(QBrush(QColor(34,139,34)))
                pen.setBrush(Qt.white)
                pen.setWidth(1)
                painter.setPen(pen)
                painter.drawPath(path)

                path = QPainterPath()
                font.setPointSize(9)
                awkstr = ('%d' % card.current_awakening if
                        card.current_awakening < card.max_awakening else
                        '★')
                path.addText(rect.x(),rect.bottom(),font,awkstr)
                
                br = path.boundingRect()
                path.translate(rect.center().x()-br.center().x(),
                        rect.center().y()-br.center().y())

                pen.setBrush(QColor(0,0,0,0))
                pen.setWidth(0)
                painter.setPen(pen)
                painter.setBrush(QBrush(Qt.yellow))
                painter.drawPath(path)

            # Draw main attack damage
            #print(self.main_attack)
            if self.main_attack > 0:
                matkstr = '%d' % self.main_attack
                painter.setBrush(QBrush(COLORS[self.card.element[0]]))
                path = QPainterPath()
                font = QFont()
                font.setFamily('Helvetica')
                font.setWeight(QFont.Black)
                #font.setStretch(25)
                font.setPointSize(13)
                path.addText(rect.x(),rect.bottom(),font,matkstr)

                rect = QRectF(event.rect())
                br = path.boundingRect()
                path.translate(rect.center().x()-br.center().x(),
                        rect.center().y()-br.bottom()-1)

                # 
                pen.setBrush(Qt.black)
                pen.setWidthF(.75)
                painter.setPen(pen)
                painter.drawPath(path)

            # Draw sub attack damage
            #print(self.main_attack)
            if self.sub_attack > 0:
                satkstr = '%d' % self.sub_attack
                painter.setBrush(QBrush(COLORS[self.card.element[1]]))
                path = QPainterPath()
                font = QFont()
                font.setFamily('Helvetica')
                font.setWeight(QFont.Black)
                #font.setStretch(25)
                font.setPointSize(12)
                path.addText(rect.x(),rect.bottom(),font,satkstr)

                rect = QRectF(event.rect())
                br = path.boundingRect()
                path.translate(rect.center().x()-br.center().x(),
                        rect.center().y()-br.top()+1)

                # 
                pen.setBrush(Qt.black)
                pen.setWidthF(.75)
                painter.setPen(pen)
                painter.drawPath(path)
Beispiel #52
0
    def __init__(self,persepolis_setting):
        super().__init__()

        self.persepolis_setting = persepolis_setting

        # add support for other languages
        locale = str(self.persepolis_setting.value('settings/locale'))
        QLocale.setDefault(QLocale(locale))
        self.translator = QTranslator()
        if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
            QCoreApplication.installTranslator(self.translator)

        # set ui direction
        ui_direction = self.persepolis_setting.value('ui_direction')

        if ui_direction == 'rtl':
            self.setLayoutDirection(Qt.RightToLeft)
        
        elif ui_direction in 'ltr':
            self.setLayoutDirection(Qt.LeftToRight)


        icons = ':/' + \
            str(self.persepolis_setting.value('settings/icons')) + '/'

        self.setMinimumSize(QSize(545, 375))
        self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))

        verticalLayout = QVBoxLayout(self)

        self.about_tabWidget = QTabWidget(self)

        # about tab
        self.about_tab = QWidget(self)

        about_tab_horizontalLayout = QHBoxLayout(self.about_tab)

        about_tab_verticalLayout = QVBoxLayout()
        

        # persepolis icon
        if qtsvg_available:
            persepolis_icon_verticalLayout = QVBoxLayout()
            self.persepolis_icon = QtSvg.QSvgWidget(':/persepolis.svg')
            self.persepolis_icon.setFixedSize(QSize(64, 64))

            persepolis_icon_verticalLayout.addWidget(self.persepolis_icon)
            persepolis_icon_verticalLayout.addStretch(1)

            about_tab_horizontalLayout.addLayout(persepolis_icon_verticalLayout)

        self.title_label = QLabel(self.about_tab)
        font = QFont()
        font.setBold(True)
        font.setWeight(75)
        self.title_label.setFont(font)
        self.title_label.setAlignment(Qt.AlignCenter)
        about_tab_verticalLayout.addWidget(self.title_label)

        self.version_label = QLabel(self.about_tab)
        self.version_label.setAlignment(Qt.AlignCenter)

        about_tab_verticalLayout.addWidget(self.version_label)

        self.site2_label = QLabel(self.about_tab)
        self.site2_label.setTextFormat(Qt.RichText)
        self.site2_label.setAlignment(Qt.AlignCenter)
        self.site2_label.setOpenExternalLinks(True)
        self.site2_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        about_tab_verticalLayout.addWidget(self.site2_label)

        self.telegram_label = QLabel(self.about_tab)
        self.telegram_label.setTextFormat(Qt.RichText)
        self.telegram_label.setAlignment(Qt.AlignCenter)
        self.telegram_label.setOpenExternalLinks(True)
        self.telegram_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        about_tab_verticalLayout.addWidget(self.telegram_label)

        self.twitter_label = QLabel(self.about_tab)
        self.twitter_label.setTextFormat(Qt.RichText)
        self.twitter_label.setAlignment(Qt.AlignCenter)
        self.twitter_label.setOpenExternalLinks(True)
        self.twitter_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        about_tab_verticalLayout.addWidget(self.twitter_label)

        about_tab_verticalLayout.addStretch(1)

        about_tab_horizontalLayout.addLayout(about_tab_verticalLayout)


        # developers_tab
        # developers
        self.developers_tab = QWidget(self)
        developers_verticalLayout = QVBoxLayout(self.developers_tab)

        self.developers_title_label = QLabel(self.developers_tab)
        font.setBold(True)
        font.setWeight(75)
        self.developers_title_label.setFont(font)
        self.developers_title_label.setAlignment(Qt.AlignCenter)
        developers_verticalLayout.addWidget(self.developers_title_label)
 

        self.name_label = QLabel(self.developers_tab)
        self.name_label.setAlignment(Qt.AlignCenter)

        developers_verticalLayout.addWidget(self.name_label)


        # contributors
        self.contributors_thank_label = QLabel(self.developers_tab)
        self.contributors_thank_label.setFont(font)
        self.contributors_thank_label.setAlignment(Qt.AlignCenter)

        developers_verticalLayout.addWidget(self.contributors_thank_label)

        self.contributors_link_label = QLabel(self.developers_tab)
        self.contributors_link_label.setTextFormat(Qt.RichText)
        self.contributors_link_label.setAlignment(Qt.AlignCenter)
        self.contributors_link_label.setOpenExternalLinks(True)
        self.contributors_link_label.setTextInteractionFlags(
            Qt.TextBrowserInteraction)
        developers_verticalLayout.addWidget(self.contributors_link_label)

        developers_verticalLayout.addStretch(1)

        # translators tab
        self.translators_tab = QWidget(self)
        translators_tab_verticalLayout = QVBoxLayout(self.translators_tab)

        # chinese translators
        self.chinese_translators_label = QLabel(self.translators_tab)
        self.chinese_translators_label.setFont(font)
        self.chinese_translators_label.setAlignment(Qt.AlignCenter)
        translators_tab_verticalLayout.addWidget(self.chinese_translators_label)

        self.chinese_translatos_name_label = QLabel(self.translators_tab)
        self.chinese_translatos_name_label.setAlignment(Qt.AlignCenter)
        translators_tab_verticalLayout.addWidget(self.chinese_translatos_name_label)

        # french translators
        self.french_translators_label = QLabel(self.translators_tab)
        self.french_translators_label.setFont(font)
        self.french_translators_label.setAlignment(Qt.AlignCenter)
        translators_tab_verticalLayout.addWidget(self.french_translators_label)

        self.french_translatos_name_label = QLabel(self.translators_tab)
        self.french_translatos_name_label.setAlignment(Qt.AlignCenter)
        translators_tab_verticalLayout.addWidget(self.french_translatos_name_label)

        # persian translators
        self.persian_translators_label = QLabel(self.translators_tab)
        self.persian_translators_label.setFont(font)
        self.persian_translators_label.setAlignment(Qt.AlignCenter)

        translators_tab_verticalLayout.addWidget(self.persian_translators_label)

        self.persian_translatos_name_label = QLabel(self.translators_tab)
        self.persian_translatos_name_label.setAlignment(Qt.AlignCenter)
        translators_tab_verticalLayout.addWidget(self.persian_translatos_name_label)


        translators_tab_verticalLayout.addStretch(1)
   
        # License tab
        self.license_tab = QWidget(self)
        license_tab_verticalLayout = QVBoxLayout(self.license_tab)

        self.license_text = QTextEdit(self.license_tab)
        self.license_text.setReadOnly(True)

        license_tab_verticalLayout.addWidget(self.license_text)



        verticalLayout.addWidget(self.about_tabWidget)

        # buttons
        button_horizontalLayout = QHBoxLayout()
        button_horizontalLayout.addStretch(1)

        self.pushButton = QPushButton(self)
        self.pushButton.setIcon(QIcon(icons + 'ok'))
        self.pushButton.clicked.connect(self.close)

        button_horizontalLayout.addWidget(self.pushButton)

        verticalLayout.addLayout(button_horizontalLayout)

        self.setWindowTitle(QCoreApplication.translate("about_ui_tr", "About Persepolis"))

        # about_tab
        self.title_label.setText(QCoreApplication.translate("about_ui_tr", "Persepolis Download Manager"))
        self.version_label.setText(QCoreApplication.translate("about_ui_tr", "Version 3.1.0"))
        self.site2_label.setText(QCoreApplication.translate("about_ui_tr", 
            "<a href=https://persepolisdm.github.io>https://persepolisdm.github.io</a>",
            "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        self.telegram_label.setText(QCoreApplication.translate("about_ui_tr", 
            "<a href=https://telegram.me/persepolisdm>https://telegram.me/persepolisdm</a>",
            "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        self.twitter_label.setText(QCoreApplication.translate("about_ui_tr", 
            "<a href=https://twitter.com/persepolisdm>https://twitter.com/persepolisdm</a>",
            "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        #developers_tab
        self.developers_title_label.setText(QCoreApplication.translate('about_ui_tr', 'Developers:'))

        self.name_label.setText(QCoreApplication.translate("about_ui_tr", 
            "\nAliReza AmirSamimi\nMohammadreza Abdollahzadeh\nSadegh Alirezaie\nMostafa Asadi\nMohammadAmin Vahedinia\nJafar Akhondali\nH.Rostami",
            "TRANSLATORS NOTE: YOU REALLY DON'T NEED TO TRANSLATE THIS PART!"))

        self.contributors_thank_label.setText(QCoreApplication.translate('about_ui_tr', 'Special thanks to:'))
        self.contributors_link_label.setText("<a href=https://github.com/persepolisdm/persepolis/graphs/contributors>our contributors</a>")

        # translators_tab
        # Chinese
        self.chinese_translators_label.setText(QCoreApplication.translate("about_ui_tr", "Chinese translators:"))

        self.chinese_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "Davinma\n210hcl\nleoxxx"))

        # French
        self.french_translators_label.setText(QCoreApplication.translate("about_ui_tr", "French translator:"))

        self.french_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "Simon Porte"))


        # Persian
        self.persian_translators_label.setText(QCoreApplication.translate("about_ui_tr", "Persian translators:"))

        self.persian_translatos_name_label.setText(QCoreApplication.translate("about_ui_tr", "H.Rostami\nMostafa Asadi"))

        # License
        self.license_text.setPlainText("""
            This program is free software: you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation, either version 3 of the License, or
            (at your option) any later version.

            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.

            You should have received a copy of the GNU General Public License
            along with this program.  If not, see http://www.gnu.org/licenses/.
            """)


        # tabs
        self.about_tabWidget.addTab(self.about_tab, QCoreApplication.translate("about_ui_tr", "About Persepolis"))
        self.about_tabWidget.addTab(self.developers_tab, QCoreApplication.translate("about_ui_tr", "Developers"))
        self.about_tabWidget.addTab(self.translators_tab, QCoreApplication.translate("about_ui_tr", "Translators"))
        self.about_tabWidget.addTab(self.license_tab, QCoreApplication.translate("about_ui_tr", "License"))

        # button
        self.pushButton.setText(QCoreApplication.translate("about_ui_tr", "OK"))
Beispiel #53
0
class LGPdfWriter(QPrinter):
    def __init__(self, name: str):
        super(LGPdfWriter, self).__init__()
        if not self.touch(name):
            raise PermissionError("Cannot open "+name)

        self.setOutputFileName(name)
        self.setOutputFormat(self.PdfFormat)
        self.setPageSize(self.A4)

        #self.setPageSizeMM(QSizeF(2100,2970))
        self._rot = QPen(QColor(255,0,0))
        self._blau = QPen(QColor(0,0,255))
        self._grün = QPen(QColor(0,255,0))
        self._schwarz = QPen(QColor(0,0,0))
        self._weis = QPen(QColor(255, 255, 255))
        self._fg = self._schwarz
        self._fg.setWidth(3)
        self._bg = QPen(QColor(0,0,0))
        self._bg.setWidth(3)
        self._fgs = QPen(QColor(190, 190, 190))
        self._fgs.setWidth(3)
        self._sg = QColor(180, 20, 51)

        self._painter = QPainter(self)
        self._painter.setBackground(QColor(255, 255, 255))

        self._font = QFont("Arial", 20, QFont.Bold, True)

        #bordersize = 20/40mm

    def touch(self,filename)->bool:
        basedir = os.path.dirname(filename)
        if not os.path.exists(basedir):
            os.makedirs(basedir)
        try:
            with open(filename, 'a'):
                os.utime(filename, None)
        except PermissionError as e:
            entscheidung = QMessageBox.question(None,
                                                "Keine Schreibberechtigung","Keine Schreibberechtigung für Datei <br><b>{}</b><br>Bitte die Datei schließen und dann fortfahren.<br><b>Fortfahren?</b>".format(filename),
                                                QMessageBox.Yes|QMessageBox.No,QMessageBox.Yes)
            if entscheidung == QMessageBox.Yes:
                return self.touch(filename)
            else:
                return False
        else:
            return True

    def line(self, start: QPointF, ende: QPointF, shaded: int=0) -> None:
        if shaded:
            diff = 2 if isinstance(shaded,bool) and shaded == True else shaded
            self._painter.setPen(self._fgs)
            self._painter.drawLine(start + diff, ende + diff)
        self._painter.setPen(self._fg)
        self._painter.drawLine(start, ende)


    def rect(self, rect: QRectF, shaded: int=0) -> None:
        if shaded:
            diff = 6 if isinstance(shaded,bool) and shaded == True else shaded
            self._painter.setPen(self._fgs)
            rect.translate(diff, diff)
            self._painter.drawRect(rect)
            rect.translate(-diff, -diff)

        self._painter.setPen(self._bg)
        self._painter.drawRect(rect)

    def text(self, text: str, pos: QRectF, color: QColor=None, size: int=20, shaded: int=0,
             bold: bool=False,shrinkToFit=10) -> None:
        if not isinstance(text,str):
            text = "{}".format(text)

        self._font.setPointSize(size)
        if bold:
            self._font.setWeight(QFont.Black)
        else:
            self._font.setWeight(QFont.Bold)
        self._painter.setFont(self._font)

        fm = QFontMetrics(self._font)
        if pos.width() == 0:
            pos.setWidth(fm.width(text))
        if pos.height() == 0:
            pos.setHeight(fm.height())

        if size > shrinkToFit:
            #
            if fm.width(text) > pos.width() or fm.height() > pos.height()+2:
                self.text(text,pos,color,size-1,shaded,bold,shrinkToFit)
                return

        if shaded:
            diff = size//4 if isinstance(shaded,bool) and shaded == True else shaded
            self._painter.setPen(self._fgs)
            pos2 = pos.translated(diff, diff)
            self._painter.drawText(pos2, Qt.AlignCenter, text)
        p = QPen(color if color is not None else self._fg)
        self._painter.setPen(p)
        self._painter.drawText(pos, Qt.AlignCenter, text)

    def image(self, img: str, pos: QRectF, shaded: int=0):
        img = QImage(img)
        imgSize = QRectF(0, 0, img.width(), img.height())

        if shaded:
            diff = 10 if isinstance(shaded,bool) and shaded == True else shaded
            pos2 = pos.translated(diff,diff)
            self._painter.drawImage(pos2, img, imgSize, Qt.MonoOnly)
        self._painter.drawImage(pos, img)

    def table(self,
              rect: QRectF,
              lineData: list=None,
              columnCount: int=0,
              rowCount:int=0,
              w: dict=None,
              h: dict=None,
              size:int=18,
              border:bool=True) -> None:
        #lineData: [{x:1,y:2,text:"hallo"}...]
        #    oder  [{x:[1,3],y:[2,4],text."hallo"}..]

        for id in range(len(lineData)):
            if not isinstance(lineData[id], dict):
                lineData[id] = {"text": "{}".format(lineData[id])}

        if w is None:
            w = dict()
        if h is None:
            h = dict()


        #Berechne Reservierte Größen
        reserved = {"w": 0, "h": 0}

        for wr in w.values():
            reserved["w"] += wr
        for hr in h.values():
            reserved["h"] += hr

        #Berechne Zellengrößen
        marginX = 5
        marginY = 5

        remCol = columnCount - len(w)
        remRow = rowCount - len(h)

        regularWidth = (rect.width() - reserved["w"] - (columnCount + 1) * marginX) / remCol
        regularHeight = (rect.height() - reserved["h"] - (rowCount + 1) * marginY) / remRow

        def calcCellUsage() -> list:
            index = 0
            pos = []

            for column in range(columnCount):
                l = list()
                for row in range(rowCount):
                    l.append(None)
                pos.append(l)

            curX = 0
            curY = 0
            for i in lineData:
                if "x" in i.keys():
                    x = i["x"]
                    if isinstance(x, int):
                        x = range(x, x + 1)
                    elif isinstance(x, tuple):
                        x = range(x[0], x[-1] + 1)
                else:
                    x = range(curX, curX + 1)
                    i["x"] = x

                if "y" in i.keys():
                    y = i["y"]
                    if isinstance(y, int):
                        y = range(y, y + 1)
                    elif isinstance(y, tuple):
                        x = range(y[0], y[-1] + 1)
                else:
                    y = range(curY, curY + 1)

                    i["y"] = y

                curX = x[-1] + 1
                curY = y[-1]

                if curX >= columnCount:
                    curX = 0
                    curY += 1

                for xx in x:
                    for yy in y:
                        pos[xx][yy] = index
                index += 1
            return pos

        def calcWidth(col:int) -> float:
            try:
                if col in w.keys():
                    return w[col]
            except IndexError:
                pass
            return regularWidth

        def calcHeight(row:int) -> float:
            try:
                if row in h.keys():
                    return h[row]
            except IndexError:
                pass
            return regularHeight

        def calcCellSize(col:int, row: int) -> tuple:
            if col >= columnCount:
                raise IndexError
            if row >= rowCount:
                raise IndexError
            if pos[col][row] is None:
                raise IndexError

            width = calcWidth(col)
            height = calcHeight(row)

            id = pos[col][row]
            try:
                if pos[col + 1][row] is id:
                    width += calcCellSize(col + 1, row)[0] + marginX
            except IndexError:
                pass

            try:
                if pos[col][row + 1] is id:
                    height += calcCellSize(col, row + 1)[1] + marginY
            except IndexError:
                pass
            return width, height

        def calcCumulativeWidth(col: int) -> float:
            if col is 0:
                return marginX
            x = calcWidth(col - 1) + marginX + calcCumulativeWidth(col - 1)
            return x

        def calcCumulativeHeight(row: int) -> float:
            if row is 0:
                return marginY
            return calcHeight(row - 1) + marginY + calcCumulativeHeight(row - 1)

        def calcCell(index: int) -> tuple:
            x = lineData[index]["x"]
            if not isinstance(x, int):
                x = x[0]
            y = lineData[index]["y"]
            if not isinstance(y, int):
                y = y[0]

            left = rect.left() + calcCumulativeWidth(x)
            top = rect.top() + calcCumulativeHeight(y)

            d = calcCellSize(x, y)

            return left, top, d[0], d[1]

        def getFontOptions(index: int) -> dict:
            data = {
                "size": size,
                "color": self._fg,
                "shaded": False,
                "bold": False
            }

            elem = lineData[index]

            if "size" in elem.keys():
                data["size"] = elem["size"]
            if "color" in elem.keys():
                data["color"] = elem["color"]
            if "shaded" in elem.keys():
                data["shaded"] = elem["shaded"]
            if "bold" in elem.keys():
                data["bold"] = elem["bold"]
            return data

        if border:
            self.rect(rect, False)

        pos = calcCellUsage()

        for elem in range(len(lineData)):
            r = QRectF(*calcCell(elem))
            if border:
                self.rect(r, False)
            self.text(lineData[elem]["text"], r, **getFontOptions(elem))

    def end(self):
        self._painter.end()

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.end()
Beispiel #54
0
    def __init__(self, appName = "Carla2", libPrefix = None):
        object.__init__(self)

        # try to find styles dir
        stylesDir = ""

        CWDl = CWD.lower()

        if libPrefix is not None:
            stylesDir = os.path.join(libPrefix, "lib", "carla")

        elif CWDl.endswith("resources"):
            if CWDl.endswith("native-plugins%sresources" % os.sep):
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "..", "bin"))
            elif "carla-native.lv2" in sys.argv[0]:
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "lib", "lv2", "carla-native.lv2"))
            else:
                stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "lib", "carla"))

        elif CWDl.endswith("source"):
            stylesDir = os.path.abspath(os.path.join(CWD, "..", "bin"))

        if stylesDir:
            QApplication.addLibraryPath(stylesDir)

        elif not config_UseQt5:
            self._createApp(appName)
            return

        # base settings
        settings    = QSettings("falkTX", appName)
        useProTheme = settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool)

        if not useProTheme:
            self._createApp(appName)
            return

        if config_UseQt5:
            # set initial Qt stuff
            customFont = QFont("DejaVu Sans [Book]")
            customFont.setBold(False)
            customFont.setItalic(False)
            customFont.setOverline(False)
            customFont.setKerning(True)
            customFont.setHintingPreference(QFont.PreferFullHinting)
            customFont.setPixelSize(12)
            customFont.setWeight(QFont.Normal)

            QApplication.setDesktopSettingsAware(False)
            QApplication.setFont(customFont)

        # set style
        QApplication.setStyle("carla" if stylesDir else "fusion")

        # create app
        self._createApp(appName)

        if config_UseQt5:
            self.fApp.setFont(customFont)

        self.fApp.setStyle("carla" if stylesDir else "fusion")

        # set palette
        proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, "Black", type=str).lower()

        if proThemeColor == "black":
            self.fPalBlack = QPalette()
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Window, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Window, QColor(17, 17, 17))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.WindowText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.WindowText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Base, QColor(6, 6, 6))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Base, QColor(7, 7, 7))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(12, 12, 12))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(4, 4, 4))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Text, QColor(74, 74, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Text, QColor(230, 230, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Button, QColor(24, 24, 24))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Button, QColor(28, 28, 28))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(90, 90, 90))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Light, QColor(191, 191, 191))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Midlight, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Dark, QColor(129, 129, 129))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Mid, QColor(94, 94, 94))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Shadow, QColor(155, 155, 155))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Highlight, QColor(14, 14, 14))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Highlight, QColor(60, 60, 60))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Highlight, QColor(34, 34, 34))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(83, 83, 83))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(255, 255, 255))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(240, 240, 240))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.Link, QColor(34, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.Link, QColor(100, 100, 230))
            self.fPalBlack.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(74, 34, 74))
            self.fPalBlack.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(230, 100, 230))
            self.fPalBlack.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(230, 100, 230))
            self.fApp.setPalette(self.fPalBlack)

        elif proThemeColor == "blue":
            self.fPalBlue = QPalette()
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Window, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Window, QColor(37, 40, 45))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.WindowText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.WindowText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Base, QColor(48, 53, 60))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Base, QColor(55, 61, 69))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(60, 64, 67))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(69, 73, 77))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(182, 193, 208))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(42, 44, 48))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Text, QColor(96, 103, 113))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Text, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Button, QColor(51, 55, 62))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Button, QColor(59, 63, 71))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(98, 104, 114))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(210, 222, 240))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Light, QColor(59, 64, 72))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Light, QColor(63, 68, 76))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Midlight, QColor(48, 52, 59))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Midlight, QColor(51, 56, 63))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Dark, QColor(18, 19, 22))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Dark, QColor(20, 22, 25))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Mid, QColor(28, 30, 34))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Mid, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Shadow, QColor(13, 14, 16))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Shadow, QColor(15, 16, 18))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Highlight, QColor(32, 35, 39))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Highlight, QColor(14, 14, 17))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Highlight, QColor(27, 28, 33))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(89, 95, 104))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.HighlightedText, QColor(217, 234, 253))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(223, 237, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.Link, QColor(79, 100, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.Link, QColor(156, 212, 255))
            self.fPalBlue.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(51, 74, 118))
            self.fPalBlue.setColor(QPalette.Active,   QPalette.LinkVisited, QColor(64, 128, 255))
            self.fPalBlue.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(64, 128, 255))
            self.fApp.setPalette(self.fPalBlue)

        print("Using \"%s\" theme" % self.fApp.style().objectName())
Beispiel #55
0
    def populate(self, data):
        """Populate the data model using the data passed
        from the extensions object.

        The data model has up to three root-level items:
        - Invalid metadata
        - Failed to load
        - Failed dependencies
        """

        # font for use in various Items
        bold = QFont()
        bold.setWeight(QFont.Bold)

        root = self.invisibleRootItem()
        infos = data['infos']
        if infos:
            # Handle extensions with metadata errors
            infos_item = QStandardItem()
            infos_item.setFont(bold)
            infos_item.setText(_("Invalid metadata:"))
            infos_tooltip = (
                _("Extensions whose extension.cnf file has errors.\n"
                  "They will be loaded nevertheless."))
            infos_item.setToolTip(infos_tooltip)

            root.appendRow(infos_item)
            for info in infos:
                name_item = QStandardItem(info)
                name_item.setToolTip(infos_tooltip)
                icon = self.extensions.icon(info)
                if icon:
                    name_item.setIcon(icon)
                details_item = QStandardItem(infos[info])
                details_item.setToolTip(infos_tooltip)
                infos_item.appendRow([name_item, details_item])

        exceptions = data['exceptions']
        if exceptions:
            # Handle extensions that failed to load properly
            import traceback
            exceptions_item = self.exceptions_item = QStandardItem()
            exceptions_item.setFont(bold)
            exceptions_item.setText(_("Failed to load:"))
            extensions_tooltip = (
                _("Extensions that failed to load properly.\n"
                  "Double click on name to show the stacktrace.\n"
                  "Please contact the extension maintainer."))
            exceptions_item.setToolTip(extensions_tooltip)

            root.appendRow(exceptions_item)
            for ext in exceptions:
                extension_info = self.extensions.infos(ext)
                name = (extension_info.get('extension-name', ext)
                    if extension_info
                    else ext)
                name_item = QStandardItem(name)
                name_item.setToolTip(extensions_tooltip)
                icon = self.extensions.icon(ext)
                if icon:
                    name_item.setIcon(icon)
                exc_info = exceptions[ext]
                # store exception information in the first item
                name_item.exception_info = exc_info
                message = '{}: {}'.format(exc_info[0].__name__, exc_info[1])
                details_item = QStandardItem(message)
                details_item.setToolTip(extensions_tooltip)
                exceptions_item.appendRow([name_item, details_item])

        dependencies = data['dependencies']
        if dependencies:
            # Handle extensions with dependency issues
            dep_item = QStandardItem(_("Failed dependencies:"))
            dep_item.setFont(bold)
            dep_tooltip = (
                _("Extensions with failed or circular dependencies.\n"
                  "They are not loaded."))
            dep_item.setToolTip(dep_tooltip)

            root.appendRow(dep_item)
            missing = dependencies.get('missing', None)
            if missing:
                missing_item = QStandardItem(_("Missing:"))
                missing_item.setFont(bold)
                missing_item.setToolTip(dep_tooltip)
                dep_item.appendRow(missing_item)
                for m in missing:
                    item = QStandardItem(m)
                    item.setToolTip(dep_item)
                    missing_item.appendRow(item)
            inactive = dependencies.get('inactive', None)
            if inactive:
                inactive_item = QStandardItem(_("Inactive:"))
                inactive_item.setFont(bold)
                inactive_item.setToolTip(dep_tooltip)
                dep_item.appendRow(inactive_item)
                for i in inactive:
                    item = QStandardItem(i)
                    item.setToolTip(dep_tooltip)
                    inactive_item.appendRow(item)
            circular = dependencies.get('circular', None)
            if circular:
                circular_item = QStandardItem(_("Circular:"))
                circular_item.setFont(bold)
                circular_item.setToolTip(dep_tooltip)
                dep_item.appendRow(circular_item)
                item = QStandardItem(' | '.join(circular))
                item.setToolTip(dep_tooltip)
                circular_item.appendRow(item)