def initUI(self):

        saveButton = QPushButton("SAVE", self)
        clearButton = QPushButton("CLEAR", self)
        saveButton.setFont(QtGui.QFont("Calibri", 13))
        clearButton.setFont(QtGui.QFont("Calibri", 13))

        saveButton.move(100, 680)
        clearButton.move(260, 680)

        comboBoxyopass = QtWidgets.QComboBox(self)
        comboBoxyopass.addItem("SELECT")
        i = 2050
        while i >= 2000:
            comboBoxyopass.addItem(str(i))
            i -= 1
        comboBoxyopass.setMinimumHeight(35)
        comboBoxyopass.setFixedWidth(150)
        comboBoxyopass.setFont(QtGui.QFont("Calibri", 14))

        comboBoxtrcentr = QtWidgets.QComboBox(self)
        comboBoxtrcentr.addItem("SELECT CENTER")
        comboBoxtrcentr.addItem('Jaipur   ')
        comboBoxtrcentr.addItem('Hyderabad')
        comboBoxtrcentr.addItem('Raipur   ')
        comboBoxtrcentr.addItem('Lucknow  ')
        comboBoxtrcentr.addItem('Pune     ')
        comboBoxtrcentr.addItem('Vizag    ')
        comboBoxtrcentr.addItem('Bhopal   ')
        comboBoxtrcentr.addItem('Delhi    ')
        comboBoxtrcentr.setMinimumHeight(35)
        comboBoxtrcentr.setFixedWidth(180)
        comboBoxtrcentr.setFont(QtGui.QFont("Calibri", 14))

        comboBoxcourse = QtWidgets.QComboBox(self)
        comboBoxcourse.addItem("SELECT COURSE")
        comboBoxcourse.addItem('ESR    (30 Days)     ')
        comboBoxcourse.addItem('ESR    (45 Days)     ')
        comboBoxcourse.addItem('Matlab   (30 Days)   ')
        comboBoxcourse.addItem('IOT   (15 Days)      ')
        comboBoxcourse.addItem('IOT   (30 Days)      ')
        comboBoxcourse.addItem('JAVA   (30 Days)     ')
        comboBoxcourse.addItem('Python   (30 Days)   ')
        comboBoxcourse.addItem('PLC-SCADA   (30 Days)')
        comboBoxcourse.addItem('C/C++   (45 Days)    ')
        comboBoxcourse.addItem('Android   (15 Days)  ')
        comboBoxcourse.addItem('Android   (30 Days)  ')
        comboBoxcourse.setMinimumHeight(35)
        comboBoxcourse.setFixedWidth(200)
        comboBoxcourse.setFont(QtGui.QFont("Calibri", 14))

        comboBoxsem = QtWidgets.QComboBox(self)
        comboBoxsem.addItem("SELECT")
        i = 1
        while i <= 8:
            comboBoxsem.addItem(str(i))
            i += 1
        comboBoxsem.addItem("Passed Out")
        comboBoxsem.setMinimumHeight(35)
        comboBoxsem.setFixedWidth(100)
        comboBoxsem.setFont(QtGui.QFont("Calibri", 14))

        comboBoxstate = QtWidgets.QComboBox(self)
        comboBoxstate.addItem("SELECT")
        comboBoxstate.addItem('Andhra Pradesh')
        comboBoxstate.addItem('Arunachal Pradesh')
        comboBoxstate.addItem('Assam')
        comboBoxstate.addItem('Bihar')
        comboBoxstate.addItem('Goa')
        comboBoxstate.addItem('Gujarat')
        comboBoxstate.addItem('Haryana')
        comboBoxstate.addItem('Himachal Pradesh')
        comboBoxstate.addItem('Jammu & Kashmir')
        comboBoxstate.addItem('Karnataka')
        comboBoxstate.addItem('Kerala')
        comboBoxstate.addItem('Madhya Pradesh')
        comboBoxstate.addItem('Maharashtra')
        comboBoxstate.addItem('Manipur')
        comboBoxstate.addItem('Meghalaya')
        comboBoxstate.addItem('Mizoram')
        comboBoxstate.addItem('Nagaland')
        comboBoxstate.addItem('Orissa')
        comboBoxstate.addItem('Punjab')
        comboBoxstate.addItem('Rajasthan')
        comboBoxstate.addItem('Sikkim')
        comboBoxstate.addItem('Tamil Nadu')
        comboBoxstate.addItem('Tripura')
        comboBoxstate.addItem('Uttar Pradesh')
        comboBoxstate.addItem('West Bengal')
        comboBoxstate.addItem('Chhattisgarh')
        comboBoxstate.addItem('Uttarakhand')
        comboBoxstate.addItem('Jharkhand')
        comboBoxstate.addItem('Telangana')
        comboBoxstate.setMinimumHeight(35)
        comboBoxstate.setFixedWidth(250)
        comboBoxstate.setFont(QtGui.QFont("Calibri", 14))

        hboxsex = QHBoxLayout()
        hboxsex.setSpacing(60)
        r1 = QRadioButton("Male")
        r1.setFont(QtGui.QFont("Calibri", 10.5, QtGui.QFont.Bold))
        r1.setMinimumHeight(30)
        r2 = QRadioButton("Female")
        r2.setFont(QtGui.QFont("Calibri", 10.5, QtGui.QFont.Bold))
        r2.setMinimumHeight(30)
        widgetsex = QWidget(self)
        groupsex = QButtonGroup(widgetsex)
        groupsex.addButton(r1)
        groupsex.addButton(r2)
        hboxsex.addWidget(r1)
        hboxsex.addWidget(r2)
        hboxsex.addStretch()

        headerfont = QtGui.QFont("Cambria", 13, QtGui.QFont.Bold)
        saveloc = str("Student_List.xlsx")

        l1 = QLabel("Name: ")
        l1.setFont(headerfont)
        l1.setMinimumHeight(30)
        l1.setFixedWidth(180)
        text1 = QLineEdit()
        text1.setFixedWidth(600)
        text1.setMinimumHeight(30)
        text1.setFont(QtGui.QFont("Times", 11))

        l2 = QLabel("Email Id: ")
        l2.setFont(headerfont)
        l2.setMinimumHeight(30)
        l2.setFixedWidth(180)
        text2 = QLineEdit()
        text2.setFixedWidth(600)
        text2.setMinimumHeight(30)
        text2.setFont(QtGui.QFont("Times", 11))

        l3 = QLabel("Contact No.: ")
        l3.setFont(headerfont)
        l3.setMinimumHeight(30)
        l3.setFixedWidth(180)
        text3 = QLineEdit()
        text3.setFixedWidth(600)
        text3.setMinimumHeight(30)
        text3.setFont(QtGui.QFont("Times", 11))

        l4 = QLabel("City: ")
        l4.setFont(headerfont)
        l4.setMinimumHeight(30)
        l4.setFixedWidth(180)
        text4 = QLineEdit()
        text4.setFixedWidth(600)
        text4.setMinimumHeight(30)
        text4.setFont(QtGui.QFont("Times", 11))

        l5 = QLabel("State: ")
        l5.setFont(headerfont)
        l5.setMinimumHeight(30)
        l5.setFixedWidth(180)

        l6 = QLabel("College: ")
        l6.setFont(headerfont)
        l6.setMinimumHeight(30)
        l6.setFixedWidth(180)
        text6 = QLineEdit()
        text6.setFixedWidth(600)
        text6.setMinimumHeight(30)
        text6.setFont(QtGui.QFont("Times", 11))

        l7 = QLabel("Branch: ")
        l7.setFont(headerfont)
        l7.setMinimumHeight(30)
        l7.setFixedWidth(180)
        text7 = QLineEdit()
        text7.setFixedWidth(600)
        text7.setMinimumHeight(30)
        text7.setFont(QtGui.QFont("Times", 11))

        l8 = QLabel("Semester: ")
        l8.setFont(headerfont)
        l8.setMinimumHeight(30)
        l8.setFixedWidth(180)

        l9 = QLabel("Year Of Passing: ")
        l9.setFont(headerfont)
        l9.setFixedWidth(180)

        l10 = QLabel("Course: ")
        l10.setFont(headerfont)
        l10.setMinimumHeight(30)
        l10.setFixedWidth(180)

        l11 = QLabel("Batch: ")
        l11.setFont(headerfont)
        l11.setMinimumHeight(30)
        l11.setFixedWidth(180)
        text11 = QLineEdit()
        text11.setFixedWidth(600)
        text11.setMinimumHeight(30)
        text11.setFont(QtGui.QFont("Times", 11))

        l12 = QLabel("Training Center: ")
        l12.setFont(headerfont)
        l12.setMinimumHeight(30)
        l12.setFixedWidth(180)

        l13 = QLabel("SEX: ")
        l13.setFont(headerfont)
        l13.setFixedWidth(180)

        l14 = QLabel("Save File As: ")
        l14.setFont(headerfont)
        l14.setMinimumHeight(30)
        l14.setFixedWidth(180)
        text14 = QLineEdit()
        text14.setFixedWidth(600)
        text14.setMinimumHeight(30)
        text14.setFont(QtGui.QFont("Times", 11, QtGui.QFont.Bold))
        text14.setText(saveloc)

        l15 = QLabel("Query/Regarding What: ")
        l15.setFont(QtGui.QFont("Cambria", 12, QtGui.QFont.Bold))
        l15.setMinimumHeight(30)
        l15.setFixedWidth(200)
        text15 = QLineEdit()
        text15.setFixedWidth(600)
        text15.setMinimumHeight(30)
        text15.setFont(QtGui.QFont("Times", 11))

        hboxcourse = QHBoxLayout()
        hboxcourse.setSpacing(25)
        l16 = QLabel("Others: ")
        l16.setFont(headerfont)
        l16.setMinimumHeight(30)
        l16.setFixedWidth(100)
        text16 = QLineEdit()
        text16.setFixedWidth(250)
        text16.setMinimumHeight(30)
        text16.setFont(QtGui.QFont("Times", 11))
        hboxcourse.addWidget(comboBoxcourse)
        hboxcourse.addWidget(l16)
        hboxcourse.addWidget(text16)
        hboxcourse.addStretch()

        hboxstate = QHBoxLayout()
        hboxstate.setSpacing(25)
        l17 = QLabel("Others: ")
        l17.setFont(headerfont)
        l17.setMinimumHeight(30)
        l17.setFixedWidth(70)
        text17 = QLineEdit()
        text17.setFixedWidth(230)
        text17.setMinimumHeight(30)
        text17.setFont(QtGui.QFont("Times", 11))
        hboxstate.addWidget(comboBoxstate)
        hboxstate.addWidget(l17)
        hboxstate.addWidget(text17)
        hboxstate.addStretch()

        fbox = QFormLayout()
        fbox.setVerticalSpacing(10)

        fbox.addRow(l1, text1)
        fbox.addRow(l2, text2)
        fbox.addRow(l3, text3)
        fbox.addRow(l4, text4)
        fbox.addRow(l5, hboxstate)
        fbox.addRow(l6, text6)
        fbox.addRow(l7, text7)
        fbox.addRow(l8, comboBoxsem)
        fbox.addRow(l9, comboBoxyopass)
        fbox.addRow(l10, hboxcourse)
        fbox.addRow(l11, text11)
        fbox.addRow(l12, comboBoxtrcentr)

        l18 = QLabel("Training Session: ")
        l18.setFont(headerfont)
        l18.setMinimumHeight(30)
        l18.setFixedWidth(200)

        hboxperiod = QHBoxLayout()
        hboxperiod.setSpacing(70)
        r3 = QRadioButton("Summer Training")
        r3.setFont(QtGui.QFont("Calibri", 10, QtGui.QFont.Bold))
        r3.setMinimumHeight(30)
        r4 = QRadioButton("Winter Training")
        r4.setFont(QtGui.QFont("Calibri", 10, QtGui.QFont.Bold))
        r4.setMinimumHeight(30)
        r5 = QRadioButton("Project Based")
        r5.setFont(QtGui.QFont("Calibri", 10, QtGui.QFont.Bold))
        r5.setMinimumHeight(30)
        r6 = QRadioButton("Other")
        r6.setFont(QtGui.QFont("Calibri", 10, QtGui.QFont.Bold))
        r6.setMinimumHeight(30)
        widgetperiod = QWidget(self)
        groupperiod = QButtonGroup(widgetperiod)
        groupperiod.addButton(r3)
        groupperiod.addButton(r4)
        groupperiod.addButton(r5)
        groupperiod.addButton(r6)
        hboxperiod.addWidget(r3)
        hboxperiod.addWidget(r4)
        hboxperiod.addWidget(r5)
        hboxperiod.addWidget(r6)
        hboxperiod.addStretch()
        fbox.addRow(l18, hboxperiod)
        fbox.addRow(l13, hboxsex)
        fbox.addRow(l15, text15)
        fbox.addRow(l14, text14)

        self.lineedits = [
            text1, text2, text3, text4, text6, text7, text11, text14, text15,
            text16, text17
        ]
        self.saveedit = [text14]
        self.comboBox = [
            comboBoxstate, comboBoxsem, comboBoxyopass, comboBoxtrcentr,
            comboBoxcourse
        ]
        self.radiobutton = [r1, r2, r3, r4, r5, r6]
        saveButton.clicked.connect(self.saveClicked)
        clearButton.clicked.connect(self.clearClicked)

        self.setLayout(fbox)

        try:
            self.setWindowState(QtCore.Qt.WindowMaximized)
        except:
            self.setGeometry(10, 30, 1350, 750)

        self.setWindowTitle('Managemet System Software ')
        self.setWindowIcon(
            QIcon('logso.png'))  # Enter your Icon Image url here
        oImage = QImage("image2.jpg")  # Enter your Background Image url here
        sImage = oImage.scaled(QSize(1350, 750))
        palette = QPalette()
        palette.setBrush(10, QBrush(sImage))
        self.setPalette(palette)
        self.show()
