source: sasview/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py @ 60af928

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 60af928 was 60af928, checked in by Piotr Rozyczko <rozyczko@…>, 4 years ago

Fitting perspective refactoring for multitab support SASVIEW-345

  • Property mode set to 100755
File size: 1.9 KB
Line 
1import sys
2
3from PyQt4 import QtCore
4from PyQt4 import QtGui
5
6from FittingWidget import FittingWidget
7
8class FittingWindow(QtGui.QTabWidget):
9    """
10    """
11    name = "Fitting" # For displaying in the combo box in DataExplorer
12    def __init__(self, manager=None, parent=None, data=None):
13        super(FittingWindow, self).__init__()
14
15        self.manager = manager
16        self.parent = parent
17        self._data = data
18
19        #r = raw_input("A")
20        #r = 1
21
22        # List of active fits
23        self.tabs = []
24
25        # Max index for adding new, non-clashing tab names
26        self.maxIndex = 0
27
28        # Index of the current tab
29        self.currentTab = 0
30
31        # The current optimizer
32        self.optimizer = 'DREAM'
33
34        # The tabs need to be closeable
35        self.setTabsClosable(True)
36
37        # Initialize the first tab
38        self.addFit(None)
39
40        # Deal with signals
41        self.tabCloseRequested.connect(self.tabCloses)
42   
43        self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer)
44
45    def addFit(self, data):
46        """
47        Add a new tab for passed data
48        """
49        tab     = FittingWidget(manager=self.manager, parent=self.parent, data=data)
50        self.tabs.append(tab)
51        self.maxIndex += 1
52        self.addTab(tab, self.tabName())
53
54    def tabName(self):
55        """
56        Get the new tab name, based on the number of fitting tabs so far
57        """
58        page_name = "FitPage" + str(self.maxIndex)
59        return page_name
60       
61    def tabCloses(self, index):
62        """
63        Update local bookkeeping on tab close
64        """
65        assert(len(self.tabs) >= index)
66        # don't remove the last tab
67        if len(self.tabs) <= 1:
68            return
69        del self.tabs[index]
70        self.removeTab(index)
71
72if __name__ == "__main__":
73    app = QtGui.QApplication([])
74    dlg = FittingWindow()
75    dlg.show()
76    sys.exit(app.exec_())
Note: See TracBrowser for help on using the repository browser.