Hi,

I don't totally understand all of the pyqtgraph GraphicsScene 
modifications, but you're right that the usual things you'd do for a 
QGraphicsScene don't seem to work.

Here's a crude way to disable mouse interactions, by live patching the 
legend mouse handler methods. I'm 99% sure this isn't the best way to do 
it, but it works.

# Crude patch of the legend mouse methods
import types
def nullifyEvent(self, ev):
    return None
self.legend.hoverEvent = types.MethodType(nullifyEvent, self.legend)
self.legend.mouseDragEvent = types.MethodType(nullifyEvent, self.legend)


Patrick

On Monday, 17 February 2020 02:09:07 UTC+10:30, clément Andre wrote:
>
> Hello,
> I am looking for create an IHM able to plotting many curves on each others 
> (so far no problem)
> in order to give good/clear informations to users, i would like to add 
> legend/items in a viewbox placed on the right of the plot (here again, no 
> problem).
>
> I am blocked concerning the position setting of the item in the viewbox...
> Indeed, I would like to fix the position of the legend in the viewbox
>
> here is two ways to create legend/items... but both present the an issue:
>
> self.column_legend = self.graph.addViewBox(border=QPen(QColor(255, 0, 0), 1, 
> Qt.SolidLine), enableMouse=False)
> self.column_legend.setMaximumWidth(80)
> self.legend = pg.LegendItem(size=(10, 20), offset=(1,1))
> self.legend.setParentItem(self.colonne_legende)
> self.column_legend.setMouseEnabled(x=False, y=False)
>
> here, i created wiewbox, legenditem... but despite the setting of 
> enableMouse to False, items are movable!
>
> self.column_legend = self.graph.addViewBox(border=QPen(QColor(255, 0, 0), 1, 
> Qt.SolidLine), enableMouse=False)
> self.column_legend.setMaximumWidth(80)
> self.legend = pg.LegendItem(size=(10, 20), offset=None)
> self.column_legend.addItem(self.legend)
> self.column_legend.setMouseEnabled(x=False, y=False)
>
> here, items are not movable!!! but offset need to set "None"... so the 
> position is bad...
>
> is there a solution to do what i am looking for?
> thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/da8f23e4-3cc8-41fd-a14a-34f9febe844f%40googlegroups.com.

Reply via email to