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

Is it possible to embed MNEQtBrowser directly in PyQt UI>> QWidget/QFrame/QGraphicsScene/ Custom Widgets? #117

Closed
vsltech opened this issue Apr 22, 2022 · 1 comment

Comments

@vsltech
Copy link

vsltech commented Apr 22, 2022

E.G: I have added a basic Ui where I want to Embedded MNEQtBrowser into a QWidget/QFrame/QGraphicsView/QLayout whichever is possible?
er1

Code Snippet to Run Ui:
graph.zip

from PyQt5 import QtCore,QtGui,QtWidgets, uic
from PyQt5.QtWidgets import  QFileDialog,QWidget, QLineEdit,QLabel, QApplication,QAction,QMainWindow,QMessageBox
from PyQt5.QtCore import QThread, Qt, pyqtSignal, pyqtSlot,QRect, Qt ,QLine,QEvent
from PyQt5.QtGui import QImage,QPixmap,QIcon,QPainter, QPen

import sys,cv2,requests,uuid,os,csv
from pathlib import Path
import mne

sample_dir = mne.datasets.sample.data_path()
raw_path = Path(sample_dir) / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw(raw_path,preload=True)

# ============================================================================       
class Ui(QMainWindow):
    def __init__(self):
        super(Ui, self).__init__()      
        uic.loadUi("graph.ui", self)
        ###################################
        self.cam1_stat = 0
        self.label_list=[]
        self.fps=0
        self.start_stat=False
        self.lan = "English"
        self.sc = "1"
        self.cam_url = None
        
        self.desktop = QApplication.desktop()
        self.screenRect = self.desktop.screenGeometry()
        self.w = self.screenRect.width()
        self.h = self.screenRect.height()        
        ##################################
        
        ###################################
        fig = raw.plot(show=False)
        fig.update_plot_ui(1400,950,90)
        self.show()
        #fig = raw.plot(remove_dc=False,show=True,block=True,show_options=False,theme='dark',title=None,proj=False) #,bgcolor='gray',bad_color='lightgray')
        self.graphicsView.setLayout(fig)
        self.frame.setLayout(fig)
        self.stackedWidget.setLayout(fig)
        self.centralwidget.setLayout(fig)
        #######################################   
        #self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.move(0, 0)
        #self.setMaximumSize(self.w,self.h)
        self.show()
        #print(self.w,self.h)
        #self.showFullScreen()

                
        
if __name__ == '__main__':   
    app = QApplication(sys.argv)
    ex = Ui()
    #ex.show()
    sys.exit(app.exec_())

If not possible then what's the best way to do this but not using matplotlib?

@vsltech vsltech changed the title Is it possible to qt browser directly in our PyQt Widgets/QGraphicsScene/ Custom Widgets? Is it possible to embed MNEQtBrowser directly in PyQt UI>> QWidget/QFrame/QGraphicsScene/ Custom Widgets? Apr 22, 2022
@marsipu
Copy link
Member

marsipu commented Apr 22, 2022

@vsltech Yes it should be possible to add the MNEQtBrowser-instance as a widget to your application.
block=False is needed to work because otherwise your custom application probably won't be shown.

layout = <your layout>
fig = raw.plot(block=False)
layout.addWidget(fig)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants