Esempio n. 1
0
    def _set_stylesheet_background(self):
        '''
        Will set proper sylesheet based on edit status to have
        fixed size background in edit mode and stretchable in anim mode
        '''
        if not self.background:
            self.setStyleSheet("")
            return

        bg = self.background
        if __EDIT_MODE__.get():
            edit_css = "QLabel {background-image: url('{}'); background-repeat: no repeat;}".format(
                bg)
            self.setStyleSheet(edit_css)
        else:
            self.setStyleSheet("QLabel {border-image: url('{}');}".format(bg))
Esempio n. 2
0
    def contextMenuEvent(self, event):
        '''Right click menu options
        '''
        # Abort in non edit mode
        if not __EDIT_MODE__.get():
            return

        # Init context menu
        menu = QtWidgets.QMenu(self)

        # Add choose action
        choose_action = QtWidgets.QAction("Select Picture", None)
        choose_action.triggered.connect(self.select_image)
        menu.addAction(choose_action)

        # Add reset action
        reset_action = QtWidgets.QAction("Reset", None)
        reset_action.triggered.connect(self.reset_image)
        menu.addAction(reset_action)

        # Open context menu under mouse
        if not menu.isEmpty():
            menu.exec_(self.mapToGlobal(event.pos()))