Changeset 4992ff2 in sasview for src/sas/qtgui/MainWindow


Ignore:
Timestamp:
Nov 9, 2017 8:43:07 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
7969b9c
Parents:
7fb471d
git-author:
Piotr Rozyczko <rozyczko@…> (10/30/17 07:50:09)
git-committer:
Piotr Rozyczko <rozyczko@…> (11/09/17 08:43:07)
Message:

Initial, in-progress version. Not really working atm. SASVIEW-787

Location:
src/sas/qtgui/MainWindow
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/AboutBox.py

    • Property mode changed from 100755 to 100644
    rb3e8629 r4992ff2  
    11import functools 
    2 from PyQt4 import QtGui 
     2from PyQt5 import QtWidgets 
    33 
    44import sas.sasview 
     
    1010from .UI.AboutUI import Ui_AboutUI 
    1111 
    12 class AboutBox(QtGui.QDialog, Ui_AboutUI): 
     12class AboutBox(QtWidgets.QDialog, Ui_AboutUI): 
    1313    def __init__(self, parent=None): 
    1414        super(AboutBox, self).__init__(parent) 
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r7fb471d r4992ff2  
    55import logging 
    66 
    7 from PyQt4 import QtCore 
    8 from PyQt4 import QtGui 
    9 from PyQt4 import QtWebKit 
    10 from PyQt4.Qt import QMutex 
     7from PyQt5 import QtCore 
     8from PyQt5 import QtGui 
     9from PyQt5 import QtWidgets 
     10from PyQt5 import QtWebKitWidgets 
    1111 
    1212from twisted.internet import threads 
     
    4848        self.loader = Loader() 
    4949        self.manager = manager if manager is not None else DataManager() 
    50         self.txt_widget = QtGui.QTextEdit(None) 
     50        self.txt_widget = QtWidgets.QTextEdit(None) 
    5151 
    5252        # Be careful with twisted threads. 
    53         self.mutex = QMutex() 
     53        self.mutex = QtCore.QMutex() 
    5454 
    5555        # Active plots 
     
    6969 
    7070        # Display HTML content 
    71         self._helpView = QtWebKit.QWebView() 
     71        self._helpView = QtWebKitWidgets.QWebView() 
    7272 
    7373        # Fill in the perspectives combo 
     
    9898 
    9999        # Proxy model for showing a subset of Data1D/Data2D content 
    100         self.data_proxy = QtGui.QSortFilterProxyModel(self) 
     100        self.data_proxy = QtCore.QSortFilterProxyModel(self) 
    101101        self.data_proxy.setSourceModel(self.model) 
    102102 
     
    108108 
    109109        # Proxy model for showing a subset of Theory content 
    110         self.theory_proxy = QtGui.QSortFilterProxyModel(self) 
     110        self.theory_proxy = QtCore.QSortFilterProxyModel(self) 
    111111        self.theory_proxy.setSourceModel(self.theory_model) 
    112112 
     
    182182        Opens the Qt "Open File..." dialog 
    183183        """ 
     184        print("A") 
    184185        path_str = self.chooseFiles() 
    185186        if not path_str: 
     
    192193        Opens the Qt "Open Folder..." dialog 
    193194        """ 
    194         folder = QtGui.QFileDialog.getExistingDirectory(self, "Choose a directory", "", 
    195               QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog) 
     195        folder = QtWidgets.QFileDialog.getExistingDirectory(self, "Choose a directory", "", None, 
     196              QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog) 
    196197        if folder is None: 
    197198            return 
     
    216217            'caption'   : 'Open Project', 
    217218            'filter'    : 'Project (*.json);;All files (*.*)', 
    218             'options'   : QtGui.QFileDialog.DontUseNativeDialog 
     219            'options'   : QtWidgets.QFileDialog.DontUseNativeDialog 
    219220        } 
    220         filename = str(QtGui.QFileDialog.getOpenFileName(**kwargs)) 
     221        filename = str(QtWidgets.QFileDialog.getOpenFileName(**kwargs)) 
    221222        if filename: 
    222223            load_thread = threads.deferToThread(self.readProject, filename) 
    223224            load_thread.addCallback(self.readProjectComplete) 
    224225            load_thread.addErrback(self.readProjectFailed) 
     226 
     227    def loadFailed(self, reason): 
     228        """ 
     229        """ 
     230        print("file load FAILED: ", reason) 
     231        pass 
    225232 
    226233    def readProjectFailed(self, reason): 
     
    248255 
    249256        self.manager.assign(manager) 
     257        self.model.beginResetModel() 
    250258        for id, item in self.manager.get_all_data().items(): 
    251259            self.updateModel(item.data, item.path) 
    252260 
    253         self.model.reset() 
     261        self.model.endResetModel() 
    254262 
    255263    def saveProject(self): 
     
    261269            'caption'   : 'Save Project', 
    262270            'filter'    : 'Project (*.json)', 
    263             'options'   : QtGui.QFileDialog.DontUseNativeDialog 
     271            'options'   : QtWidgets.QFileDialog.DontUseNativeDialog 
    264272        } 
    265         filename = str(QtGui.QFileDialog.getSaveFileName(**kwargs)) 
     273        filename = str(QtWidgets.QFileDialog.getSaveFileName(**kwargs)) 
    266274        if filename: 
    267275            self.communicator.statusBarUpdateSignal.emit("Saving Project... %s\n" % os.path.basename(filename)) 
     
    617625        # Location is automatically saved - no need to keep track of the last dir 
    618626        # But only with Qt built-in dialog (non-platform native) 
    619         paths = QtGui.QFileDialog.getOpenFileNames(self, "Choose a file", "", 
    620                 wlist, QtGui.QFileDialog.DontUseNativeDialog) 
     627        paths = QtWidgets.QFileDialog.getOpenFileNames(self, "Choose a file", "", 
     628                wlist, None, QtWidgets.QFileDialog.DontUseNativeDialog) 
    621629        if paths is None: 
    622630            return 
     
    835843        """ 
    836844        # Create a custom menu based on actions defined in the UI file 
    837         self.context_menu = QtGui.QMenu(self) 
     845        self.context_menu = QtWidgets.QMenu(self) 
    838846        self.context_menu.addAction(self.actionDataInfo) 
    839847        self.context_menu.addAction(self.actionSaveAs) 
     
    10711079        # If so, delete them 
    10721080        # TODO: fix this to resemble GuiUtils.updateModelItemWithPlot 
    1073         #  
     1081        # 
     1082        self.model.beginResetModel() 
    10741083        current_tab_name = model_item.text()[:2] 
    10751084        for current_index in range(self.theory_model.rowCount()): 
     
    10791088 
    10801089        # Reset the view 
    1081         self.model.reset() 
     1090        self.model.endResetModel() 
    10821091 
    10831092        # Reset the view 
  • src/sas/qtgui/MainWindow/DroppableDataLoadWidget.py

    rcd2cc745 r4992ff2  
    11# global 
    2 from PyQt4 import QtGui, QtCore 
     2from PyQt5 import QtCore 
     3from PyQt5 import QtGui 
     4from PyQt5 import QtWidgets 
    35 
    46# UI 
     
    68from sas.qtgui.MainWindow.UI.DataExplorerUI import Ui_DataLoadWidget 
    79 
    8 class DroppableDataLoadWidget(QtGui.QTabWidget, Ui_DataLoadWidget): 
     10class DroppableDataLoadWidget(QtWidgets.QTabWidget, Ui_DataLoadWidget): 
    911    """ 
    1012    Overwrite drag and drop methods in the base class 
  • src/sas/qtgui/MainWindow/GuiManager.py

    rcee5c78 r4992ff2  
    66import webbrowser 
    77 
    8 from PyQt4 import QtCore 
    9 from PyQt4 import QtGui 
    10 from PyQt4 import QtWebKit 
     8from PyQt5.QtWidgets import * 
     9from PyQt5.QtGui import * 
     10from PyQt5.QtCore import Qt 
     11from PyQt5.QtWebKitWidgets import QWebView 
    1112 
    1213from twisted.internet import reactor 
     
    3839from sas.qtgui.MainWindow.DataExplorer import DataExplorerWindow 
    3940 
    40 class Acknowledgements(QtGui.QDialog, Ui_Acknowledgements): 
     41class Acknowledgements(QDialog, Ui_Acknowledgements): 
    4142    def __init__(self, parent=None): 
    42         QtGui.QDialog.__init__(self, parent) 
     43        QDialog.__init__(self, parent) 
    4344        self.setupUi(self) 
    4445 
     
    7778        # Invoke the initial perspective 
    7879        self.perspectiveChanged("Fitting") 
    79  
    8080        self.addWidgets() 
    8181 
     
    9494        # Show the Welcome panel 
    9595        self.welcomePanel = WelcomePanel() 
    96         self._workspace.workspace.addWindow(self.welcomePanel) 
     96        self._workspace.workspace.addSubWindow(self.welcomePanel) 
    9797 
    9898        # Current help file 
    99         self._helpView = QtWebKit.QWebView() 
     99        self._helpView = QWebView() 
    100100        # Needs URL like path, so no path.join() here 
    101101        self._helpLocation = GuiUtils.HELP_DIRECTORY_LOCATION + "/index.html" 
     
    116116        ObjectLibrary.addObject('DataExplorer', self.filesWidget) 
    117117 
    118         self.dockedFilesWidget = QtGui.QDockWidget("Data Explorer", self._workspace) 
     118        self.dockedFilesWidget = QDockWidget("Data Explorer", self._workspace) 
     119        self.dockedFilesWidget.setFloating(True) 
    119120        self.dockedFilesWidget.setWidget(self.filesWidget) 
    120121 
    121122        # Disable maximize/minimize and close buttons 
    122         self.dockedFilesWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) 
    123         self._workspace.addDockWidget(QtCore.Qt.LeftDockWidgetArea, 
    124                                       self.dockedFilesWidget) 
     123        self.dockedFilesWidget.setFeatures(QDockWidget.NoDockWidgetFeatures) 
     124        self.dockedFilesWidget.setFeatures(Qt.LeftDockWidgetArea) 
     125 
     126        self._workspace.workspace.addDockWidget(Qt.LeftDockWidgetArea, self.dockedFilesWidget) 
    125127 
    126128        # Add the console window as another docked widget 
    127         self.logDockWidget = QtGui.QDockWidget("Log Explorer", self._workspace) 
     129        self.logDockWidget = QDockWidget("Log Explorer", self._workspace) 
    128130        self.logDockWidget.setObjectName("LogDockWidget") 
    129         self.listWidget = QtGui.QTextBrowser() 
     131 
     132        self.listWidget = QTextBrowser() 
    130133        self.logDockWidget.setWidget(self.listWidget) 
    131         self._workspace.addDockWidget(QtCore.Qt.BottomDockWidgetArea, 
    132                                       self.logDockWidget) 
     134        self._workspace.workspace.addDockWidget(Qt.BottomDockWidgetAre, self.logDockWidget)  
    133135 
    134136        # Add other, minor widgets 
     
    152154        Progress bar invisible until explicitly shown 
    153155        """ 
    154         self.progress = QtGui.QProgressBar() 
     156        self.progress = QProgressBar() 
    155157        self._workspace.statusbar.setSizeGripEnabled(False) 
    156158 
    157         self.statusLabel = QtGui.QLabel() 
     159        self.statusLabel = QLabel() 
    158160        self.statusLabel.setText("Welcome to SasView") 
    159161        self._workspace.statusbar.addPermanentWidget(self.statusLabel, 1) 
     
    194196        self._current_perspective = Perspectives.PERSPECTIVES[str(perspective_name)](parent=self) 
    195197 
    196         self.setupPerspectiveMenubarOptions(self._current_perspective) 
    197         self._workspace.workspace.addWindow(self._current_perspective) 
     198        self._workspace.workspace.addSubWindow(self._current_perspective) 
     199 
    198200        # Resize to the workspace height 
    199201        workspace_height = self._workspace.workspace.sizeHint().height() 
     
    265267        # Display confirmation messagebox 
    266268        quit_msg = "Are you sure you want to exit the application?" 
    267         reply = QtGui.QMessageBox.question( 
     269        reply = QMessageBox.question( 
    268270            self._parent, 
    269271            'Information', 
    270272            quit_msg, 
    271             QtGui.QMessageBox.Yes, 
    272             QtGui.QMessageBox.No) 
     273            QMessageBox.Yes, 
     274            QMessageBox.No) 
    273275 
    274276        # Exit if yes 
    275         if reply == QtGui.QMessageBox.Yes: 
     277        if reply == QMessageBox.Yes: 
    276278            reactor.callFromThread(reactor.stop) 
    277279            return True 
     
    587589 
    588590        # Add the console window as another docked widget 
    589         self.ipDockWidget = QtGui.QDockWidget("IPython", self._workspace) 
     591        self.ipDockWidget = QDockWidget("IPython", self._workspace) 
    590592        self.ipDockWidget.setObjectName("IPythonDockWidget") 
    591593        self.ipDockWidget.setWidget(terminal) 
    592         self._workspace.addDockWidget(QtCore.Qt.RightDockWidgetArea, 
    593                                       self.ipDockWidget) 
     594        self._workspace.workspace.addSubWindow(self.ipDockWidget, Qt.RightDockWidgetArea) 
    594595 
    595596    def actionImage_Viewer(self): 
     
    716717        TODO: use QNetworkAccessManager to assure _helpLocation is valid 
    717718        """ 
    718         self._helpView.load(QtCore.QUrl(self._helpLocation)) 
     719        self._helpView.load(QUrl(self._helpLocation)) 
    719720        self._helpView.show() 
    720721 
     
    761762        :param new_datalist_item: 
    762763        """ 
    763         if not isinstance(new_item, QtGui.QStandardItem) or \ 
     764        if not isinstance(new_item, QStandardItem) or \ 
    764765                not isinstance(new_datalist_item, dict): 
    765766            msg = "Wrong data type returned from calculations." 
  • src/sas/qtgui/MainWindow/MainWindow.py

    • Property mode changed from 100755 to 100644
    rb3e8629 r4992ff2  
    11# UNLESS EXEPTIONALLY REQUIRED TRY TO AVOID IMPORTING ANY MODULES HERE 
    22# ESPECIALLY ANYTHING IN SAS, SASMODELS NAMESPACE 
    3 from PyQt4 import QtGui 
     3#from PyQt4 import QtGui 
     4from PyQt5.QtWidgets import * 
     5from PyQt5.QtGui import * 
    46 
    57# Local UI 
     
    1012import sas.qtgui.Utilities.SasviewLogger 
    1113 
    12 class MainSasViewWindow(QtGui.QMainWindow, Ui_MainWindow): 
     14class MainSasViewWindow(QMainWindow, Ui_MainWindow): 
    1315    # Main window of the application 
    1416    def __init__(self, parent=None): 
     
    1719 
    1820        # define workspace for dialogs. 
    19         self.workspace = QtGui.QWorkspace(self) 
     21        self.workspace = QMdiArea(self) 
    2022        self.setCentralWidget(self.workspace) 
    2123 
    2224        # Create the gui manager 
    2325        from .GuiManager import GuiManager 
    24         self.guiManager = GuiManager(self) 
     26        try: 
     27            self.guiManager = GuiManager(self) 
     28        except Exception as ex: 
     29            print("EXCEPTION: ", ex) 
    2530 
    2631    def closeEvent(self, event): 
     
    3742    """ 
    3843    # TODO: standardize path to images 
    39     pixmap = QtGui.QPixmap("src/sas/qtgui/images/SVwelcome_mini.png") 
    40     splashScreen = QtGui.QSplashScreen(pixmap) 
     44    pixmap = QPixmap("src/sas/qtgui/images/SVwelcome_mini.png") 
     45    splashScreen = QSplashScreen(pixmap) 
    4146    return splashScreen 
    4247 
    4348def run(): 
    44     app = QtGui.QApplication([]) 
     49    app = QApplication([]) 
    4550 
    4651    # Main must have reference to the splash screen, so making it explicit 
     
    5560    # DO NOT move the following import to the top! 
    5661    # (unless you know what you're doing) 
    57     import qt4reactor 
     62    import qt5reactor 
    5863    # Using the Qt4 reactor wrapper from https://github.com/ghtdak/qtreactor 
    59     qt4reactor.install() 
     64    qt5reactor.install() 
    6065 
    6166    # DO NOT move the following import to the top! 
  • src/sas/qtgui/MainWindow/WelcomePanel.py

    rcd2cc745 r4992ff2  
    22import sys 
    33import os 
    4 from PyQt4 import QtCore 
    5 from PyQt4 import QtGui 
    6 from PyQt4 import QtWebKit 
     4 
     5from PyQt5 import QtWidgets 
    76 
    87import sas.sasview 
     
    1312from sas.qtgui.MainWindow.UI.WelcomePanelUI import Ui_WelcomePanelUI 
    1413 
    15 class WelcomePanel(QtGui.QDialog, Ui_WelcomePanelUI): 
     14class WelcomePanel(QtWidgets.QDialog, Ui_WelcomePanelUI): 
    1615    def __init__(self, parent=None): 
    1716        super(WelcomePanel, self).__init__(parent) 
Note: See TracChangeset for help on using the changeset viewer.