Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
            self.but_elog.setStyleSheet(cp.styleButton) 
            self.but_elog.setEnabled(False)
            self.repaint()

Dialog boxes

For password

Code Block
    app = QtGui.QApplication(sys.argv)
    w = QtGui.QInputDialog()
    w.show()
    msg = 'To use %s and submitt messages in ELog\nauthentication for user %s is required\nPassword:' % (sys.argv[0], opts.usr)
    text, ok = w.getText(None, 'Authentication', msg, QtGui.QLineEdit.Password)
    w.close()
...

 

Graphics in PyQt4

Code Block
...
        self.poi1  = QtCore.QPoint(0,0)
        self.poi2  = QtCore.QPoint(0,0)
        self.rect1 = QtCore.QRect()
        self.rect2 = QtCore.QRect()

        self.pen1 = QtGui.QPen(QtCore.Qt.black) 
        self.pen2 = QtGui.QPen(QtCore.Qt.white) 
        self.pen1.setStyle(QtCore.Qt.DashLine) 
        self.pen2.setStyle(QtCore.Qt.DashLine) 
        self.pen1.setWidthF(1) 
        self.pen2.setWidthF(1)
...

     def paintEvent(self, e):
        super(GUIImage,self).paintEvent(e)
        qp = QtGui.QPainter()
        # or QPainter can be defined earlier and use it as   qp = self.qp
        qp.begin(self)
        #self.drawPixmap(qp)
        self.drawRect(qp)
        qp.end()
        self.update()

    def setPen(self, qp):
        self.pen.setStyle(QtCore.Qt.DashLine) 
        self.pen.setWidthF(1) 

    def drawRect(self, qp):
        if self.r_pixmap == None:
            return

        p1x, p1y = self.poi1.x(), self.poi1.y()
        p2x, p2y = self.poi2.x(), self.poi2.y()

        R=1
        if abs(p2x-p1x) < R : return
        if abs(p2y-p1y) < R : return

        self.rect1.setCoords( p1x,   p1y,   p2x,   p2y)
        self.rect2.setCoords( p1x+1, p1y+1, p2x-1, p2y-1)
        qp.setPen  (self.pen1)
        qp.drawRect(self.rect1);
        qp.setPen  (self.pen2)
        qp.drawRect(self.rect2);


    def drawPixmap(self, qp):
        if self.r_pixmap != None:
            qp.drawPixmap(0,0,self.s_pixmap)

...