Пример #1
0
	def __init__( self, parent ):
		QScrollArea.__init__( self, parent )

		#self.setFrameShape( QScrollArea.NoFrame )
		self.setAutoFillBackground( False )
		self.setWidgetResizable( True )
		self.setMouseTracking(True)
		self.verticalScrollBar().setMaximumWidth(10)

#		from PyQt4.QtGui import QWidget
		widget = QWidget( self )

		# define custom properties
		self._rolloutStyle 	= AccordianWidget.Rounded
		self._dragDropMode 	= AccordianWidget.NoDragDrop
		self._scrolling		= False
		self._scrollInitY	= 0
		self._scrollInitVal	= 0
		self._itemClass		= AccordianItem

		# create the layout
#		from PyQt4.QtGui import QVBoxLayout

		layout = QVBoxLayout()
		layout.setContentsMargins( 3, 3, 3, 3 )
		layout.setSpacing( 3 )
		layout.addStretch(1)

		widget.setLayout( layout )

		self.setWidget( widget )
Пример #2
0
    def __init__(self, parent=None, direction="ltr", rtf=False):
        """ Creates a new QPageWidget on given parent object. 

        parent: QWidget parent
        direction: "ltr" -> Left To Right
                   "ttb" -> Top To Bottom
        rtf: Return to first, if its True it flips to the first page 
             when next page requested at the last page
        """
        # First initialize, QPageWidget is based on QScrollArea
        QScrollArea.__init__(self, parent)

        # Properties for QScrollArea
        self.setFrameShape(QFrame.NoFrame)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidgetResizable(True)

        # Main widget, which stores all Pages in it
        self.widget = QWidget(self)

        # Layout based on QBoxLayout which supports Vertical or Horizontal layout
        if direction == "ltr":
            self.layout = QBoxLayout(QBoxLayout.LeftToRight, self.widget)
            self.__scrollBar = self.horizontalScrollBar()
            self.__base_value = self.width
        else:
            self.layout = QBoxLayout(QBoxLayout.TopToBottom, self.widget)
            self.__scrollBar = self.verticalScrollBar()
            self.__base_value = self.height
        self.layout.setSpacing(0)
        self.layout.setMargin(0)

        # Return to first
        self.__return_to_first = rtf

        # TMP_PAGE, its using as last page in stack
        # A workaround for a QScrollArea bug
        self.__tmp_page = Page(QWidget(self.widget))
        self.__pages = [self.__tmp_page]
        self.__current = 0
        self.__last = 0

        # Set main widget
        self.setWidget(self.widget)

        # Animation TimeLine
        self.__timeline = QTimeLine()
        self.__timeline.setUpdateInterval(2)

        # Updates scrollbar position when frame changed
        self.__timeline.frameChanged.connect(
            lambda x: self.__scrollBar.setValue(x))

        # End of the animation
        self.__timeline.finished.connect(self._animateFinished)

        # Initialize animation
        self.setAnimation()
        self.setDuration()
Пример #3
0
    def __init__(self, parent):
        QScrollArea.__init__(self, parent)

        self.setFrameShape(QScrollArea.NoFrame)
        self.setAutoFillBackground(False)
        self.setWidgetResizable(True)
        self.setMouseTracking(True)
        #self.verticalScrollBar().setMaximumWidth(10)

        widget = QWidget(self)

        # define custom properties
        self._rolloutStyle = AccordionWidget.Rounded
        self._dragDropMode = AccordionWidget.NoDragDrop
        self._scrolling = False
        self._scrollInitY = 0
        self._scrollInitVal = 0
        self._itemClass = AccordionItem
        self._items = {}

        layout = QVBoxLayout()
        layout.setContentsMargins(2, 2, 2, 2)
        layout.setSpacing(2)
        layout.addStretch(1)

        widget.setLayout(layout)

        self.setWidget(widget)
Пример #4
0
    def __init__(self, items, parent, insertionMode=False):
        QScrollArea.__init__(self, parent)
        self._editor = parent
        self._items = items
        self._insertion_mode = insertionMode

        # Find all classes
        self._label_classes = set([item['class'] for item in items if 'class' in item])
        n_classes = len(self._label_classes)
        LOG.debug("Creating editor for %d item classes: %s" % (n_classes, ", ".join(list(self._label_classes))))

        # Widget layout
        self._layout = QVBoxLayout()
        self._content = QWidget()
        self._content.setLayout(self._layout)

        attributes = set()
        for lc in self._label_classes:
            attributes |= set(self._editor.getLabelClassAttributes(lc))

        for attr in attributes:
            handler = self._editor.getHandler(attr)
            if handler is not None:
                if len(items) > 1:
                    valid_items = [item for item in items if attr in self._editor.getLabelClassAttributes(item['class'])]
                    handler.setItems(valid_items, True)
                else:
                    handler.setItems(items)
                self._layout.addWidget(handler)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidgetResizable(True)
        self.setWidget(self._content)
Пример #5
0
    def __init__(self, items, parent, insertionMode=False):
        QScrollArea.__init__(self, parent)
        self._editor = parent
        self._items = items
        self._insertion_mode = insertionMode

        # Find all classes
        self._label_classes = set([item['class'] for item in items if 'class' in item])
        n_classes = len(self._label_classes)
        LOG.debug("Creating editor for %d item classes: %s" % (n_classes, ", ".join(list(self._label_classes))))

        # Widget layout
        self._layout = QVBoxLayout()
        self._content = QWidget()
        self._content.setLayout(self._layout)

        attributes = set()
        for lc in self._label_classes:
            attributes |= set(self._editor.getLabelClassAttributes(lc))

        for attr in attributes:
            handler = self._editor.getHandler(attr)
            if handler is not None:
                if len(items) > 1:
                    valid_items = [item for item in items if attr in self._editor.getLabelClassAttributes(item['class'])]
                    handler.setItems(valid_items, True)
                else:
                    handler.setItems(items)
                self._layout.addWidget(handler)
                self._layout.addWidget(handler)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidgetResizable(True)
        self.setWidget(self._content)
Пример #6
0
    def __init__(self, parent = None, direction = "ltr", rtf = False):
        """ Creates a new QPageWidget on given parent object. 

        parent: QWidget parent
        direction: "ltr" -> Left To Right
                   "ttb" -> Top To Bottom
        rtf: Return to first, if its True it flips to the first page 
             when next page requested at the last page
        """
        # First initialize, QPageWidget is based on QScrollArea
        QScrollArea.__init__(self, parent)

        # Properties for QScrollArea
        self.setFrameShape(QFrame.NoFrame)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidgetResizable(True)

        # Main widget, which stores all Pages in it
        self.widget = QWidget(self)

        # Layout based on QBoxLayout which supports Vertical or Horizontal layout
        if direction == "ltr":
            self.layout = QBoxLayout(QBoxLayout.LeftToRight, self.widget)
            self.__scrollBar = self.horizontalScrollBar()
            self.__base_value = self.width
        else:
            self.layout = QBoxLayout(QBoxLayout.TopToBottom, self.widget)
            self.__scrollBar = self.verticalScrollBar()
            self.__base_value = self.height
        self.layout.setSpacing(0)
        self.layout.setMargin(0)

        # Return to first
        self.__return_to_first = rtf

        # TMP_PAGE, its using as last page in stack
        # A workaround for a QScrollArea bug
        self.__tmp_page = Page(QWidget(self.widget))
        self.__pages = [self.__tmp_page]
        self.__current = 0
        self.__last = 0

        # Set main widget
        self.setWidget(self.widget)

        # Animation TimeLine
        self.__timeline = QTimeLine()
        self.__timeline.setUpdateInterval(2)

        # Updates scrollbar position when frame changed
        self.__timeline.frameChanged.connect(lambda x: self.__scrollBar.setValue(x))

        # End of the animation
        self.__timeline.finished.connect(self._animateFinished)

        # Initialize animation
        self.setAnimation()
        self.setDuration()
Пример #7
0
    def __init__(self, items, parent, config, insertionMode=False):
        QScrollArea.__init__(self, parent)
        self._editor = parent
        self._items = items
        self._insertion_mode = insertionMode
        self._class_config = config

        # Find all classes
        self._label_classes = set(
            [item['class'] for item in items if 'class' in item])
        n_classes = len(self._label_classes)
        LOG.debug("Creating editor for %d item classes: %s" %
                  (n_classes, ", ".join(list(self._label_classes))))

        # Widget layout
        self._layout = QVBoxLayout()
        self._content = QWidget()
        self._content.setLayout(self._layout)

        attributes = set()
        for lc in self._label_classes:
            attributes |= set(self._editor.getLabelClassAttributes(lc))

        attributes = list(attributes)
        attributes.sort()
        for attr in attributes:
            handler = self._editor.getHandler(attr)
            # YW - Customise, to handle attributes differently
            if attr == 'id':
                self._handler_parent = handler.parent
                classLabel = list(self._label_classes)[0]
                supportedIds = config[classLabel]['attributes'][attr]
                for btnStr in handler._buttons:
                    if btnStr not in supportedIds:
                        handler._buttons[btnStr].hide()
                    else:
                        handler._buttons[btnStr].show()

            if handler is not None:
                if len(items) > 1:
                    valid_items = [
                        item for item in items if attr in
                        self._editor.getLabelClassAttributes(item['class'])
                    ]
                    handler.setItems(valid_items, True)
                else:
                    handler.setItems(items)
                self._layout.addWidget(handler)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidgetResizable(True)
        self.setWidget(self._content)