Пример #2
0
    def update_io(self):
        inputs_header_text = _("Inputs") + ' (%d)' % len(self.tx.inputs())
        if not self.finalized:
            selected_coins = self.main_window.get_manually_selected_coins()
            if selected_coins is not None:
                inputs_header_text += f"  -  " + _(
                    "Coin selection active ({} UTXOs selected)").format(
                        len(selected_coins))
        self.inputs_header.setText(inputs_header_text)
        ext = QTextCharFormat()
        rec = QTextCharFormat()
        rec.setBackground(QBrush(ColorScheme.GREEN.as_color(background=True)))
        rec.setToolTip(_("Wallet receive address"))
        chg = QTextCharFormat()
        chg.setBackground(QBrush(ColorScheme.YELLOW.as_color(background=True)))
        chg.setToolTip(_("Wallet change address"))
        twofactor = QTextCharFormat()
        twofactor.setBackground(
            QBrush(ColorScheme.BLUE.as_color(background=True)))
        twofactor.setToolTip(
            _("TrustedCoin (2FA) fee for the next batch of transactions"))

        def text_format(addr):
            if self.wallet.is_mine(addr):
                return chg if self.wallet.is_change(addr) else rec
            elif self.wallet.is_billing_address(addr):
                return twofactor
            return ext

        def format_amount(amt):
            return self.main_window.format_amount(amt, whitespaces=True)

        i_text = self.inputs_textedit
        i_text.clear()
        i_text.setFont(QFont(MONOSPACE_FONT))
        i_text.setReadOnly(True)
        cursor = i_text.textCursor()
        for txin in self.tx.inputs():
            if txin.is_coinbase_input():
                cursor.insertText('coinbase')
            else:
                prevout_hash = txin.prevout.txid.hex()
                prevout_n = txin.prevout.out_idx
                cursor.insertText(prevout_hash + ":%-4d " % prevout_n, ext)
                addr = self.wallet.get_txin_address(txin)
                if addr is None:
                    addr = ''
                cursor.insertText(addr, text_format(addr))
                if isinstance(
                        txin,
                        PartialTxInput) and txin.value_sats() is not None:
                    cursor.insertText(format_amount(txin.value_sats()), ext)
            cursor.insertBlock()

        self.outputs_header.setText(
            _("Outputs") + ' (%d)' % len(self.tx.outputs()))
        o_text = self.outputs_textedit
        o_text.clear()
        o_text.setFont(QFont(MONOSPACE_FONT))
        o_text.setReadOnly(True)
        cursor = o_text.textCursor()
        for o in self.tx.outputs():
            addr, v = o.get_ui_address_str(), o.value
            cursor.insertText(addr, text_format(addr))
            if v is not None:
                cursor.insertText('\t', ext)
                cursor.insertText(format_amount(v), ext)
            cursor.insertBlock()
Пример #3
0
    def showWedge(self,
                  angle,
                  color,
                  extended=False,
                  rev_gradient=False,
                  outline_only=False):
        """Summary

        Args:
            angle (TYPE): Description
            color (TYPE): Description
            extended (bool, optional): Description
            rev_gradient (bool, optional): Description
            outline_only (bool, optional): Description
        """
        # Hack to keep wedge in front
        # self.setRotation(self.pre_xover_item_group.rotation())

        self._last_params = (angle, color, extended, rev_gradient,
                             outline_only)
        radius = self._radius
        span = self.pre_xover_item_group.partCrossoverSpanAngle() / 2
        radius_adjusted = radius + (_WEDGE_RECT_GAIN / 2)

        tip = QPointF(radius_adjusted, radius_adjusted)
        EXT = 1.35 if extended else 1.0

        # print("wtf", tip, pos)
        base_p2 = QPointF(1, 1)

        line0 = QLineF(tip, QPointF(base_p2))
        line1 = QLineF(tip, QPointF(base_p2))
        line2 = QLineF(tip, QPointF(base_p2))

        quad_scale = 1 + (.22 *
                          (span - 5) / 55)  # lo+(hi-lo)*(val-min)/(max-min)
        line0.setLength(radius_adjusted * EXT *
                        quad_scale)  # for quadTo control point
        line1.setLength(radius_adjusted * EXT)
        line2.setLength(radius_adjusted * EXT)
        line0.setAngle(angle)
        line1.setAngle(angle - span)
        line2.setAngle(angle + span)

        path = QPainterPath()

        if outline_only:
            self.setPen(getPenObj(color, 0.5, alpha=128, capstyle=Qt.RoundCap))
            path.moveTo(line1.p2())
            path.quadTo(line0.p2(), line2.p2())
        else:
            gradient = QRadialGradient(tip, radius_adjusted * EXT)
            color1 = getColorObj(color, alpha=80)
            color2 = getColorObj(color, alpha=0)
            if rev_gradient:
                color1, color2 = color2, color1

            if extended:
                gradient.setColorAt(0, color1)
                gradient.setColorAt(radius_adjusted / (radius_adjusted * EXT),
                                    color1)
                gradient.setColorAt(
                    radius_adjusted / (radius_adjusted * EXT) + 0.01, color2)
                gradient.setColorAt(1, color2)
            else:
                gradient.setColorAt(0, getColorObj(color, alpha=50))
            brush = QBrush(gradient)
            self.setBrush(brush)

            path.moveTo(line1.p1())
            path.lineTo(line1.p2())
            path.quadTo(line0.p2(), line2.p2())
            path.lineTo(line2.p1())

        self.setPath(path)
        self.show()
Пример #4
0
class VirtualHelixItem(QGraphicsEllipseItem):
    """
    The VirtualHelixItem is an individual circle that gets drawn in the SliceView
    as a child of the PartItem. Taken as a group, many SliceHelix
    instances make up the crossection of the DNAPart. Clicking on a SliceHelix
    adds a VirtualHelix to the DNAPart. The SliceHelix then changes appearence
    and paints its corresponding VirtualHelix number.
    """
    # set up default, hover, and active drawing styles
    _USE_BRUSH = QBrush(styles.ORANGE_FILL)
    _USE_PEN = QPen(styles.ORANGE_STROKE, styles.SLICE_HELIX_STROKE_WIDTH)
    _RADIUS = styles.SLICE_HELIX_RADIUS
    _OUT_OF_SLICE_PEN = QPen(styles.LIGHT_ORANGE_STROKE,\
                         styles.SLICE_HELIX_STROKE_WIDTH)
    _OUT_OF_SLICE_BRUSH = QBrush(styles.LIGHT_ORANGE_FILL)
    _RECT = QRectF(0, 0, 2 * _RADIUS, 2 * _RADIUS)
    _FONT = styles.SLICE_NUM_FONT
    _ZVALUE = styles.ZSLICEHELIX+3

    def __init__(self, model_virtual_helix, empty_helix_item):
        """
        empty_helix_item is a EmptyHelixItem that will act as a QGraphicsItem parent
        """
        super(VirtualHelixItem, self).__init__(parent=empty_helix_item)
        self._virtual_helix = model_virtual_helix
        self._empty_helix_item = empty_helix_item
        self.hide()
        # drawing related

        self.isHovered = False
        self.setAcceptHoverEvents(True)
        # self.setFlag(QGraphicsItem.ItemIsSelectable)
        self.setZValue(self._ZVALUE)
        self.lastMousePressAddedBases = False

        self.setBrush(self._OUT_OF_SLICE_BRUSH)
        self.setPen(self._OUT_OF_SLICE_PEN)
        self.setRect(self._RECT)

        # handle the label specific stuff
        self._label = self.createLabel()
        self.setNumber()
        self._pen1, self._pen2 = (QPen(), QPen())
        self.createArrows()

        self._controller = VirtualHelixItemController(self, model_virtual_helix)

        self.show()
    # end def

    ### SIGNALS ###

    ### SLOTS ###
    def virtualHelixNumberChangedSlot(self, virtualHelix):
        """
        receives a signal containing a virtualHelix and the oldNumber 
        as a safety check
        """
        self.setNumber()
    # end def

    def virtualHelixRemovedSlot(self, virtualHelix):
        self._controller.disconnectSignals()
        self._controller = None
        self._empty_helix_item.setNotHovered()
        self._virtual_helix = None
        self._empty_helix_item = None
        self.scene().removeItem(self._label)
        self._label = None
        self.scene().removeItem(self)
    # end def

    def strandAddedSlot(self, sender, strand):
        pass
    # end def

    def createLabel(self):
        label = QGraphicsSimpleTextItem("%d" % self._virtual_helix.number())
        label.setFont(self._FONT)
        label.setZValue(self._ZVALUE)
        label.setParentItem(self)
        return label
    # end def

    def createArrows(self):
        rad = self._RADIUS
        pen1 = self._pen1
        pen2 = self._pen2
        pen1.setWidth(3)
        pen2.setWidth(3)
        pen1.setBrush(Qt.gray)
        pen2.setBrush(Qt.lightGray)
        if self._virtual_helix.isEvenParity():
            arrow1 = QGraphicsLineItem(rad, rad, 2*rad, rad, self)
            arrow2 = QGraphicsLineItem(0, rad, rad, rad, self)
        else:
            arrow1 = QGraphicsLineItem(0, rad, rad, rad, self)
            arrow2 = QGraphicsLineItem(rad, rad, 2*rad, rad, self)
        arrow1.setTransformOriginPoint(rad, rad)
        arrow2.setTransformOriginPoint(rad, rad)
        arrow1.setZValue(400)
        arrow2.setZValue(400)
        arrow1.setPen(pen1)
        arrow2.setPen(pen2)
        self.arrow1 = arrow1
        self.arrow2 = arrow2
        self.arrow1.hide()
        self.arrow2.hide()
    # end def

    def updateScafArrow(self, idx):
        scafStrand = self._virtual_helix.scaf(idx)
        if scafStrand:
            scafStrandColor = QColor(scafStrand.oligo().color())
            scafAlpha = 0.9 if scafStrand.hasXoverAt(idx) else 0.3
        else:
            scafStrandColor = QColor(Qt.gray)
            scafAlpha = 0.1
        scafStrandColor.setAlphaF(scafAlpha)
        self._pen1.setBrush(scafStrandColor)
        self.arrow1.setPen(self._pen1)
        part = self.part()
        tpb = part._TWIST_PER_BASE
        angle = idx*tpb
        # for some reason rotation is CW and not CCW with increasing angle
        self.arrow1.setRotation(angle + part._TWIST_OFFSET)

    def updateStapArrow(self, idx):
        stapStrand = self._virtual_helix.stap(idx)
        if stapStrand:
            stapStrandColor = QColor(stapStrand.oligo().color()) 
            stapAlpha = 0.9 if stapStrand.hasXoverAt(idx) else 0.3
        else:
            stapStrandColor = QColor(Qt.lightGray)
            stapAlpha = 0.1
        stapStrandColor.setAlphaF(stapAlpha)
        self._pen2.setBrush(stapStrandColor)
        self.arrow2.setPen(self._pen2)
        part = self.part()
        tpb = part._TWIST_PER_BASE
        angle = idx*tpb
        self.arrow2.setRotation(angle + part._TWIST_OFFSET)
    # end def

    def setNumber(self):
        """docstring for setNumber"""
        vh = self._virtual_helix
        num = vh.number()
        label = self._label
        radius = self._RADIUS

        if num != None:
            label.setText("%d" % num)
        else:
            return

        y_val = radius / 3
        if num < 10:
            label.setPos(radius / 1.5, y_val)
        elif num < 100:
            label.setPos(radius / 3, y_val)
        else: # _number >= 100
            label.setPos(0, y_val)
        b_rect = label.boundingRect()
        posx = b_rect.width()/2
        posy = b_rect.height()/2
        label.setPos(radius-posx, radius-posy)
    # end def

    def part(self):
        return self._empty_helix_item.part()

    def virtualHelix(self):
        return self._virtual_helix
    # end def

    def number(self):
        return self.virtualHelix().number()

    def setActiveSliceView(self, idx, has_scaf, has_stap):
        if has_scaf:
            self.setPen(self._USE_PEN)
            self.setBrush(self._USE_BRUSH)
            self.updateScafArrow(idx)
            self.arrow1.show()
        else:
            self.setPen(self._OUT_OF_SLICE_PEN)
            self.setBrush(self._OUT_OF_SLICE_BRUSH)
            self.arrow1.hide()
        if has_stap:
            self.updateStapArrow(idx)
            self.arrow2.show()
        else:
            self.arrow2.hide()
    # end def

    ############################ User Interaction ############################
    def sceneEvent(self, event):
        """Included for unit testing in order to grab events that are sent
        via QGraphicsScene.sendEvent()."""
        # if self._parent.sliceController.testRecorder:
        #     coord = (self._row, self._col)
        #     self._parent.sliceController.testRecorder.sliceSceneEvent(event, coord)
        if event.type() == QEvent.MouseButtonPress:
            self.mousePressEvent(event)
            return True
        elif event.type() == QEvent.MouseButtonRelease:
            self.mouseReleaseEvent(event)
            return True
        elif event.type() == QEvent.MouseMove:
            self.mouseMoveEvent(event)
            return True
        QGraphicsItem.sceneEvent(self, event)
        return False

    def hoverEnterEvent(self, event):
        """
        If the selection is configured to always select
        everything, we don't draw a focus ring around everything,
        instead we only draw a focus ring around the hovered obj.
        """
        # if self.selectAllBehavior():
        #     self.setSelected(True)
        # forward the event to the empty_helix_item as well
        self._empty_helix_item.hoverEnterEvent(event)
    # end def

    def hoverLeaveEvent(self, event):
        # if self.selectAllBehavior():
        #     self.setSelected(False)
        self._empty_helix_item.hoverEnterEvent(event)
