示例#1
0
    def create_main_frame(self):
        '''Creates main frame.'''
        self.main_frame = QtGui.QWidget()

        #Creating short title A, B, C
        self.shortTitles = []
        for t in ['A', 'B', 'C']:
            self.shortTitles.append(t)

        #Creating Plot panel
        self.fig = Figure()
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)
        self.TernaryPlot = TernaryPlot(self.fig, short_labels=self.shortTitles)

        #Creating Toolbox for groups
        self.tab = QtGui.QToolBox()
        self.tab.setMaximumWidth(300)
        self.groups = []
        self.groups_brief = []
        self.maxGroupNumber = 0
        self.addGroupTab()

        #Creating buttons for groups
        bbox = QtGui.QHBoxLayout()
        self.btn_addGroup = QtGui.QPushButton('+')
        self.btn_removeGroup = QtGui.QPushButton('-')
        self.btn_editGroups = QtGui.QPushButton('*')

        #Setting buttons shape and tooltip
        self.btn_addGroup.setMaximumWidth(30)
        self.btn_removeGroup.setMaximumWidth(30)
        self.btn_editGroups.setMaximumWidth(30)
        self.btn_addGroup.setToolTip('Add a group')
        self.btn_removeGroup.setToolTip('Remove the current group')
        self.btn_editGroups.setToolTip('Edit the panel labels')

        #Creating layout for buttons
        bbox.addWidget(self.btn_addGroup)
        bbox.addWidget(self.btn_removeGroup)
        bbox.addStretch(1)
        bbox.addWidget(self.btn_editGroups)
        bbox.setSpacing(2)

        #Conecting buttons
        self.connect(self.btn_addGroup, QtCore.SIGNAL('clicked()'),
                     self.addGroupTab)
        self.connect(self.btn_removeGroup, QtCore.SIGNAL('clicked()'),
                     self.removeCurrentGroupTab)
        self.connect(
            self.btn_editGroups,
            QtCore.SIGNAL('clicked()'), lambda: PlotSettingsWindow(
                self, self.TernaryPlot, self.canvas).exec_())

        #Creating Dock Panel
        pbox = QtGui.QVBoxLayout()
        pbox.addLayout(bbox)
        pbox.addWidget(self.tab)
        pbox.setSpacing(10)
        dock_w = QtGui.QWidget()
        dock_w.setLayout(pbox)
        dock_w.setMaximumWidth(270)
        dock_w.setMinimumWidth(270)
        self.dock = QtGui.QDockWidget(self)
        self.dock.setWidget(dock_w)
        self.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dock)

        #Creating main_frame
        mbox = QtGui.QHBoxLayout()
        mbox.addWidget(self.canvas)
        self.main_frame.setLayout(mbox)
        self.setCentralWidget(self.main_frame)