Пример #8
0
    def __init__(self, weboob, parent=None):
        QScrollArea.__init__(self, parent)

        self.weboob = weboob

        self.setFrameShadow(self.Plain)
        self.setFrameShape(self.NoFrame)
        self.setWidgetResizable(True)

        widget = QWidget(self)
        widget.setLayout(QVBoxLayout())
        widget.show()
        self.setWidget(widget)
Пример #9
0
 def __init__(self, parent=None):
     QScrollArea.__init__(self, parent)
     self.s = 100
     self.setMinimumSize(0, 0)
     self.__max = 250
     self.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum))
     self.__w = QWidget()
     self.setWidget(self.__w)
     self.setWidgetResizable(True)
     self.__w.setLayout(QVBoxLayout())
     self.__w.layout().setContentsMargins(0, 0, 0, 0)
     self.setFrameShape(QFrame.NoFrame)
     self.__recalcSize()
Пример #10
0
    def __init__(self, weboob, parent=None):
        QScrollArea.__init__(self, parent)

        self.weboob = weboob

        self.setFrameShadow(self.Plain)
        self.setFrameShape(self.NoFrame)
        self.setWidgetResizable(True)

        widget = QWidget(self)
        widget.setLayout(QVBoxLayout())
        widget.show()
        self.setWidget(widget)
Пример #11
0
    def __init__(self):
        QScrollArea.__init__(self)

        self.setWidgetResizable(True)

        scroll_widget = QWidget()
        self.scroll_box_layout = QVBoxLayout(scroll_widget)
        self.setWidget(scroll_widget)

        self.scroll_box_layout.setSpacing(2)
        self.scroll_box_layout.setMargin(2)

        self.scroll_box_layout.setAlignment(Qt.AlignTop)
        self.scroll_box_layout.setSizeConstraint(QtGui.QLayout.SetMaximumSize)
 def __init__(self, parent=None):
     QScrollArea.__init__(self, parent)
     self.s = 100
     self.setMinimumSize(0, 0)
     self.__max = 250
     self.setSizePolicy(
         QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum))
     self.__w = QWidget()
     self.setWidget(self.__w)
     self.setWidgetResizable(True)
     self.__w.setLayout(QVBoxLayout())
     self.__w.layout().setContentsMargins(0, 0, 0, 0)
     self.setFrameShape(QFrame.NoFrame)
     self.__recalcSize()
Пример #13
0
    def __init__(self):
        QScrollArea.__init__(self)

        self.setWidgetResizable(True)

        scroll_widget = QWidget()
        self.scroll_box_layout = QVBoxLayout(scroll_widget)
        self.setWidget(scroll_widget)

        self.scroll_box_layout.setSpacing(2)
        self.scroll_box_layout.setMargin(2)

        self.scroll_box_layout.setAlignment(Qt.AlignTop)
        self.scroll_box_layout.setSizeConstraint(QtGui.QLayout.SetMaximumSize)
Пример #14
0
    def __init__( self, parent = None ):
        QScrollArea.__init__( self, parent )

        self.pixmapLabel = QLabel()
        self.pixmapLabel.setBackgroundRole( QPalette.Base )
        self.pixmapLabel.setSizePolicy( QSizePolicy.Ignored,
                                        QSizePolicy.Ignored )
        self.pixmapLabel.setScaledContents( True )

        self.zoom = 1.0
        self.info = ""
        self.formatInfo = ""
        self.fileSize = 0

        self.setBackgroundRole( QPalette.Dark )
        self.setWidget( self.pixmapLabel )
        self.setAlignment( Qt.AlignCenter )
        return
Пример #15
0
    def __init__(self, parent=None, photo_path=""):
        QScrollArea.__init__(self, parent)
        self.setBackgroundRole(QPalette.Dark)

        self._printer = QPrinter()

        self._lbl_photo = QLabel()
        self._lbl_photo.setBackgroundRole(QPalette.Base)
        self._lbl_photo.setSizePolicy(QSizePolicy.Ignored,QSizePolicy.Ignored)
        self._lbl_photo.setScaledContents(True)

        self.setWidget(self._lbl_photo)

        self._photo_path = photo_path
        self._ph_image = None
        self._scale_factor = 1.0
        self._aspect_ratio = -1

        self._create_actions()

        if self._photo_path:
            self.load_document(self._photo_path)
Пример #16
0
 def __init__(self, *args, **kwargs):
     QScrollArea.__init__(self, *args, **kwargs)
     self.viewport().setMouseTracking(True)
     self.setMouseTracking(True)
     self.setWidget(QWidget())
     self.widget().setLayout(QGridLayout())