Пример #5
0
 def _create_rubber_band(self):
     rubber_band = QRubberBand(QRubberBand.Rectangle, self.label_image)
     pal = QPalette()
     pal.setBrush(QPalette.Highlight, QBrush(Qt.red))
     rubber_band.setPalette(pal)
     return rubber_band
Пример #6
0
 def set_main_background(self):
     palette = QPalette()
     pixmap = QPixmap("assets/main_background.jpg")
     brush = QBrush(pixmap)
     palette.setBrush(QPalette.Background, brush)
     self.setPalette(palette)
Пример #7
0
    "int": lambda v: v.toInt()[0],
    "double": lambda v: v.toDouble()[0],
    "char": lambda v: v.toChar(),
    "QByteArray": lambda v: v.toByteArray(),
    "QPoint": lambda v: v.toPoint(),
    "QPointF": lambda v: v.toPointF(),
    "QSize": lambda v: v.toSize(),
    "QLine": lambda v: v.toLine(),
    "QStringList": lambda v: v.toStringList(),
    "QTime": lambda v: v.toTime(),
    "QDateTime": lambda v: v.toDateTime(),
    "QDate": lambda v: v.toDate(),
    "QLocale": lambda v: v.toLocale(),
    "QUrl": lambda v: v.toUrl(),
    "QRect": lambda v: v.toRect(),
    "QBrush": lambda v: QBrush(v),
    "QFont": lambda v: QFont(v),
    "QPalette": lambda v: QPalette(v),
    "QPixmap": lambda v: QPixmap(v),
    "QImage": lambda v: QImage(v),
    "bool": lambda v: v.toBool(),
    "QObject*": lambda v: wrap_variant_object(v),
    "QWidget*": lambda v: wrap_variant_object(v),
    "ActionMap": lambda v: int(v.count())
}


def wrap_variant_object(variant):
    """
    convert a QObject or a QWidget to its wrapped superclass
    """
Пример #8
0
    def initUi(self):
        self.setFixedSize(400, 200)                      # 创建固定窗口大小         # 窗口标题
        self.setWindowFlags(Qt.FramelessWindowHint)      # 设置窗口无边框
        self.setWindowIcon(QIcon(':/logo.png')) 

        window_pale = QPalette()                           # 创建窗口背景图片对象
        window_pale.setBrush(self.backgroundRole(),\
                QBrush(QPixmap("UI/image/login.jpg")))        # 按指定路径找到图片
        self.setPalette(window_pale)

        pee = QPalette()                                  # 设置程序显示名的颜色
        pee.setColor(QPalette.WindowText,Qt.white)
        colo = QPalette()                                    #设置普通文字的颜色
        colo.setColor(QPalette.WindowText,Qt.red)
        
        if self.error == 'normal':
            self.lbl_main = QLabel('货运信息公共平台', self)    #设置程序的名字
            self.lbl_main.setPalette(pee)
        elif self.error == 'NetworkConnectIonisFailed':
            self.lbl_main = QLabel('*网络连接失败*', self)    #设置程序的名字
            self.lbl_main.setPalette(colo)
        self.lbl_main.move(10, 10)

        pe = QPalette()                                    #设置普通文字的颜色
        pe.setColor(QPalette.WindowText,Qt.gray)
        lucency = "background:transparent;border-width:\
                0;border-style:outset"

        self.lbl_user = QLabel('账号:', self)                 # 创建一个标题用户名标题
        self.lbl_user.move(110, 55)
        self.lbl_user.setPalette(pe)
        
        self.Edit_user = QLineEdit(self)                       # 创建一个用户名输入框对象
        self.Edit_user.setGeometry(150, 45, 140, 30)           # 设置输入框的位置大小
        self.Edit_user.setPlaceholderText('手机号码')           # 悬浮显示提示信息
        self.Edit_user.setStyleSheet(lucency)                  # 透明输入框                      # 无边框设置
        self.Edit_user.setValidator(QRegExpValidator\
                    (QRegExp("[0-9]+"),self))                  # 限制用户输入信息的类型
        self.Edit_user.setMaxLength(11)                        # 输入框中的信息最大长度11
        self.Edit_user.setToolTip('用户名只能为11位的电话号码')  # 输入框的提示语句
        
        self.lbl_password = QLabel('密码:', self)               # 创建密码标签
        self.lbl_password.move(110, 90)
        self.lbl_password.setPalette(pe)

        self.Edit_password = QLineEdit(self)                   # 创建密码输入框
        self.Edit_password.setGeometry(150, 80, 140, 30)
        self.Edit_password.setPlaceholderText('密码')
        self.Edit_password.setStyleSheet(lucency)
        self.Edit_password.setValidator(QRegExpValidator\
                            (QRegExp("[A-Za-z0-9]+"),self))
        self.Edit_password.setEchoMode(QLineEdit.Password)     #隐藏显示密码为圆点
        self.Edit_password.setMaxLength(16)
        self.Edit_password.setToolTip('用户密码最大长度为16位')
        
        # 设置按键背景和悬停的属性变量
        color = "QPushButton{border:none;color:rgb(55, 255, 255);}"\
            "QPushButton:hover{border:none;color:rgb(255, 255, 255);}"
        color2 = "QPushButton{border:none;}"\
                "QPushButton:hover{border-image:\
                url(%s);border:none;}"

        self.button_register = QPushButton('注册', self)      # 创建注册按钮对象
        self.button_register.setGeometry(76, 160, 70, 28)
        self.button_register.setStyleSheet(color)             # 给按钮添加属性

        self.button_lose = QPushButton('忘记密码', self)       # 创建忘记密码按钮对象
        self.button_lose.setGeometry(250, 160, 70, 28)
        self.button_lose.setStyleSheet(color)

        self.button_login = QPushButton(' ', self)             # 创建登陆按钮对象
        self.button_login.setGeometry(88, 130, 230, 26)
        self.button_login.setStyleSheet(color2 % 'UI/image/login1.png')
        
        self.button_little = QPushButton(' ', self)            # 创建最小化按钮对象
        self.button_little.setGeometry(336, 0, 32, 25)
        self.button_little.setToolTip('最小化')
        self.button_little.setStyleSheet(color2 % 'UI/image/login3.png')
        
        self.button_close = QPushButton(' ', self)             # 创建关闭按钮对象
        self.button_close.setGeometry(368, 0, 32, 25)
        self.button_close.setToolTip('关闭')
        self.button_close.setStyleSheet(color2 % 'UI/image/login2.png')
        
        self.centralwidget = QWidget(self)                     # 创建一个QWidget窗口对象
        self.centralwidget.setGeometry(317, 40, 100, 40)       # 设置对象的大小位置
        self.gridLayout = QGridLayout(self.centralwidget)      # 在self.centralwidget窗口中添加一个布局
        self.centralwidget2 = QWidget(self)
        self.centralwidget2.setGeometry(317, 76, 100, 40)
        self.gridLayout2 = QGridLayout(self.centralwidget2)
        
        screen = self.frameGeometry()                           # 窗口居中显示
        wall = QDesktopWidget().availableGeometry().center()
        screen.moveCenter(wall)
        self.move(screen.topLeft())

        self.button_little.clicked.connect(self.showMinimized)   # 为按键添加信号事件
        self.button_close.clicked.connect(self.close_quit)
    
        self.Edit_user.installEventFilter(self)                  # 定义对象获取焦点事件
        self.Edit_password.installEventFilter(self)
Пример #9
0
    def data(self, index: QModelIndex, role: Qt.ItemDataRole) -> QVariant:
        # note: this method is performance-critical.
        # it is called a lot, and so must run extremely fast.
        assert index.isValid()
        col = index.column()
        tx_item = self.transactions.value_from_pos(index.row())
        is_lightning = tx_item.get('lightning', False)
        timestamp = tx_item['timestamp']
        if is_lightning:
            status = 0
            txpos = tx_item['txpos']
            if timestamp is None:
                status_str = 'unconfirmed'
            else:
                status_str = format_time(int(timestamp))
        else:
            tx_hash = tx_item['txid']
            conf = tx_item['confirmations']
            txpos = tx_item['txpos_in_block'] or 0
            height = tx_item['height']
            try:
                status, status_str = self.tx_status_cache[tx_hash]
            except KeyError:
                tx_mined_info = self.tx_mined_info_from_tx_item(tx_item)
                status, status_str = self.parent.wallet.get_tx_status(
                    tx_hash, tx_mined_info)

        # we sort by timestamp
        if timestamp is None:
            timestamp = float("inf")

        if role == Qt.UserRole:
            # for sorting
            d = {
                HistoryColumns.STATUS:
                    # height breaks ties for unverified txns
                    # txpos breaks ties for verified same block txns
                    (-timestamp, conf, -status, -height, -txpos) if not is_lightning else (-timestamp, 0,0,0,-txpos),
                HistoryColumns.DESCRIPTION:
                    tx_item['label'] if 'label' in tx_item else None,
                HistoryColumns.AMOUNT:
                    (tx_item['bc_value'].value if 'bc_value' in tx_item else 0)\
                    + (tx_item['ln_value'].value if 'ln_value' in tx_item else 0),
                HistoryColumns.BALANCE:
                    (tx_item['balance'].value if 'balance' in tx_item else 0)\
                    + (tx_item['balance_msat']//1000 if 'balance_msat'in tx_item else 0),
                HistoryColumns.FIAT_VALUE:
                    tx_item['fiat_value'].value if 'fiat_value' in tx_item else None,
                HistoryColumns.FIAT_ACQ_PRICE:
                    tx_item['acquisition_price'].value if 'acquisition_price' in tx_item else None,
                HistoryColumns.FIAT_CAP_GAINS:
                    tx_item['capital_gain'].value if 'capital_gain' in tx_item else None,
                HistoryColumns.TXID: tx_hash if not is_lightning else None,
            }
            return QVariant(d[col])
        if role not in (Qt.DisplayRole, Qt.EditRole):
            if col == HistoryColumns.STATUS and role == Qt.DecorationRole:
                icon = "lightning" if is_lightning else TX_ICONS[status]
                return QVariant(read_QIcon(icon))
            elif col == HistoryColumns.STATUS and role == Qt.ToolTipRole:
                msg = 'lightning transaction' if is_lightning else str(
                    conf) + _(" confirmation" + ("s" if conf != 1 else ""))
                return QVariant(msg)
            elif col > HistoryColumns.DESCRIPTION and role == Qt.TextAlignmentRole:
                return QVariant(Qt.AlignRight | Qt.AlignVCenter)
            elif col != HistoryColumns.STATUS and role == Qt.FontRole:
                monospace_font = QFont(MONOSPACE_FONT)
                return QVariant(monospace_font)
            #elif col == HistoryColumns.DESCRIPTION and role == Qt.DecorationRole and not is_lightning\
            #        and self.parent.wallet.invoices.paid.get(tx_hash):
            #    return QVariant(read_QIcon("seal"))
            elif col in (HistoryColumns.DESCRIPTION, HistoryColumns.AMOUNT) \
                    and role == Qt.ForegroundRole and not is_lightning and tx_item['value'].value < 0:
                red_brush = QBrush(QColor("#BC1E1E"))
                return QVariant(red_brush)
            elif col == HistoryColumns.FIAT_VALUE and role == Qt.ForegroundRole \
                    and not tx_item.get('fiat_default') and tx_item.get('fiat_value') is not None:
                blue_brush = QBrush(QColor("#1E1EFF"))
                return QVariant(blue_brush)
            return QVariant()
        if col == HistoryColumns.STATUS:
            return QVariant(status_str)
        elif col == HistoryColumns.DESCRIPTION and 'label' in tx_item:
            return QVariant(tx_item['label'])
        elif col == HistoryColumns.AMOUNT:
            bc_value = tx_item['bc_value'].value if 'bc_value' in tx_item else 0
            ln_value = tx_item['ln_value'].value if 'ln_value' in tx_item else 0
            value = bc_value + ln_value
            v_str = self.parent.format_amount(value,
                                              is_diff=True,
                                              whitespaces=True)
            return QVariant(v_str)
        elif col == HistoryColumns.BALANCE:
            balance = tx_item['balance'].value
            balance_str = self.parent.format_amount(balance, whitespaces=True)
            return QVariant(balance_str)
        elif col == HistoryColumns.FIAT_VALUE and 'fiat_value' in tx_item:
            value_str = self.parent.fx.format_fiat(tx_item['fiat_value'].value)
            return QVariant(value_str)
        elif col == HistoryColumns.FIAT_ACQ_PRICE and \
                tx_item['value'].value < 0 and 'acquisition_price' in tx_item:
            # fixme: should use is_mine
            acq = tx_item['acquisition_price'].value
            return QVariant(self.parent.fx.format_fiat(acq))
        elif col == HistoryColumns.FIAT_CAP_GAINS and 'capital_gain' in tx_item:
            cg = tx_item['capital_gain'].value
            return QVariant(self.parent.fx.format_fiat(cg))
        elif col == HistoryColumns.TXID:
            return QVariant(tx_hash)
        return QVariant()
Пример #10
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)

        # a = self.lineEdit.text()  # 获取单行输入框内的值
        # self.textEdit.setText('1213')  # 将单行输入框内的值,显示到多长输入框内\
        # self.lineEdit.setText('2323')
        # self.comboBox.addItem("男")
        # self.comboBox.addItem("女")
        # b=("1","2")
        # self.comboBox.addItem(b)

        # horizontalHeader = ["编号1", "姓名1", "性别1", "年龄1", "职业1"]
        Col = self.table.setColumnCount(5)
        Row = self.table.setRowCount(100)

        # self.table.setHorizontalHeaderLabels(horizontalHeader)
        self.table.setEditTriggers(QTableWidget.NoEditTriggers)
        self.table.setSelectionBehavior(QTableWidget.SelectColumns)
        self.table.setSelectionMode(QTableWidget.SingleSelection)

        for index in range(self.table.columnCount()):
            headItem = self.table.horizontalHeaderItem(index)
            headItem.setFont(QFont("song", 12, QFont.Bold))
            headItem.setForeground(QBrush(Qt.gray))
            headItem.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter)

        self.table.setColumnWidth(4, 100)
        self.table.setRowHeight(0, 40)

        for i in range(20):

            self.table.setItem(i, 0, QTableWidgetItem('00' + str(i + 1)))
            self.table.setItem(i, 1, QTableWidgetItem("刘亦菲"))
            genderComb = QComboBox()
            genderComb.addItem("男")
            genderComb.addItem("女")
            genderComb.setCurrentIndex(1)
            self.table.setCellWidget(i, 2, genderComb)
            self.table.setItem(i, 3, QTableWidgetItem("30"))
            self.table.setItem(i, 4, QTableWidgetItem("演员"))

        # self.table.setItem(1, 0, QTableWidgetItem("002"))
        # self.table.setItem(1, 1, QTableWidgetItem("马云"))
        # genderComb = QComboBox()
        # genderComb.addItem("男")
        # genderComb.addItem("女")
        # genderComb.setCurrentIndex(0)
        # self.table.setCellWidget(1, 2, genderComb)
        # self.table.setItem(1, 3, QTableWidgetItem("50"))
        # self.table.setItem(1, 4, QTableWidgetItem("企业家"))

        row_count = self.table.rowCount()
        self.table.insertRow(row_count)
        mainLayout = QHBoxLayout()
        mainLayout.addWidget(self.table)
        self.setLayout(mainLayout)

        # self.resize(600, 280)
        # self.center()
        self.setWindowTitle("TableWidget Excempt")
