Package Camelot :: Package camelot :: Package view :: Package controls :: Module dashboard |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.controls.dashboard

     1  from PyQt4.QtGui import QApplication, QFrame, QPalette, QLabel, QPixmap
     2  from PyQt4.QtCore import Qt, QRect, SIGNAL, QCoreApplication
     3

     4

     5 -class BareFrame(QFrame):
     6

     7 -    def __init__(self, parent=None):
     8          super(BareFrame, self).__init__(parent)
     9          self.setWindowFlags(Qt.FramelessWindowHint)
    10          self.setFrameShadow(QFrame.Plain)
    11          self.setFrameShape(QFrame.Box)
    12          self.setLineWidth(1)
    13

    14 -    def setBGColor(self, color):
    15          pal = QCoreApplication.instance().palette()
    16          pal.setColor(QPalette.Window, color)
    17          self.setPalette(pal)
    18

    19

    20 -class CloseMark(QLabel):
    21

    22      WIDTH  = 31
    23      HEIGHT = 31
    24      MARGIN = 10
    25

    26 -    def __init__(self, pixmap, parent=None):
    27          super(CloseMark, self).__init__(parent)
    28          self.setPixmap(pixmap)
    29          self.toParentTopRight()
    30

    31 -    def mousePressEvent(self, event):
    32          self.parent().close()
    33

    34 -    def toParentTopRight(self):
    35          parent = self.parent()
    36          x = parent.width() - CloseMark.MARGIN - CloseMark.WIDTH
    37          y = CloseMark.MARGIN
    38          w = CloseMark.WIDTH
    39          h = CloseMark.HEIGHT
    40          self.setGeometry(QRect(x, y, w, h))
    41

    42

    43 -class Dashboard(BareFrame):
    44

    45      SCALE  = .85
    46

    47 -    def __init__(self, parent=None):
    48          super(Dashboard, self).__init__(parent)
    49          desktop = QCoreApplication.instance().desktop()
    50

    51          self.resize(desktop.width() * Dashboard.SCALE, desktop.height() * Dashboard.SCALE)
    52          self.closemark = CloseMark(QPixmap('close-mark.png'), self)
    53          self.setBGColor(Qt.white)
    54

    55

    56  if __name__ == '__main__':
    57      import sys
    58      app = QApplication(sys.argv)
    59      board = Dashboard()
    60      board.show()
    61      sys.exit(app.exec_())
    62