Пример #17
0
 def __init__(self):
     QScrollArea.__init__(self)
     BaseWidget.__init__(self)
Пример #18
0
 def __init__(self):
     QScrollArea.__init__(self)
     self.lastMouse = None
Пример #19
0
	def __init__(self, img=None):
		QScrollArea.__init__(self)

		# Déclaration du drapeau: a-t-on chargé un *.gif
		if img and os.path.splitext(img)[1]!=".gif":
			self.gif = 1
		else:
			self.gif = 0
		
		# Facteur de redimensionnement de l'image à afficher par rapport à la taille réelle de l'image
		self.factor = 1
		
		# Variables de paramètres
		self.modeTransformation=Qt.SmoothTransformation
		#self.modeTransformation=Qt.FastTransformation
		
		# widget qui contiendra l'image
		self.imageLabel = QLabel()
		self.imageLabel.setAlignment(Qt.AlignCenter)
		
		self.setBackgroundRole(QPalette.Dark)
		self.setWidget(self.imageLabel)
		# Indispensable pour ne pas avoir d'images tronquées, lors du chargement de nvll img
		self.setWidgetResizable(True)
		
		# Position du curseur dans le QScrollArea au moment du clic de la souris
		self.positionPresseeSourisIni = QPoint()
		# Position du point haut-gauche du QScrollArea par rapport au QPixMap entier au
		# moment du clic de la souris (par la suite appelée "position de la barre de défilement")
        	self.positionBarrePresseeSourisIni = QPoint()
		
		# Création du menu contextuel
		self.menuZoom=QMenu("Zoom")
		
		# Entrée zoom taille réelle
		self.menuTailleReelle=self.menuZoom.addAction(_(u'&Taille Réelle'))
		self.menuTailleReelle.setIcon(QIcon("Icones" + os.sep + "taillereelle.png"))
		self.connect(self.menuTailleReelle, SIGNAL("triggered()"), self.setTailleReelle)
		
		# Entrée zoom taille fenetre
		self.menuTailleFenetre=self.menuZoom.addAction(_(u'&Adapter à la fenêtre'))
		self.menuTailleFenetre.setIcon(QIcon("Icones" + os.sep + "fenetre.png"))
		self.connect(self.menuTailleFenetre, SIGNAL("triggered()"), self.setTailleFenetre)
	
		# Entrée zoom +
		self.menuZoomPlus=self.menuZoom.addAction(_(u'&Zoom Avant'))
		self.menuZoomPlus.setIcon(QIcon("Icones" + os.sep + "zoomplus.png"))
		self.connect(self.menuZoomPlus, SIGNAL("triggered()"), self.zoomAvant)
		
		# Entrée zoom - 
		self.menuZoomMoins=self.menuZoom.addAction(_(u'&Zoom Arrière'))
		self.menuZoomMoins.setIcon(QIcon("Icones" + os.sep + "zoommoins.png"))
		self.connect(self.menuZoomMoins, SIGNAL("triggered()"), self.zoomArriere)
		
		# Entrée mettre en pause/démarrer l'animation du gif
		self.menuStartPauseGif=self.menuZoom.addAction(_(u"Mettre en pause/démarrer l'animation"))
		self.menuStartPauseGif.setIcon(QIcon("Icones" + os.sep + "player_end.png"))
		self.connect(self.menuStartPauseGif, SIGNAL("triggered()"), self.startPauseGif)
			
		# Entrée mettre en pause/démarrer l'animation du gif
		self.menuStopGif=self.menuZoom.addAction(_(u"Arrêter l'animation"))
		self.menuStopGif.setIcon(QIcon("Icones" + os.sep + "player_stop.png"))
		self.connect(self.menuStopGif, SIGNAL("triggered()"), self.stopGif)
		
		# On cache les 2 menus de *.gif si on ne traite pas ce format
		if not self.gif:
			self.menuStartPauseGif.setVisible(False)
			self.menuStopGif.setVisible(False)
		
		# Si une image est en paramètre de classe, on l'affiche directement
		# sinon on pourra toujours l'afficher plus tard en appelant la
		# méthode setImage(), le moment venu
		if img:
			self.setImage(img)
			self.setToolTip(img)
		else:
			# image par défaut
			self.setImage("Icones" + os.sep + "avant-image.png")
			self.setToolTip(_(u"image d'accueil"))
			self.setTailleReelle()
Пример #20
0
 def __init__(self, *args, **kwargs):
     QScrollArea.__init__(self, *args, **kwargs)
     self.viewport().setMouseTracking(True)
     self.setMouseTracking(True)
     self.setWidget(QWidget())
     self.widget().setLayout(QGridLayout())