Пример #11
0
 def resetPen(self, painter):
     pen = QPen(Qt.black, 1)
     brush = QBrush()
     painter.setPen(pen)
     painter.setBrush(brush)
Пример #12
0
 def restyle(self, style):
     self.normal_thick = style["pen_width"]
     self.setPen(QPen(style["annot_color"], style["pen_width"]))
     self.setBrush(QBrush(style["box_tint"]))
Пример #13
0
    def init_UI(self):

        #self.setFont(QFont("Arial"))
        self.setWindowFlags(Qt.WindowCloseButtonHint)

        # initiate file names
        self.statusBar().showMessage("Thanks for trusting BOM Comparer :)")
        iconLib = self.style()

        # add background image
        backgroundMAC = QImage(resource_path("backgroundOSX.png"))
        backgroundMAC.scaled(QSize(900, 150))
        self.paletteMain = QPalette()
        self.paletteMain.setBrush(10, QBrush(backgroundMAC))
        self.setPalette(self.paletteMain)

        # add button "Import BOM1"
        inButton1 = QPushButton("Import Original BOM", self)
        inButton1.clicked.connect(self.showImport1)
        inButton1.setFixedWidth(150)
        inButton1.move(50, 50)
        inButton1.setFlat(True)
        inButton1.setStyleSheet("background-color: rgb(6,182,224); \
                                 color: white; \
                                 font: 12pt Arial; \
                                 font-weight: bold;")
        inButton1.setIcon(iconLib.standardIcon(getattr(QStyle, "SP_FileIcon")))

        # add button "Import BOM2"
        inButton2 = QPushButton("Import Updated BOM", self)
        inButton2.clicked.connect(self.showImport2)
        inButton2.setFixedWidth(150)
        inButton2.move(250, 50)
        inButton2.setFlat(True)
        inButton2.setStyleSheet("background-color: rgb(10,172,206); \
                                 color: white; \
                                 font: 12pt Arial; \
                                 font-weight: bold;")
        inButton2.setIcon(iconLib.standardIcon(getattr(QStyle, "SP_FileIcon")))

        # add button "Compare BOMs"
        cmp = QPushButton("Compare BOMs", self)
        cmp.clicked.connect(self.rUSure)
        cmp.resize(cmp.sizeHint())
        cmp.move(450, 50)
        cmp.setFixedWidth(150)
        cmp.setFlat(True)
        cmp.setStyleSheet("background-color: rgb(18,175,175); \
                                 color: white; \
                                 font: 12pt Arial; \
                                 font-weight: bold;")
        cmp.setIcon(iconLib.standardIcon(getattr(QStyle, \
                            "SP_ArrowForward")))

        # add menu option "Set Folder"
        setF = QAction("&Set Folder", self)
        setF.setStatusTip("Choose Folder to Store the Comparison Result")
        setF.triggered.connect(self.setFolder)
        # add menu option "Set BOM Types"
        setB = QMenu("&Set BOM Types", self)
        setB.setStatusTip("Choose BOM Types")
        setBSimple = QAction("&Simple BOMs", self)
        setBStandard = QAction("&Standard BOMs", self)
        setBSimple.triggered.connect(self.setBOMSimple)
        setBSimple.setStatusTip("To Process Simple BOMs")
        setBStandard.triggered.connect(self.setBOMStandard)
        setBStandard.setStatusTip("To Process Standard BOMs")
        setB.addAction(setBSimple)
        setB.addAction(setBStandard)
        # add Setting menu
        menubar = self.menuBar()
        settingMenu = menubar.addMenu("&Setting ")
        settingMenu.addAction(setF)
        settingMenu.addMenu(setB)

        # add menu option "Read Me"
        readMe = QAction("&Read Me", self)
        readMe.setStatusTip("See User Manual")
        readMe.triggered.connect(self.showHelp)
        # add menu option "Contact Me"
        contactMe = QAction("&Contact Me", self)
        contactMe.setStatusTip("Feel Free to Contact Developer Chen")
        contactMe.triggered.connect(self.showEmail)
        # add Help menu
        helpMenu = menubar.addMenu('&Help ')
        helpMenu.addAction(readMe)
        helpMenu.addAction(contactMe)
        """
        authMenu = QAction("&DECLARATION", self)
        authMenu.triggered.connect(self.showAuth)
        menubar.addAction(authMenu)
        """

        self.setStyleSheet("""QMenu{
                                    background-color: rgb(25,140,69);
                                    color: white;
                                    font: 12pt Arial;
                                    font-weight: bold;
                                    }
                              QMenu::item::selected{
                                    background-color:rgb(5,188,228);
                                    }
                              QMenuBar{
                                    background-color: rgb(25,140,69);
                                    color: white;
                                    font: 12pt Arial;
                                    font-weight: bold;
                                    }
                              QMenuBar::item::selected{
                                    background-color: rgb(5,188,228);
                              }""")

        # set window geometry
        self.resize(650, 150)
        self.setWindowTitle("BOM comparer")
        self.setWindowIcon(QIcon(iconLib.standardIcon(getattr(QStyle, \
                        "SP_ComputerIcon"))))
        self.center()
        self.show()
Пример #14
0
    def paint(self, painter, option, index):
        painter.save()
        painter.setRenderHint(QPainter.Antialiasing)
        rect = option.rect
        text_rect_height = 30
        source_rect_height = TextHeight - text_rect_height
        cover_spacing = 0
        text_y = rect.y() + rect.height() - TextHeight
        cover_height = rect.height() - TextHeight
        cover_width = rect.width() - cover_spacing
        cover_x = rect.x() + cover_spacing // 2
        cover_y = rect.y()
        text_rect = QRectF(rect.x(), text_y, rect.width(), text_rect_height)
        source_rect = QRectF(rect.x(), text_y + text_rect_height - 5,
                             rect.width(), source_rect_height + 5)
        obj = index.data(Qt.DecorationRole)
        if obj is None:
            painter.restore()
            return

        text_color = option.palette.color(QPalette.Text)
        if text_color.lightness() > 150:
            non_text_color = text_color.darker(140)
        else:
            non_text_color = text_color.lighter(150)
        non_text_color.setAlpha(100)
        painter.save()
        pen = painter.pen()
        pen.setColor(non_text_color)
        painter.setPen(pen)
        painter.translate(cover_x, cover_y)
        if isinstance(obj, QColor):
            color = obj
            brush = QBrush(color)
            painter.setBrush(brush)
        else:
            if obj.height() < obj.width():
                pixmap = obj.scaledToHeight(cover_height,
                                            Qt.SmoothTransformation)
            else:
                pixmap = obj.scaledToWidth(cover_width,
                                           Qt.SmoothTransformation)
            brush = QBrush(pixmap)
            painter.setBrush(brush)
        border_radius = 3
        if self.as_circle:
            border_radius = cover_width // 2
        cover_rect = QRect(0, 0, cover_width, cover_height)
        painter.drawRoundedRect(cover_rect, border_radius, border_radius)
        painter.restore()
        option = QTextOption()
        source_option = QTextOption()
        if self.as_circle:
            option.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
            source_option.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
        else:
            option.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
            source_option.setAlignment(Qt.AlignLeft | Qt.AlignTop)
        name = index.data(Qt.DisplayRole)
        fm = QFontMetrics(painter.font())
        elided_name = fm.elidedText(name, Qt.ElideRight, text_rect.width())
        source = index.data(Qt.WhatsThisRole)
        painter.drawText(text_rect, elided_name, option)
        painter.restore()
        painter.save()
        pen = painter.pen()
        font = painter.font()
        resize_font(font, -2)
        painter.setFont(font)
        pen.setColor(non_text_color)
        painter.setPen(non_text_color)
        painter.drawText(source_rect, source, source_option)
        painter.restore()
Пример #15
0
 def __init__(self, files=[], parent=None):
     """
     Constructor
     
     @param files list of files to compare and their label
         (list of two tuples of two strings)
     @param parent parent widget (QWidget)
     """
     super(CompareDialog, self).__init__(parent)
     self.setupUi(self)
     
     self.file1Button.setIcon(UI.PixmapCache.getIcon("open.png"))
     self.file2Button.setIcon(UI.PixmapCache.getIcon("open.png"))
     
     self.file1Completer = E5FileCompleter(self.file1Edit)
     self.file2Completer = E5FileCompleter(self.file2Edit)
     
     self.diffButton = self.buttonBox.addButton(
         self.tr("Compare"), QDialogButtonBox.ActionRole)
     self.diffButton.setToolTip(
         self.tr("Press to perform the comparison of the two files"))
     self.diffButton.setEnabled(False)
     self.diffButton.setDefault(True)
     
     self.firstButton.setIcon(UI.PixmapCache.getIcon("2uparrow.png"))
     self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow.png"))
     self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow.png"))
     self.lastButton.setIcon(UI.PixmapCache.getIcon("2downarrow.png"))
     
     self.totalLabel.setText(self.tr('Total: {0}').format(0))
     self.changedLabel.setText(self.tr('Changed: {0}').format(0))
     self.addedLabel.setText(self.tr('Added: {0}').format(0))
     self.deletedLabel.setText(self.tr('Deleted: {0}').format(0))
     
     self.updateInterval = 20    # update every 20 lines
     
     self.vsb1 = self.contents_1.verticalScrollBar()
     self.hsb1 = self.contents_1.horizontalScrollBar()
     self.vsb2 = self.contents_2.verticalScrollBar()
     self.hsb2 = self.contents_2.horizontalScrollBar()
     
     self.on_synchronizeCheckBox_toggled(True)
     
     font = Preferences.getEditorOtherFonts("MonospacedFont")
     self.contents_1.setFontFamily(font.family())
     self.contents_1.setFontPointSize(font.pointSize())
     self.contents_2.setFontFamily(font.family())
     self.contents_2.setFontPointSize(font.pointSize())
     self.fontHeight = QFontMetrics(self.contents_1.currentFont()).height()
     
     self.cNormalFormat = self.contents_1.currentCharFormat()
     self.cInsertedFormat = self.contents_1.currentCharFormat()
     self.cInsertedFormat.setBackground(QBrush(QColor(190, 237, 190)))
     self.cDeletedFormat = self.contents_1.currentCharFormat()
     self.cDeletedFormat.setBackground(QBrush(QColor(237, 190, 190)))
     self.cReplacedFormat = self.contents_1.currentCharFormat()
     self.cReplacedFormat.setBackground(QBrush(QColor(190, 190, 237)))
     
     # connect some of our widgets explicitly
     self.file1Edit.textChanged.connect(self.__fileChanged)
     self.file2Edit.textChanged.connect(self.__fileChanged)
     self.vsb1.valueChanged.connect(self.__scrollBarMoved)
     self.vsb1.valueChanged.connect(self.vsb2.setValue)
     self.vsb2.valueChanged.connect(self.vsb1.setValue)
     
     self.diffParas = []
     self.currentDiffPos = -1
     
     self.markerPattern = "\0\+|\0\^|\0\-"
     
     if len(files) == 2:
         self.filesGroup.hide()
         self.file1Edit.setText(files[0][1])
         self.file2Edit.setText(files[1][1])
         self.file1Label.setText(files[0][0])
         self.file2Label.setText(files[1][0])
         self.diffButton.hide()
         QTimer.singleShot(0, self.on_diffButton_clicked)
     else:
         self.file1Label.hide()
         self.file2Label.hide()
