Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with mouse events over pg plots in taurus guis #905

Closed
cmft opened this issue Apr 15, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@cmft
Copy link
Member

commented Apr 15, 2019

The mouse events (right click) in the pyqtgraph.PlotWidget seem do not work when the PlotWidget is part of a TaurusGui.

You can reproduce the bug with this snippet:

import sys
from taurus.external.qt import Qt
import pyqtgraph as pg


def qapp():
    app = Qt.QApplication(sys.argv)
    mainWin = Qt.QMainWindow()
    plot = pg.PlotWidget()
    dock = Qt.QDockWidget('Plot', None)
    dock.setWidget(plot)
    mainWin.addDockWidget(Qt.Qt.TopDockWidgetArea, dock)
    mainWin.show()
    sys.exit( app.exec_() )


def tapp():
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.qt.qtgui.taurusgui import TaurusGui
    app = TaurusApplication()
    mainWin = TaurusGui()
    plot = pg.PlotWidget()
    dock = Qt.QDockWidget('Plot', None)
    dock.setWidget(plot)
    mainWin.addDockWidget(Qt.Qt.TopDockWidgetArea, dock)
    mainWin.show()
    sys.exit( app.exec_() )


if __name__ == "__main__":
    # qapp() # Works
    tapp()   # Does not work
@cmft

This comment has been minimized.

Copy link
Member Author

commented Apr 15, 2019

The taurusgui example can be simplified changing

    dock = Qt.QDockWidget('Plot', None)
    dock.setWidget(plot)
    mainWin.addDockWidget(Qt.Qt.TopDockWidgetArea, dock)

by

    mainWin.createPanel(plot, 'plot')
@cmft

This comment has been minimized.

Copy link
Member Author

commented Apr 15, 2019

The problem can also be reproduced using TaurusMainWindow instead of TaurusGui

@cmft

This comment has been minimized.

Copy link
Member Author

commented Apr 16, 2019

The problem happens when taurusMenu is create (in TaurusMainWindow.__init__ method):

        if self._showTaurusMenu:  # Taurus Menu
            self.createTaurusMenu()

Since if it is not None the popup menu event are catched in TaurusBaseComponent class:

    def contextMenuEvent(self, event):
        """Handle the popup menu event

        :param event: the popup menu event
        """
        if self.taurusMenu is not None:
            self.taurusMenu.exec_(event.globalPos())
        else:
            event.ignore()
@cpascual

This comment has been minimized.

Copy link
Member

commented Apr 16, 2019

#906 should fix this (the following snippet did not allow to show the context menu before and is fixed with #906)

import sys
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.container import TaurusMainWindow
import pyqtgraph as pg

app = TaurusApplication()
mainWin = TaurusMainWindow()
plot = pg.PlotWidget()
mainWin.setCentralWidget(plot)
mainWin.show()
sys.exit( app.exec_() )

Thanks to @cmft for pointing out the root of the issue

@reszelaz reszelaz closed this in 0008a24 Apr 23, 2019

@cpascual cpascual added this to the Jul19 milestone Apr 23, 2019

@cpascual cpascual added the bug label Apr 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.