Esempio n. 1
0
class FaceMap(QtGui.QMainWindow):    
    def __init__(self, directory, deckName):
        super(FaceMap, self).__init__()
        self.dir = directory
        self.deckName = deckName
        self.statusBar()
        self.ankiWriteSignal = None
        # Use seconds since 1970 to uniquely identify image folder and images
        self.imageSetId = str(int(time.time()))
        self.initUI()
    
    # Make a drop-enabled window with a custom toolbar
    # along the left hand side   
    def initUI(self):
        self.setGeometry(100, 100, 600, 400)
        self.setWindowTitle('FaceMap - Deck: ' + self.deckName)
        self.addCustomToolBar()
        self.addCentralWidget()
        self.statusBar().showMessage("Ready")
        self.show()
        

    # Add a left-hand-side toolbar for the face_map actions
    def addCustomToolBar(self):
        iconsDir = os.path.join(self.dir, 'icons')
        newPersonIcon = os.path.join(iconsDir, 'new_person.jpg')
        newPerson = QtGui.QAction(QtGui.QIcon(newPersonIcon), 'New', self)
        newPerson.setShortcut('Ctrl+N')
        newPerson.triggered.connect(self.chooseFiles)
        
        saveImageIcon = os.path.join(iconsDir, 'save_pictures.jpg')
        saveImage = QtGui.QAction(QtGui.QIcon(saveImageIcon), 'Save', self)
        saveImage.setShortcut('Ctrl+S')
        saveImage.triggered.connect(self.saveImage)
        
        self.toolbar = QtGui.QToolBar()
        self.toolbar.addAction(newPerson)
        self.toolbar.addAction(saveImage)
        self.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolbar)
    
    # Add a central widget with no (default absolute) layout
    def addCentralWidget(self):
        self.centralWidget = CentralWidget(self, self.imageSetId)
        self.setCentralWidget(self.centralWidget)
        
    
    # Create a file-chooser dialog to pick images
    def chooseFiles(self):
        self.statusBar().showMessage("Processing...")
        fnames = QtGui.QFileDialog.getOpenFileNames(self, 'Open file', 
                '/home', 'Image Files (*.png *.jpg *.bmp, *gif)')
        for fname in fnames:
            if fname:
                self.centralWidget.addDraggableFrame(fname)
        self.statusBar().showMessage("Ready")
                
    # Save images to the media folder
    # If we are running within Anki, signal to AnkiWriter
    # to create cards from the images
    def saveImage(self):
        self.statusBar().showMessage("Processing...")
        self.centralWidget.createQuestionAnswerImages(self.dir)
        self.statusBar().showMessage("Finished")
        if self.ankiWriteSignal:
            self.ankiWriteSignal.emit()
        self.popupGoodbyeDialog()
                  
    # Set the signal to be called once writing of images finishes
    def setAnkiWriteSignal(self, signal):
        self.ankiWriteSignal = signal
        
    # Get the imageSetId - the number identifying the folder and the images created
    def getImageSetId(self):
        return self.imageSetId
    
    # Popup a dialog to say the window will close
    def popupGoodbyeDialog(self):
        reply = QtGui.QMessageBox.question(self, 'Success',
    "FaceMap has successfully\ncompleted. Goodbye!", QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
        self.close()
Esempio n. 2
0
    def repaint(self):

        self.setWindowTitle("Vulnerability Scanner (VSBOT)")
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setMinimumHeight(334)
        self.setMinimumWidth(500)
        self.resize(500, 334)

        #style
        self.setStyleSheet("\
    QMainWindow {\
      background: #e2e2e2;\
      border: 1px solid #cecdcd;\
    }\
    \
    QWidget {\
      font-size: 13px;\
      font-family: \"Arial\";\
    }\
    \
    QWidget#eFullBlendWidget {\
      background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,\
                  stop: 0 #a1c517, stop: 0.25 #009045,\
                  stop: 0.5 #0082b6, stop: 0.75 #151f77,\
                  stop: 1.0 #db004f);\
    }\
    \
    QWidget#eHeaderWidget {\
      background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\
                  stop: 0 #ffffff,\
                  stop: 1.0 #cecdcd);\
    }\
    QTabWidget#menuTabWidget::pane {\
      background: #ffffff;\
      border: none;\
    }\
    \
    QTabBar::tab {\
      background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\
                    stop: 0 #f3f3f3, stop: 1.0 #d4d4d4);\
      border-top: none;\
      border-left: 1px solid #e6e7e8;\
      border-bottom: 2px solid #b9bbbb;\
      border-right: 2px solid #b9bbbb;\
      max-height: 48px;\
      padding: 4px;\
    }\
    \
    QTabBar::tab:selected {\
      background: #ffffff;\
      border: none;\
      border-bottom: 2px solid #b9bbbb;\
    }\
    \
    QLabel#titleLabel {\
      color: #00285e;\
    }\
    \
    QPushButton {\
      color: #ffffff;\
      border: 1px solid #bfbebe;\
      border-radius: 6px;\
      padding-top: 7px;\
      padding-bottom: 8px;\
      padding-left: 10px;\
      padding-right: 10px;\
      min-width: 67px;\
      background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\
                  stop: 0.0 #ffffff,\
                  stop: 0.1 #abbfd4,\
                  stop: 0.2 #316196,\
                  stop: 0.9 #1b3d6f,\
                  stop: 1.0 #1d335a);\
    }\
    \
    QPushButton:hover {\
      border: 3px solid #00a9d4;\
      background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\
                  stop: 0.0 #ffffff,\
                  stop: 0.1 #98d5ea,\
                  stop: 0.2 #0697cb,\
                  stop: 1.0 #0a5097);\
    }\
    \
    QPushButton:pressed {\
      border: 1px solid #bfbebe;\
      background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\
                  stop: 0.0 #ffffff,\
                  stop: 0.1 #abbfd4,\
                  stop: 0.2 #316196,\
                  stop: 0.9 #316196,\
                  stop: 1.0 #1d335a);\
    }\
    \
    QPushButton#minimizeButton, QPushButton#maximizeButton, QPushButton#closeButton {\
      min-width: 0px;\
      background: none;\
      border: none;\
    }\
    \
    QTreeView::branch:open:has-children {\
      image: url(icons/arrowdown.png);\
    }\
    \
    QTreeView::branch:closed:has-children {\
      image: url(icons/arrowright.png);\
    }/*\
    \
    QScrollBar:vertical {\
	    border: none;\
	    margin: 20px 0px 20px 0px;\
	  }\
	  \
    QScrollBar::add-line:vertical {\
	    image: url(icons/arrowdown.png);\
	  }\
    \
    QScrollBar::sub-line:vertical {\
	    image: url(icons/arrowup.png);\
	  }*/")

        self.centralWidget = CentralWidget()
        QObject.connect(self.centralWidget, SIGNAL("minimizeClicked()"),
                        self.minimize)
        QObject.connect(self.centralWidget, SIGNAL("maximizeClicked()"),
                        self.maximize)
        QObject.connect(self.centralWidget, SIGNAL("closeClicked()"),
                        self.close)

        self.setCentralWidget(self.centralWidget)
        self.show()
Esempio n. 3
0
 def addCentralWidget(self):
     self.centralWidget = CentralWidget(self, self.imageSetId)
     self.setCentralWidget(self.centralWidget)