Пример #16
0
class UTTT_Widget(QWidget):

    top_margin = 15
    bottom_margin = 25
    left_margin = 10
    right_margin = 10

    def __init__(self, player, width=700, height=700):
        self.player = player
        super().__init__()
        self.setWindowTitle("Ultimate Tic Tac Toe by AntonioJKim")
        self.width = width
        self.height = height
        self.resize(width, height)
        self.installEventFilter(self)
        self.setMouseTracking(True)

        # Graphics attributes
        self.large_grid_spacing = 225
        self.small_grid_margins = 15
        self.small_grid_spacing = (self.large_grid_spacing -
                                   2 * self.small_grid_margins) // 3

        self.locked = True

        self.mouse_i = -1
        self.mouse_j = -1

        self.current_player = P1
        self.legal_moves = set()
        self.filled = set()
        self.quadrant_filled = set()

        # timer = QTimer(self, timeout=self.paint_board, interval=100)
        # timer.start()

    def lock(self):
        self.locked = True
        # self.update()
        self.repaint()

    def unlock(self):
        self.locked = False
        # self.update()
        self.repaint()

    def mouseMoveEvent(self, event):
        if not self.locked:
            x = event.x()
            y = event.y()

            i = sum((
                min((x - self.left_margin) // self.large_grid_spacing, 2),
                3 * min((y - self.top_margin) // self.large_grid_spacing, 2),
            ))
            x = max(
                x - min((x - self.left_margin) // self.large_grid_spacing, 2) *
                self.large_grid_spacing - 2 * self.small_grid_margins + 5,
                0,
            )
            y = max(
                y - min((y - self.top_margin) // self.large_grid_spacing, 2) *
                self.large_grid_spacing - 2 * self.small_grid_margins,
                0,
            )
            j = sum((
                min(x // self.small_grid_spacing, 2),
                3 * min(y // self.small_grid_spacing, 2),
            ))

            if 0 <= i < 9 and 0 <= j < 9 and (i != self.mouse_i
                                              or j != self.mouse_j):
                self.mouse_i = i
                self.mouse_j = j

        self.repaint()
        event.accept()

    def mouseReleaseEvent(self, event):
        if not self.locked:
            self.player.move = (self.mouse_i, self.mouse_j)
            self.player.end_turn()

        event.accept()

    def keyReleaseEvent(self, event):
        if event.modifiers() == Qt.ControlModifier:
            if event.key() == Qt.Key_W:
                sys.exit(0)

        event.accept()

    def paintEvent(self, event):
        painter = QPainter(self)
        self.draw_grids(painter)
        self.draw_legal(painter)
        self.draw_filled(painter)
        self.draw_quadrant_filled(painter)
        self.draw_hover(painter)

    def draw_grids(self, painter):
        # Draw Large Grid
        painter.setPen(QPen(Qt.black, 4))
        for i in range(1, 3):
            painter.drawLine(
                self.left_margin + i * self.large_grid_spacing,
                self.top_margin,
                self.left_margin + i * self.large_grid_spacing,
                self.height - self.bottom_margin,
            )
            painter.drawLine(
                self.left_margin,
                self.top_margin + i * 225,
                self.width - self.right_margin,
                self.top_margin + i * 225,
            )

        # Draw Small Grids
        painter.setPen(QPen(Qt.black, 2))
        for i in range(3):
            for j in range(3):
                for k in range(1, 3):
                    painter.drawLine(
                        self.left_margin + i * self.large_grid_spacing +
                        k * self.small_grid_spacing + self.small_grid_margins,
                        self.top_margin + j * self.large_grid_spacing +
                        self.small_grid_margins,
                        self.left_margin + i * self.large_grid_spacing +
                        k * self.small_grid_spacing + self.small_grid_margins,
                        self.top_margin + j * self.large_grid_spacing +
                        3 * self.small_grid_spacing + self.small_grid_margins,
                    )
                    painter.drawLine(
                        self.left_margin + i * self.large_grid_spacing +
                        self.small_grid_margins,
                        self.top_margin + j * self.large_grid_spacing +
                        k * self.small_grid_spacing + self.small_grid_margins,
                        self.left_margin + i * self.large_grid_spacing +
                        3 * self.small_grid_spacing + self.small_grid_margins,
                        self.top_margin + j * self.large_grid_spacing +
                        k * self.small_grid_spacing + self.small_grid_margins,
                    )

    legal_brushes = {
        P1: QBrush(QColor(0, 204, 0, 84)),
        P2: QBrush(QColor(0, 128, 255, 84)),
    }

    def get_rect(self, i, j):
        return QRect(
            (i % 3) * self.large_grid_spacing +
            (j % 3) * self.small_grid_spacing + self.left_margin +
            self.small_grid_margins,
            (i // 3) * self.large_grid_spacing +
            (j // 3) * self.small_grid_spacing + self.top_margin +
            self.small_grid_margins,
            self.small_grid_spacing,
            self.small_grid_spacing,
        )

    def draw_legal(self, painter):
        if self.current_player is not None:
            brush = self.legal_brushes[self.current_player]
            for i, j in self.legal_moves:
                painter.fillRect(self.get_rect(i, j), brush)

    player_symbols = {
        P1: ("X", (0, 204, 0)),
        P2: ("O", (0, 128, 255)),
        T: ("", (0, 0, 0)),
    }

    def draw_filled(self, painter):
        painter.setFont(QFont("system", 30))

        quadrant_filled = set(i for i, p in self.quadrant_filled)

        for i, j, player in self.filled:
            symbol, (r, g, b) = self.player_symbols[player]
            if i not in quadrant_filled:
                painter.setPen(QPen(QColor(r, g, b, 255)))
            else:
                painter.setPen(QPen(QColor(r, g, b, 96)))

            painter.drawText(self.get_rect(i, j), Qt.AlignCenter, symbol)

    def draw_quadrant_filled(self, painter):
        painter.setFont(QFont("system", 150))

        def draw_symbol(i, player):
            symbol, (r, g, b) = self.player_symbols[player]
            painter.setPen(QPen(QColor(r, g, b, 255)))

            painter.drawText(
                QRect(
                    (i % 3) * self.large_grid_spacing + self.top_margin,
                    (i // 3) * self.large_grid_spacing + self.left_margin,
                    self.large_grid_spacing,
                    self.large_grid_spacing,
                ),
                Qt.AlignCenter,
                symbol,
            )

        for i, player in self.quadrant_filled:
            draw_symbol(i, player)

    def draw_hover(self, painter):
        if not self.locked and (self.mouse_i,
                                self.mouse_j) in self.legal_moves:
            painter.setFont(QFont("system", 30))
            symbol, (r, g, b) = self.player_symbols[self.current_player]
            painter.setPen(QPen(QColor(r, g, b, 255)))
            painter.drawText(self.get_rect(self.mouse_i, self.mouse_j),
                             Qt.AlignCenter, symbol)
Пример #17
0
 def set_highscore_background(self):
     palette = QPalette()
     pixmap = QPixmap("assets/Highscorebackground.jpeg").scaled(700, 700)
     brush = QBrush(pixmap)
     palette.setBrush(QPalette.Background, brush)
     self.setPalette(palette)
Пример #18
0
    def update_slider(self):
        '''
        Update the slider to a gradient between the two colors.

        The painting of the slider comes from the program Krita. The original code can be accessed
        at the following URL.
        https://github.com/KDE/krita/blob/master/plugins/dockers/advancedcolorselector/kis_shade_selector_line.cpp
        '''
        if self.need_redraw:
            patch_count = self.width()
            base_hsva = list(
                self.docker.managedcolor_to_qcolor(self.left_color).getHsvF())
            dest_hsva = list(
                self.docker.managedcolor_to_qcolor(self.right_color).getHsvF())
            diff_hsva = [(dest_hsva[i] - base_hsva[i]) for i in range(4)]
            if dest_hsva[0] == -1.0:
                diff_hsva[0] = 0
            elif base_hsva[0] == -1.0:
                diff_hsva[0] = 0
                base_hsva[0] = dest_hsva[0]
            elif diff_hsva[
                    0] > 0.5:  # make sure the sliding goes through a minor arc
                diff_hsva[0] = diff_hsva[0] - 1.0
            elif diff_hsva[0] < -0.5:
                diff_hsva[0] = diff_hsva[0] + 1.0

            step_hsva = [x / patch_count for x in diff_hsva]

            self.slider_pixmap = QPixmap(self.width(), self.height())
            painter = QPainter(self.slider_pixmap)

            for i in range(patch_count):
                hue = base_hsva[0] + i * step_hsva[0]
                while hue < 0.0:
                    hue += 1.0

                while hue > 1.0:
                    hue -= 1.0

                saturation = base_hsva[1] + i * step_hsva[1]
                value = base_hsva[2] + i * step_hsva[2]
                cur_color = QColor.fromHsvF(hue, saturation, value)
                painter.fillRect(i, 0, 1, self.height(), cur_color)

            painter.end()

            self.need_redraw = False

        widget_painter = QPainter(self)
        self.rendered_image = self.slider_pixmap.toImage()

        widget_painter.drawImage(0, 0, self.rendered_image)
        if self.value_x is not None:
            start_x = self.value_x
            start_y = self.height() / 2
            delta_x = self.height() / 3
            delta_y = self.height() / 3
            points = [
                QPoint(start_x, start_y),
                QPoint(start_x - delta_x, start_y + delta_y),
                QPoint(start_x + delta_x, start_y + delta_y)
            ]
            widget_painter.setBrush(QBrush(self.cursor_fill_color))
            widget_painter.setPen(self.cursor_outline_color)
            widget_painter.drawPolygon(QPolygon(points))
Пример #19
0
    def paintEvent(self, e):







        painter= QPainter(self)


        reflecting_axis= QTransform(1,0,0,0,-1,0,250,250,1) #translating the coordinate system to the middle of the screen and reflecting it about x axis to make positive y cooredinates above x axis
        painter.setTransform(reflecting_axis)

        painter.setPen(QPen(Qt.black,1,Qt.SolidLine))
        painter.setBrush(QBrush(Qt.gray,Qt.SolidPattern))

        painter.drawEllipse(QPointF(0,0),250,250)                       #draw outer lane


        painter.setPen(QPen(Qt.yellow,5,Qt.DashLine))
        painter.setBrush(QBrush(Qt.gray,Qt.SolidPattern))

        painter.drawEllipse(QPointF(0,0),150,150)                       #draw inner lane

        painter.setPen(QPen(Qt.black,2,Qt.SolidLine))
        painter.setBrush(QBrush(Qt.black,Qt.SolidPattern))

        painter.drawEllipse(QPointF(0,0),50,50)                         #black centre

        # -------------------------------------------------------------------------------------------------------------
        # Drawing lanes is complete. Now drawing cars

        painter.setBrush(QBrush(Qt.green,Qt.SolidPattern))



        counter=1
        for point in Algorithm.run_algorithm(Window.STATE_OF_EMERGENCY):

            if counter==1:
                painter.drawEllipse(QPointF(point[0], point[1]),10,10)
                counter=-1
            else:
                painter.drawEllipse(QPointF(point[0], point[1]),5,5)
                counter=1




        for a_car in CarMaintainer.Inner_Car_List:
            if a_car.PSUEDO_CAR==False:
                painter.drawEllipse(a_car.calculate_position(),a_car.CAR_GUI_RADIUS,a_car.CAR_GUI_RADIUS)
                painter.drawText(a_car.calculate_position(),str(a_car.CarNumber))

            else:
                painter.setPen(QPen(Qt.red,1,Qt.DashLine))      #new paint settings for Psuedo car
                painter.setBrush(QBrush(Qt.gray,Qt.NoBrush))

                painter.drawEllipse(a_car.calculate_position(),a_car.CAR_GUI_RADIUS,a_car.CAR_GUI_RADIUS)
                painter.drawText(a_car.calculate_position(),str(a_car.CarNumber))

                painter.setPen(QPen(Qt.black,2,Qt.SolidLine))       # restore paint settings after drawing a psuedo car
                painter.setBrush(QBrush(Qt.green,Qt.SolidPattern))




        for a_car in CarMaintainer.Outer_Car_List:

            if a_car.IS_AMBULANCE == False :
                painter.drawEllipse(a_car.calculate_position(),a_car.CAR_GUI_RADIUS,a_car.CAR_GUI_RADIUS)
                painter.drawText(a_car.calculate_position(),str(a_car.CarNumber))

            else:
                painter.setBrush(QBrush(Qt.red,Qt.SolidPattern))

                painter.drawEllipse(a_car.calculate_position(),a_car.CAR_GUI_RADIUS,a_car.CAR_GUI_RADIUS)
                painter.drawText(a_car.calculate_position(),str(a_car.CarNumber))

                painter.setBrush(QBrush(Qt.green,Qt.SolidPattern))



        for a_car in CarMaintainer.In_Transition_List:


                painter.setBrush(QBrush(Qt.yellow,Qt.SolidPattern))

                painter.drawEllipse(a_car.calculate_position(),a_car.CAR_GUI_RADIUS,a_car.CAR_GUI_RADIUS)
                painter.drawText(a_car.calculate_position(),str(a_car.CarNumber))

                painter.setBrush(QBrush(Qt.green,Qt.SolidPattern))





        painter.setPen(QPen(Qt.red,1,Qt.SolidLine))
        painter.setBrush(QBrush(Qt.green,Qt.NoBrush))

        painter.drawEllipse(QPointF(0,0),100,100)   #draw constuction line on inner lane
        painter.drawEllipse(QPointF(0,0),200,200)   #draw constuction line on outer lane

        painter.setPen(QPen(Qt.red,1,Qt.SolidLine))
        painter.setBrush(QBrush(Qt.red,Qt.SolidPattern))

        # painter.drawEllipse(QPointF(100,0),5,5)
        # painter.drawEllipse(QPointF(-100,0),5,5)
        # painter.drawEllipse(QPointF(0,-100),5,5)



        painter.drawEllipse(QPointF(0,0),10,10)
Пример #20
0
    def build_ui(self):
        self.ui = Ui_Hitagi()
        self.ui.setupUi(self)

        # File menu
        self.ui.actionSet_as_wallpaper.triggered.connect(
            self.on_set_as_wallpaper)
        self.ui.actionCopy_to_clipboard.triggered.connect(self.on_clipboard)
        self.ui.actionOpen_current_directory.triggered.connect(
            self.on_current_dir)
        self.ui.actionOptions.triggered.connect(self.on_options)
        self.ui.actionExit.triggered.connect(self.on_close)

        # Folder menu
        self.ui.actionOpen_next.triggered.connect(self.on_next_item)
        self.ui.actionOpen_previous.triggered.connect(self.on_previous_item)
        self.ui.actionChange_directory.triggered.connect(
            self.on_change_directory)

        # View menu
        self.ui.actionZoom_in.triggered.connect(self.on_zoom_in)
        self.ui.actionZoom_out.triggered.connect(self.on_zoom_out)
        self.ui.actionOriginal_size.triggered.connect(self.on_zoom_original)
        self.ui.actionFit_image_width.triggered.connect(
            self.on_scale_image_to_width)
        self.ui.actionFit_image_height.triggered.connect(
            self.on_scale_image_to_height)
        self.ui.actionFile_list.triggered.connect(self.on_toggle_filelist)
        self.ui.actionFullscreen.triggered.connect(self.on_fullscreen)

        # Favorite menu
        self.ui.actionAdd_to_favorites.triggered.connect(
            self.on_add_to_favorites)
        self.ui.actionRemove_from_favorites.triggered.connect(
            self.on_remove_from_favorites)

        # Help menu
        self.ui.actionChangelog.triggered.connect(self.on_changelog)
        self.ui.actionAbout.triggered.connect(self.on_about)

        # Load stylesheet
        stylesheet_dir = "resources/hitagi.stylesheet"
        with open(stylesheet_dir, "r") as sh:
            self.setStyleSheet(sh.read())

        # File listing
        self.file_model = QFileSystemModel()
        self.file_model.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs
                                  | QDir.Files)
        self.file_model.setNameFilters(['*.jpg', '*.png', '*.jpeg'])
        self.file_model.setNameFilterDisables(False)
        self.file_model.setRootPath(self.settings.get('Directory', 'default'))

        self.ui.treeView.setModel(self.file_model)
        self.ui.treeView.setColumnWidth(0, 200)
        self.ui.treeView.setColumnWidth(1, 200)
        self.ui.treeView.hideColumn(1)
        self.ui.treeView.hideColumn(2)

        # Double click
        self.ui.treeView.activated.connect(self.on_dir_list_activated)
        # Update file list
        self.ui.treeView.clicked.connect(self.on_dir_list_clicked)
        # Open parent
        self.ui.button_open_parent.clicked.connect(self.on_open_parent)

        # Shortcuts
        _translate = QtCore.QCoreApplication.translate
        self.ui.actionExit.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys', 'Exit')))

        self.ui.actionOpen_next.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys', 'Next')))
        self.ui.actionOpen_previous.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys', 'Previous')))
        self.ui.actionChange_directory.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys', 'Directory')))

        self.ui.actionZoom_in.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys', 'Zoom in')))
        self.ui.actionZoom_out.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys', 'Zoom out')))
        self.ui.actionOriginal_size.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys',
                                                   'Zoom original')))
        self.ui.actionFullscreen.setShortcut(
            _translate("Hitagi", self.settings.get('Hotkeys', 'Fullscreen')))

        # Load favorites in UI
        self.load_favorites()

        # Background
        self.ui.graphicsView.setBackgroundBrush(
            QBrush(QColor(self.settings.get('Look', 'background')),
                   Qt.SolidPattern))
# -*- coding: utf-8 -*-

'''
    【簡介】
	 設定視窗背景圖片
    
'''

import sys
from PyQt5.QtWidgets import QMainWindow , QApplication
from PyQt5.QtGui import QPalette , QBrush , QPixmap


app = QApplication(sys.argv)
win = QMainWindow()
win.setWindowTitle("設定視窗背景圖片") 
palette	= QPalette()
palette.setBrush(QPalette.Background,QBrush(QPixmap("./images/python.jpg")))
win.setPalette(palette)  
#當背景圖片的寬度和高度大於視窗的寬度和高度時
#win.resize(460,  255 )  

#當背景圖片的寬度和高度小於視窗的寬度和高度時
win.resize(800,  600 )  

win.show()
sys.exit(app.exec_())
Пример #22
0
    def createRow(self,
                  param,
                  name_editable=False,
                  value_editable=True,
                  comments_editable=True,
                  index=-1):
        """
        Create a row in the table for a param.
        Input:
            param: ParamNode
        Return:
            BaseRowItem derived object
        """
        row = self.rowCount()
        if index >= 0:
            row = index
        self.insertRow(row)
        name_item = QtWidgets.QTableWidgetItem(param.name)
        name_item.setData(Qt.UserRole, param)

        if not name_editable:
            name_item.setFlags(Qt.ItemIsEnabled)

        if param.required:
            color = QColor(255, 204, 153)
            brush = QBrush(color)
            name_item.setBackground(brush)
        elif param.user_added:
            color = QColor("cyan")
            brush = QBrush(color)
            name_item.setBackground(brush)

        name_item.setText(param.name)
        self.setItem(row, 0, name_item)

        if param.cpp_type == "bool":
            checkbox = QtWidgets.QCheckBox()
            if param.value == "true":
                checkbox.setCheckState(Qt.Checked)
            else:
                checkbox.setCheckState(Qt.Unchecked)
            checkbox.pressed.connect(self.changed)
            self.setCellWidget(row, 1, checkbox)
        else:
            value_item = QtWidgets.QTableWidgetItem(param.value)
            if not value_editable or param.name == "type":
                value_item.setFlags(Qt.ItemIsEnabled)
            else:
                name_item.setToolTip(param.toolTip())

            self.setItem(row, 1, value_item)

        comments_item = QtWidgets.QTableWidgetItem(param.comments)
        if not comments_editable:
            comments_item.setFlags(Qt.ItemIsEnabled)
        self.setItem(row, 3, comments_item)

        watch_blocks = self._getChildrenOfNodeOptions(param.cpp_type)
        if param.cpp_type == "FileName" or param.cpp_type == "MeshFileName" or param.cpp_type == "FileNameNoExtension":
            self._createFilenameOption(param)
        elif watch_blocks:
            self._createBlockWatcher(param, watch_blocks)
        elif param.options:
            self._createOptions(param)
        elif param.user_added:
            button = QtWidgets.QPushButton("Remove")
            button.clicked.connect(
                lambda checked: self._removeButtonClicked(name_item))
            self.setCellWidget(row, 2, button)
        else:
            option_item = QtWidgets.QTableWidgetItem()
            option_item.setFlags(Qt.NoItemFlags)
            self.setItem(row, 2, option_item)
Пример #23
0
 def __init__(self, r, g, b, a, is_background_color):
     self.brush = QBrush(QColor(r, g, b, a))
     self.is_background_color = is_background_color
     self.is_foreground_color = not is_background_color
Пример #24
0
 def setViewTheme(self, bgColor, brushColor, penColor):
     brushColor.setAlpha(40)
     penColor.setAlpha(100)
     self.fViewBg    = bgColor
     self.fViewBrush = QBrush(brushColor)
     self.fViewPen   = QPen(penColor, 1)
Пример #25
0
    def initGui(self):
        self.setGeometry(0,0,1000,1000)
        self.setWindowTitle('Covid-19')

        f=open("podaci.csv","w",newline="")
        w=csv.writer(f)
        w.writerow(["jmbg","ime i prezime","datum","anamneza"])
        f.close()
        
        vbox = QtWidgets.QVBoxLayout()
        self.setLayout(vbox)
        
        #dodajemo sliku u pozadini
        oImage = QImage("4.jpeg")
        sImage = oImage.scaled(QSize(500,500))                   
        palette = QPalette()
        palette.setBrush(QPalette.Window, QBrush(sImage))
        self.setPalette(palette)

        self.licni = QLabel("LICNI PODACI", self)  
        vbox.addWidget(self.licni)
        self.licni.setFont(QFont("Comic Sans MS",weight=QFont.Bold))
        
        #ime i prezime
        hboxIme = QtWidgets.QHBoxLayout()
        lime= QLabel("Uneti ime i prezime: ")
        self.time= QtWidgets.QLineEdit()
        hboxIme.addWidget(lime)
        hboxIme.addWidget(self.time)
        vbox.addLayout(hboxIme)
        
        #jmbg
        hboxJMBG = QtWidgets.QHBoxLayout()
        ljmbg= QLabel("Uneti JMBG: ")
        self.tjmbg= QtWidgets.QLineEdit()
        hboxJMBG.addWidget(ljmbg)
        hboxJMBG.addWidget(self.tjmbg)
        vbox.addLayout(hboxJMBG)
        
        #goidne
        hbox1 = QtWidgets.QHBoxLayout()
        lGodine= QLabel("Uneti broj godina: ")
        self.tGodine= QtWidgets.QLineEdit()
        hbox1.addWidget(lGodine)
        hbox1.addWidget(self.tGodine)
        vbox.addLayout(hbox1)
        
        #vakcinacija
        hboxVak = QtWidgets.QHBoxLayout()
        lVakcinacija= QLabel("Da li ste vakcinisani: ")
        self.rVak1= QtWidgets.QRadioButton("Jesam od svih")
        self.rVak2= QtWidgets.QRadioButton("Nisam od svih vakcina koje su bile potrebne")
        self.rVak3= QtWidgets.QRadioButton("Nisam uopste")
        self.grVak = QtWidgets.QButtonGroup(self)
        self.grVak.addButton(self.rVak1)
        self.grVak.addButton(self.rVak2)
        self.grVak.addButton(self.rVak3)
        hboxVak.addWidget(lVakcinacija)
        hboxVak.addWidget(self.rVak1)
        hboxVak.addWidget(self.rVak2)
        hboxVak.addWidget(self.rVak3)
        vbox.addLayout(hboxVak)

        #alergija
        hboxAlergija = QtWidgets.QHBoxLayout()
        lAlergija= QLabel("Da li ste alergicni: ")
        self.rAlergija1= QtWidgets.QRadioButton("na neku vrstu hrane")
        self.rAlergija2= QtWidgets.QRadioButton("na neku vrstu leka")
        self.grAlergija1 = QtWidgets.QButtonGroup(self)
        self.grAlergija1.addButton(self.rAlergija1)
        self.grAlergija2 = QtWidgets.QButtonGroup(self)
        self.grAlergija2.addButton(self.rAlergija2)
        hboxAlergija.addWidget(lAlergija)
        hboxAlergija.addWidget(self.rAlergija1)
        hboxAlergija.addWidget(self.rAlergija2)
        vbox.addLayout(hboxAlergija)

        #teske infekcije
        hboxInfekcija = QtWidgets.QHBoxLayout()
        lInfekcije= QLabel("Da li ste imali neke od teskih infekcija: ")
        self.rInfekcija1= QtWidgets.QRadioButton("pneumonija (upala pluca)")
        self.rInfekcija2= QtWidgets.QRadioButton("meningitis (upala mozga)")
        self.rInfekcija3= QtWidgets.QRadioButton("endokarditis (upala srca)")
        self.grInfekcija1 = QtWidgets.QButtonGroup(self)
        self.grInfekcija1.addButton(self.rInfekcija1)
        self.grInfekcija2 = QtWidgets.QButtonGroup(self)
        self.grInfekcija2.addButton(self.rInfekcija2)
        self.grInfekcija3 = QtWidgets.QButtonGroup(self)
        self.grInfekcija3.addButton(self.rInfekcija3)
        hboxInfekcija.addWidget(lInfekcije)
        hboxInfekcija.addWidget(self.rInfekcija1)
        hboxInfekcija.addWidget(self.rInfekcija2)
        hboxInfekcija.addWidget(self.rInfekcija3)
        vbox.addLayout(hboxInfekcija)

        #diabetes
        hboxDiabetes = QtWidgets.QHBoxLayout()
        lDiabetes= QLabel("Da li imate diabetes: ")
        self.rDiabetes1= QtWidgets.QRadioButton("Da")
        self.rDiabetes2= QtWidgets.QRadioButton("Ne")
        self.grDiabetes = QtWidgets.QButtonGroup(self)
        self.grDiabetes.addButton(self.rDiabetes1)
        self.grDiabetes.addButton(self.rDiabetes2)
        hboxDiabetes.addWidget(lDiabetes)
        hboxDiabetes.addWidget(self.rDiabetes1)
        hboxDiabetes.addWidget(self.rDiabetes2)
        vbox.addLayout(hboxDiabetes)

        #hipertenzija
        hboxHipertenzija = QtWidgets.QHBoxLayout()
        lHipertenzija= QLabel("Da li imate hipertenziju (povisen krvni pritisak): ")
        self.rHiper1= QtWidgets.QRadioButton("Da")
        self.rHiper2= QtWidgets.QRadioButton("Ne")
        self.grHiper = QtWidgets.QButtonGroup(self)
        self.grHiper.addButton(self.rHiper1)
        self.grHiper.addButton(self.rHiper2)
        hboxHipertenzija.addWidget(lHipertenzija)
        hboxHipertenzija.addWidget(self.rHiper1)
        hboxHipertenzija.addWidget(self.rHiper2)
        vbox.addLayout(hboxHipertenzija)

        #hipotenzija
        hboxHipotenzija = QtWidgets.QHBoxLayout()
        lHipotenzija= QLabel("Da li imate hipotenziju (snizen krvni pritisak): ")
        self.rHipo1= QtWidgets.QRadioButton("Da")
        self.rHipo2= QtWidgets.QRadioButton("Ne")
        self.grHipo = QtWidgets.QButtonGroup(self)
        self.grHipo.addButton(self.rHipo1)
        self.grHipo.addButton(self.rHipo2)
        hboxHipotenzija.addWidget(lHipotenzija)
        hboxHipotenzija.addWidget(self.rHipo1)
        hboxHipotenzija.addWidget(self.rHipo2)
        vbox.addLayout(hboxHipotenzija)

        #astma
        hboxAstma = QtWidgets.QHBoxLayout()
        lAstma= QLabel("Da li imate astmu (ako da, koliko cesto): ")
        self.rAstma1= QtWidgets.QRadioButton("dnevno vise puta")
        self.rAstma2= QtWidgets.QRadioButton("jednom dnevno")
        self.rAstma3= QtWidgets.QRadioButton("vise od jednom nedeljno")
        self.rAstma4= QtWidgets.QRadioButton("manje od jednom nedeljno")
        self.rAstma5= QtWidgets.QRadioButton("nemam uopste")
        self.grAstma = QtWidgets.QButtonGroup(self)
        self.grAstma.addButton(self.rAstma1)
        self.grAstma.addButton(self.rAstma2)
        self.grAstma.addButton(self.rAstma3)
        self.grAstma.addButton(self.rAstma4)
        self.grAstma.addButton(self.rAstma5)
        hboxAstma.addWidget(lAstma)
        hboxAstma.addWidget(self.rAstma1)
        hboxAstma.addWidget(self.rAstma2)
        hboxAstma.addWidget(self.rAstma3)
        hboxAstma.addWidget(self.rAstma4)
        hboxAstma.addWidget(self.rAstma5)
        vbox.addLayout(hboxAstma)

        #cigarete
        hboxCigarete = QtWidgets.QHBoxLayout()
        lCigarete= QLabel("Da li pusite cigarete (ako da, koliko cigareta dnevno): ")
        self.rCig1= QtWidgets.QRadioButton("ne")
        self.rCig2= QtWidgets.QRadioButton("od 1 do 5 dnevno")
        self.rCig3= QtWidgets.QRadioButton("od 5 do 10 dnevno")
        self.rCig4= QtWidgets.QRadioButton("od 10 do 20 dnevno")
        self.rCig5= QtWidgets.QRadioButton("vise od 20")
        self.grCig = QtWidgets.QButtonGroup(self)
        self.grCig.addButton(self.rCig1)
        self.grCig.addButton(self.rCig2)
        self.grCig.addButton(self.rCig3)
        self.grCig.addButton(self.rCig4)
        self.grCig.addButton(self.rCig5)
        hboxCigarete.addWidget(lCigarete)
        hboxCigarete.addWidget(self.rCig1)
        hboxCigarete.addWidget(self.rCig2)
        hboxCigarete.addWidget(self.rCig3)
        hboxCigarete.addWidget(self.rCig4)
        hboxCigarete.addWidget(self.rCig5)
        vbox.addLayout(hboxCigarete)

        self.simptomi = QLabel("SIMPTOMI", self)  
        vbox.addWidget(self.simptomi)
        self.simptomi.setFont(QFont("Comic Sans MS",weight=QFont.Bold))
        self.cesti = QLabel("Najcesci simptomi",self)
        vbox.addWidget(self.cesti)
        self.cesti.setFont(QFont("Arial",weight=QFont.Bold))

        #temperatura
        hboxT = QtWidgets.QHBoxLayout()
        ltemp= QLabel("Temperatura: ")
        self.rtemp1= QtWidgets.QRadioButton("manje od 37")
        self.rtemp2= QtWidgets.QRadioButton("od 37 do 38")
        self.rtemp3= QtWidgets.QRadioButton("vise od 38")
        self.bgT = QButtonGroup(self)
        self.bgT.addButton(self.rtemp1)
        self.bgT.addButton(self.rtemp2)
        self.bgT.addButton(self.rtemp3)
        hboxT.addWidget(ltemp)
        hboxT.addWidget(self.rtemp1)
        hboxT.addWidget(self.rtemp2)
        hboxT.addWidget(self.rtemp3)
        vbox.addLayout(hboxT)
        
        #suv kasalj
        hboxSK = QtWidgets.QHBoxLayout()
        lskasalj= QLabel("Suv kasalj: ")
        self.rskasalj1= QtWidgets.QRadioButton("Da")
        self.rskasalj2= QtWidgets.QRadioButton("Ne")
        self.bgSK = QButtonGroup(self)
        self.bgSK.addButton(self.rskasalj1)
        self.bgSK.addButton(self.rskasalj2)
        hboxSK.addWidget(lskasalj)
        hboxSK.addWidget(self.rskasalj1)
        hboxSK.addWidget(self.rskasalj2)
        vbox.addLayout(hboxSK)

        #umor
        hboxU = QtWidgets.QHBoxLayout()
        lumor= QLabel("Umor: ")
        self.rumor1= QtWidgets.QRadioButton("Da")
        self.rumor2= QtWidgets.QRadioButton("Ne")
        self.bgU = QButtonGroup(self)
        self.bgU.addButton(self.rumor1)
        self.bgU.addButton(self.rumor2)
        hboxU.addWidget(lumor)
        hboxU.addWidget(self.rumor1)
        hboxU.addWidget(self.rumor2)
        vbox.addLayout(hboxU)

        self.manje = QLabel("Manje cesti simptomi",self)
        vbox.addWidget(self.manje)
        self.manje.setFont(QFont("Arial",weight=QFont.Bold))

        #bol
        hboxB = QtWidgets.QHBoxLayout()
        lbol = QLabel("Bolovi u misicima: ")
        self.rbol1= QtWidgets.QRadioButton("Da")
        self.rbol2= QtWidgets.QRadioButton("Ne")
        self.bgB = QButtonGroup(self)
        self.bgB.addButton(self.rbol1)
        self.bgB.addButton(self.rbol2)
        hboxB.addWidget(lbol)
        hboxB.addWidget(self.rbol1)
        hboxB.addWidget(self.rbol2)
        vbox.addLayout(hboxB)

        #upaljeno grlo
        hboxUG = QtWidgets.QHBoxLayout()
        lugrlo = QLabel("Upaljeno grlo: ")
        self.rugrlo1= QtWidgets.QRadioButton("Da")
        self.rugrlo2= QtWidgets.QRadioButton("Ne")
        self.bgUG = QButtonGroup(self)
        self.bgUG.addButton(self.rugrlo1)
        self.bgUG.addButton(self.rugrlo2)
        hboxUG.addWidget(lugrlo)
        hboxUG.addWidget(self.rugrlo1)
        hboxUG.addWidget(self.rugrlo2)
        vbox.addLayout(hboxUG)

        #dijareja
        hboxD = QtWidgets.QHBoxLayout()
        ldijareja = QLabel("Dijareja (proliv): ")
        self.rdijareja1 = QtWidgets.QRadioButton("Da")
        self.rdijareja2 = QtWidgets.QRadioButton("Ne")
        self.bgD = QButtonGroup(self)
        self.bgD.addButton(self.rdijareja1)
        self.bgD.addButton(self.rdijareja2)
        hboxD.addWidget(ldijareja)
        hboxD.addWidget(self.rdijareja1)
        hboxD.addWidget(self.rdijareja2)
        vbox.addLayout(hboxD)

        #glavobolja
        hboxG = QtWidgets.QHBoxLayout()
        lglavobolja = QLabel("Glavobolja: ")
        self.rglavobolja1 = QtWidgets.QRadioButton("Da")
        self.rglavobolja2 = QtWidgets.QRadioButton("Ne")
        self.bgG = QButtonGroup(self)
        self.bgG.addButton(self.rglavobolja1)
        self.bgG.addButton(self.rglavobolja2)
        hboxG.addWidget(lglavobolja)
        hboxG.addWidget(self.rglavobolja1)
        hboxG.addWidget(self.rglavobolja2)
        vbox.addLayout(hboxG)
 
        #gubitak cula
        hboxC = QtWidgets.QHBoxLayout()
        lcula = QLabel("Gubitak cula mirisa ili ukusa: ")
        self.rcula1 = QtWidgets.QRadioButton("Cubitak cula mirisa")
        self.rcula2 = QtWidgets.QRadioButton("Gubitak cula ukusa")
        self.rcula3 = QtWidgets.QRadioButton("Nije doslo do gubitka cula mirisa ili ukusa")
        self.bgC1 = QButtonGroup(self)
        self.bgC1.addButton(self.rcula1)
        self.bgC2 = QButtonGroup(self)
        self.bgC2.addButton(self.rcula2)
        self.bgC3 = QButtonGroup(self)
        self.bgC3.addButton(self.rcula3)
        
        hboxC.addWidget(lcula)
        hboxC.addWidget(self.rcula1)
        hboxC.addWidget(self.rcula2)
        hboxC.addWidget(self.rcula3)
       # hboxC.addWidget(rgrupa)
        vbox.addLayout(hboxC)
        
        #teski simptomi
        lteski = QtWidgets.QLabel("Teski simptomi")
        vbox.addWidget(lteski)
        lteski.setFont(QFont("Arial",weight=QFont.Bold))

        hboxDisanje = QtWidgets.QHBoxLayout()
        ldisanje = QtWidgets.QLabel("Teskoce pri disanju ili nedostatak daha: ")
        self.rbDisanje1 = QtWidgets.QRadioButton("Da")
        self.rbDisanje2 = QtWidgets.QRadioButton("Ne")
        self.grDisanje = QtWidgets.QButtonGroup(self)
        self.grDisanje.addButton(self.rbDisanje1)
        self.grDisanje.addButton(self.rbDisanje2)
        hboxDisanje.addWidget(ldisanje)
        hboxDisanje.addWidget(self.rbDisanje1)
        hboxDisanje.addWidget(self.rbDisanje2)
        vbox.addLayout(hboxDisanje)

        hboxPritisak = QtWidgets.QHBoxLayout()
        lpritisak = QtWidgets.QLabel("Bol ili pritisak u grudima: ")
        self.rbPritisak1 = QtWidgets.QRadioButton("Da")
        self.rbPritisak2 = QtWidgets.QRadioButton("Ne")
        self.grPritisak = QtWidgets.QButtonGroup(self)
        self.grPritisak.addButton(self.rbPritisak1)
        self.grPritisak.addButton(self.rbPritisak2)
        hboxPritisak.addWidget(lpritisak)
        hboxPritisak.addWidget(self.rbPritisak1)
        hboxPritisak.addWidget(self.rbPritisak2)
        vbox.addLayout(hboxPritisak)

        #kontakti
        lkont = QtWidgets.QLabel("KONTAKTI")
        vbox.addWidget(lkont)
        lkont.setFont(QFont("Comic Sans MS",weight=QFont.Bold))

        hboxPoz = QtWidgets.QHBoxLayout()
        lpoz = QtWidgets.QLabel("Da li ste bili u kontaktu sa osobom koja je pozitivna na Covid-19? ")
        self.rbPoz1 = QtWidgets.QRadioButton("Da")
        self.rbPoz2 = QtWidgets.QRadioButton("Ne")
        self.grPoz = QtWidgets.QButtonGroup(self)
        self.grPoz.addButton(self.rbPoz1)
        self.grPoz.addButton(self.rbPoz2)
        hboxPoz.addWidget(lpoz)
        hboxPoz.addWidget(self.rbPoz1)
        hboxPoz.addWidget(self.rbPoz2)
        vbox.addLayout(hboxPoz)

        hboxSim = QtWidgets.QHBoxLayout()
        lsim = QtWidgets.QLabel("Da li ste bili u kontaktu sa osobom koja\n ima simptome Covida-19 ali se nije testirala? ")
        self.rbSim1 = QtWidgets.QRadioButton("Da")
        self.rbSim2 = QtWidgets.QRadioButton("Ne")
        self.grSim = QtWidgets.QButtonGroup(self)
        self.grSim.addButton(self.rbSim1)
        self.grSim.addButton(self.rbSim2)
        hboxSim.addWidget(lsim)
        hboxSim.addWidget(self.rbSim1)
        hboxSim.addWidget(self.rbSim2)
        vbox.addLayout(hboxSim)

        #kraj
        hboxKraj = QtWidgets.QHBoxLayout()
        self.pbGotovo = QtWidgets.QPushButton("Gotovo")
        self.pbPonovo = QtWidgets.QPushButton("Pocni ispocetka")
        hboxKraj.addWidget(self.pbGotovo)
        hboxKraj.addWidget(self.pbPonovo)
        vbox.addLayout(hboxKraj)
        
        self.pbGotovo.clicked.connect(self.ukupno)
        self.pbPonovo.clicked.connect(self.brisi)
Пример #26
0
 def on_btnAxisTitleColor_clicked(self):
    color=self.__curAxis.titleBrush().color()
    color=QColorDialog.getColor(color)
    if color.isValid():
       self.__curAxis.setTitleBrush(QBrush(color))
Пример #27
0
 def data(self, index: QModelIndex, role: Qt.ItemDataRole) -> QVariant:
     # note: this method is performance-critical.
     # it is called a lot, and so must run extremely fast.
     assert index.isValid()
     col = index.column()
     tx_item = self.transactions.value_from_pos(index.row())
     tx_hash = tx_item['txid']
     conf = tx_item['confirmations']
     txpos = tx_item['txpos_in_block'] or 0
     height = tx_item['height']
     try:
         status, status_str = self.tx_status_cache[tx_hash]
     except KeyError:
         tx_mined_info = self.tx_mined_info_from_tx_item(tx_item)
         status, status_str = self.parent.wallet.get_tx_status(tx_hash, tx_mined_info)
     if role == Qt.UserRole:
         # for sorting
         d = {
             HistoryColumns.STATUS_ICON:
                 # height breaks ties for unverified txns
                 # txpos breaks ties for verified same block txns
                 (conf, -status, -height, -txpos),
             HistoryColumns.STATUS_TEXT: status_str,
             HistoryColumns.DESCRIPTION: tx_item['label'],
             HistoryColumns.COIN_VALUE:  tx_item['value'].value,
             HistoryColumns.RUNNING_COIN_BALANCE: tx_item['balance'].value,
             HistoryColumns.FIAT_VALUE:
                 tx_item['fiat_value'].value if 'fiat_value' in tx_item else None,
             HistoryColumns.FIAT_ACQ_PRICE:
                 tx_item['acquisition_price'].value if 'acquisition_price' in tx_item else None,
             HistoryColumns.FIAT_CAP_GAINS:
                 tx_item['capital_gain'].value if 'capital_gain' in tx_item else None,
             HistoryColumns.TXID: tx_hash,
         }
         return QVariant(d[col])
     if role not in (Qt.DisplayRole, Qt.EditRole):
         if col == HistoryColumns.STATUS_ICON and role == Qt.DecorationRole:
             return QVariant(read_QIcon(TX_ICONS[status]))
         elif col == HistoryColumns.STATUS_ICON and role == Qt.ToolTipRole:
             return QVariant(str(conf) + _(" confirmation" + ("s" if conf != 1 else "")))
         elif col > HistoryColumns.DESCRIPTION and role == Qt.TextAlignmentRole:
             return QVariant(Qt.AlignRight | Qt.AlignVCenter)
         elif col != HistoryColumns.STATUS_TEXT and role == Qt.FontRole:
             monospace_font = QFont(MONOSPACE_FONT)
             return QVariant(monospace_font)
         elif col == HistoryColumns.DESCRIPTION and role == Qt.DecorationRole \
                 and self.parent.wallet.invoices.paid.get(tx_hash):
             return QVariant(read_QIcon("seal"))
         elif col in (HistoryColumns.DESCRIPTION, HistoryColumns.COIN_VALUE) \
                 and role == Qt.ForegroundRole and tx_item['value'].value < 0:
             red_brush = QBrush(QColor("#BC1E1E"))
             return QVariant(red_brush)
         elif col == HistoryColumns.FIAT_VALUE and role == Qt.ForegroundRole \
                 and not tx_item.get('fiat_default') and tx_item.get('fiat_value') is not None:
             blue_brush = QBrush(QColor("#1E1EFF"))
             return QVariant(blue_brush)
         return QVariant()
     if col == HistoryColumns.STATUS_TEXT:
         return QVariant(status_str)
     elif col == HistoryColumns.DESCRIPTION:
         return QVariant(tx_item['label'])
     elif col == HistoryColumns.COIN_VALUE:
         value = tx_item['value'].value
         v_str = self.parent.format_amount(value, is_diff=True, whitespaces=True)
         return QVariant(v_str)
     elif col == HistoryColumns.RUNNING_COIN_BALANCE:
         balance = tx_item['balance'].value
         balance_str = self.parent.format_amount(balance, whitespaces=True)
         return QVariant(balance_str)
     elif col == HistoryColumns.FIAT_VALUE and 'fiat_value' in tx_item:
         value_str = self.parent.fx.format_fiat(tx_item['fiat_value'].value)
         return QVariant(value_str)
     elif col == HistoryColumns.FIAT_ACQ_PRICE and \
             tx_item['value'].value < 0 and 'acquisition_price' in tx_item:
         # fixme: should use is_mine
         acq = tx_item['acquisition_price'].value
         return QVariant(self.parent.fx.format_fiat(acq))
     elif col == HistoryColumns.FIAT_CAP_GAINS and 'capital_gain' in tx_item:
         cg = tx_item['capital_gain'].value
         return QVariant(self.parent.fx.format_fiat(cg))
     elif col == HistoryColumns.TXID:
         return QVariant(tx_hash)
     return QVariant()
    def dissect(self):
        logging.info("Dissecting")
        p = subprocess.Popen(['python', f'{os.getcwd()}/demo.py'])
        try:
            if (self.name[0] and ".pcap" in self.name[0]):
                self.model.removeRows(0, self.model.rowCount())
                self.pushButton2.setText("ReDissect")
                self.label_3.setText("Status: Dissecting...: ")

                self.pyro_proxy.createPackets(self.name[0])
                self.label_3.setText("")

                self.pyro_proxy.dissectPackets()
                fileToRead = open(f'{os.getcwd()}/dictColor.log', "r")

                # fileToRead = open(os.getcwd() + "/src/main/python/UI/MainPane/dictColor.log","r")
                vars = json.loads(fileToRead.read().strip())
                packetDict = vars[0]
                protocolDict = vars[1]
                colorList = vars[2]
                color = QColor(255, 0, 0)  #red
                i = 0
                j = 0
                print(colorList)
                for pkt in colorList:

                    j = j + 1
                for number, packet in packetDict.items():
                    # branch2= QtGui.QStandardItem("Packet # " + str(number))
                    branch2 = sortableElement()
                    branch2.setData("Packet #" + str(number),
                                    QtCore.Qt.EditRole)
                    index = int(number) - 1
                    if colorList[str(index)] == "Green":
                        color = QColor(0, 255, 0)  #green
                    elif colorList[str(index)] == "Red":
                        color = QColor(255, 0, 0)  #red
                    else:
                        color = QColor(255, 255, 0)  #yellow
                    for protocol, fields in packet.items():
                        # ProtocolToAdd = QtGui.QStandardItem("Protocol:" + protocol)
                        ProtocolToAdd = sortableElement()
                        ProtocolToAdd.setData("Protocol: " + protocol,
                                              QtCore.Qt.EditRole)
                        ProtocolToAdd.setData(QBrush(color),
                                              QtCore.Qt.BackgroundRole)

                        for name, value in fields.items():
                            # ProtocolField = QtGui.QStandardItem(name)
                            # ProtocolValue = QtGui.QStandardItem(value)
                            ProtocolField = sortableElement()
                            ProtocolField.setData(name, QtCore.Qt.EditRole)

                            ProtocolValue = sortableElement()
                            ProtocolValue.setData(value, QtCore.Qt.EditRole)

                            ProtocolValue.setData(QBrush(color),
                                                  QtCore.Qt.BackgroundRole)
                            ProtocolField.setData(QBrush(color),
                                                  QtCore.Qt.BackgroundRole)

                            ProtocolToAdd.appendRow(
                                [ProtocolField, ProtocolValue])
                        branch2.appendRow(ProtocolToAdd)
                        branch2.setData(QBrush(color),
                                        QtCore.Qt.BackgroundRole)
                    numberCol = QtGui.QStandardItem(str(colorList[str(index)]))
                    self.model.appendRow([branch2, numberCol])
                    numberCol.setData(QBrush(color), QtCore.Qt.BackgroundRole)
                self.label_3.setText("Status: Package has been dissected.")
        except:
            pass
        p.terminate()
        logging.info("Dissected")
Пример #29
0
        def _troubleshoot_complete():
            _ = self.appdata._
            results = self.thread.result
            self.loading.close()

            if type(results) == None:
                self.widgets.open_dialog(
                    self.widgets.dialog_warning, _("Troubleshooting Failed"),
                    _("The troubleshooter for this backend is not available for this operating system."
                      ))
                return
            elif type(results) == str:
                self.widgets.open_dialog(
                    self.widgets.dialog_error, _("Troubleshooting Failed"),
                    _("An exception was thrown while running the troubleshooter. This is probably a bug."
                      ), None, results)
                return

            self.result_window = shared.get_ui_widget(self.appdata,
                                                      "troubleshooter",
                                                      QDialog)
            label = self.result_window.findChild(QLabel, "Title")
            tree = self.result_window.findChild(QTreeWidget, "Results")
            column = tree.invisibleRootItem()
            btn_copy = self.result_window.findChild(QPushButton,
                                                    "CopyToClipboard")

            if not self.appdata.system_qt_theme:
                self.result_window.findChild(QPushButton, "Close").setIcon(
                    self.widgets.get_icon_qt("general", "close"))

            all_passed = True
            for result in results:
                item = QTreeWidgetItem()

                # "passed" must be either: True (Passed); False (Failed); None (Unknown)
                if result["passed"] is True:
                    item.setText(0, _("Passed"))
                    item.setIcon(0,
                                 QIcon(common.get_icon("general", "success")))
                elif result["passed"] is False:
                    item.setText(0, _("Failed"))
                    item.setIcon(0,
                                 QIcon(common.get_icon("general", "serious")))
                else:
                    item.setText(0, _("Unknown"))
                    item.setIcon(0,
                                 QIcon(common.get_icon("general", "unknown")))

                item.setText(1, result["test_name"])
                item.copyable = False

                # Provide suggestions on failures
                if not result["passed"]:
                    all_passed = False

                    suggestions = result["suggestions"]
                    for line in suggestions:
                        subitem = QTreeWidgetItem()
                        if line.startswith("$"):
                            text = line
                            subitem.setBackground(1, QBrush(Qt.black))
                            subitem.setForeground(1, QBrush(Qt.green))
                            subitem.copyable = True
                        else:
                            text = "• " + line
                            subitem.setDisabled(True)
                        subitem.setText(1, text)
                        subitem.setToolTip(1, line)
                        item.addChild(subitem)
                column.addChild(item)

            # Commands can be copied to clipboard for convenience
            def _change_option():
                selected = tree.selectedItems()[0]
                btn_copy.setHidden(selected.copyable == False)

            tree.itemSelectionChanged.connect(_change_option)

            def _copy_to_clipboard():
                selected_text = tree.selectedItems()[0].text(1).replace(
                    "$ ", "")
                QApplication.clipboard().setText(selected_text)

            btn_copy.setHidden(True)
            btn_copy.clicked.connect(_copy_to_clipboard)

            def _close_troubleshooter():
                self.result_window.close()

            self.result_window.findChild(
                QPushButton, "Close").clicked.connect(_close_troubleshooter)

            tree.expandAll()
            self.result_window.setWindowTitle(
                _("Troubleshooter for []").replace("[]", self.human_name))
            if all_passed:
                label.setText(_("Everything appears to be in working order!"))
            self.result_window.open()
Пример #30
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle("BMI Calculator")
        self.setGeometry(500, 500, 500, 500)
        self.title = "BMI Calculator"
        self.setWindowIcon(QIcon('arm.ico'))
        bg = QImage("wall.jpg")
        bg1 = bg.scaled(QSize(500, 500))
        palette = QPalette()
        palette.setBrush(QPalette.Window, QBrush(bg1))
        self.setPalette(palette)
        self.textboxlbl = QLabel("<h3>Welcome to BMI Calculator<h3>", self)
        self.textboxlbl.setStyleSheet("color: yellow")
        self.textboxlbl.move(140, 20)
        self.textboxlbl.resize(300, 20)
        self.textboxlbl1 = QLabel("Please input your data:", self)
        self.textboxlbl1.setStyleSheet("color: yellow")
        self.textboxlbl1.move(175, 35)
        self.textboxlbl1.resize(300, 20)

        self.textbox10 = QLineEdit(self)
        self.textboxlbl10 = QLabel("<h3>First Name:<h3>", self)
        self.textboxlbl10.move(100, 79)
        self.textboxlbl0.setStyleSheet("color: yellow")
        self.textbox10.setText("")
        self.textbox10.move(180, 70)
        self.textbox10.resize(280, 30)

        self.textbox20 = QLineEdit(self)
        self.textboxlbl20 = QLabel("<h3>Last Name:<h3>", self)
        self.textboxlb20.setStyleSheet("color: yellow")
        self.textboxlbl20.move(100, 119)
        self.textbox20.setText("")
        self.textbox20.move(180, 110)
        self.textbox20.resize(280, 30)

        self.textbox30 = QLineEdit(self)
        self.textboxlbl30 = QLabel("<h3>Age:<h3>", self)
        self.textboxlbl30.setStyleSheet("color: yellow")
        self.textboxlbl30.move(100, 159)
        self.textbox30.setText("")
        self.textbox30.move(180, 150)
        self.textbox30.resize(280, 30)

        self.textbox40 = QLineEdit(self)
        self.textboxlbl40 = QLabel("<h3>Sex:<h3>", self)
        self.textboxlbl40.setStyleSheet("color: yellow")
        self.textboxlbl40.move(100, 199)
        self.textbox40.setText("")
        self.textbox40.move(180, 190)
        self.textbox40.resize(280, 30)

        self.textbox2 = QLineEdit(self)
        self.textboxlbl2 = QLabel("<h3>Height:<h3>", self)
        self.textboxlbl2.move(100, 239)
        self.textboxlbl2.setStyleSheet("color: yellow")
        self.textbox2.setText("")
        self.textbox2.move(180, 230)
        self.textbox2.resize(280, 30)

        self.textbox1 = QLineEdit(self)
        self.textboxlbl1 = QLabel("<h3>Weight:<h3>", self)
        self.textboxlbl1.move(100, 279)
        self.textboxlbl1.setStyleSheet("color: yellow")
        self.textbox1.setText("")
        self.textbox1.move(180, 270)
        self.textbox1.resize(280, 30)

        self.textbox3 = QLineEdit(self)
        self.textboxlbl3 = QLabel("<h3>Your Body Mass Index is:<h3>", self)
        self.textboxlbl3.setStyleSheet("color: yellow")
        self.textboxlbl3.move(20, 319)
        self.textboxlbl3.resize(300, 20)
        self.textbox3.setText("")
        self.textbox3.move(190, 310)
        self.textbox3.resize(280, 30)

        self.textbox4 = QLineEdit(self)
        self.textboxlbl4 = QLabel("<h3>Your Classification is:<h3>", self)
        self.textboxlbl4.setStyleSheet("color: yellow")
        self.textboxlbl4.move(20, 359)
        self.textboxlbl4.resize(300, 20)
        self.textbox4.setText("")
        self.textbox4.move(190, 350)
        self.textbox4.resize(200, 30)

        self.button = QPushButton('Submit', self)
        self.button.setToolTip("Submit your Information")
        self.button.setStyleSheet("background-color : skyblue")
        self.button.move(80, 450)
        self.button.clicked.connect(self.data)
        self.button1 = QPushButton('Clear', self)
        self.button1.setToolTip("Clear all your information")
        self.button1.setStyleSheet("background-color : skyblue")
        self.button1.move(200, 450)
        self.button1.clicked.connect(self.clear)
        self.button2 = QPushButton('Back', self)
        self.button2.setStyleSheet("background-color : skyblue")
        self.button2.setToolTip("Back to the main window")
        self.button2.move(320, 450)
        self.button2.clicked.connect(self.back)

        self.show()