def pred():
            root1 = tk.Toplevel()
            root1.title("Graph")

            x = real_stock_price[:100, ]
            y = predicted_stock_price[:100, ]
            f = Figure(figsize=(5, 5), dpi=100)
            a = f.add_subplot(111)
            a.plot(x, color='red', label='Real Strock Price')
            a.plot(y, color='blue', label='Predicted Strock Price')

            canvas = FigureCanvasTkAgg(f, root1)
            canvas.show()
            canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
            a.set_title('Stock Price Predicted')

            toolbar = NavigationToolbar2QT(canvas, root1)
            toolbar.update()
            canvas.tkcanvas.pack(side=tk.TOP,
                                 width=800,
                                 height=500,
                                 fill=tk.BOTH,
                                 expand=True)

            a.set_xlabel('Time', fontsize=14)
            a.set_ylabel('Stock Price', fontsize=14)
            a.legend(loc='upper center', ncol=3, fancybox=True, shadow=True)
            """plt.plot(x, color = 'red', label = 'Real Strock Price')
            plt.xlabel('Time')
            plt.plot(y, color = 'blue', label = 'Predicted Strock Price')
            plt.title('Stock Price Predicted')
            plt.ylabel('Stock Price')
            plt.legend()
            plt.show()"""
            root1.mainloop()
Esempio n. 2
0
    def __init__(self, parent, segmentation, selectionmodel):
        super(FrameViewWidget, self).__init__(parent)

        self.segmentation = segmentation

        # create a vertical box layout widget
        self.vbl = QtGui.QVBoxLayout()

        self.canvas = FrameViewCanvas(segmentation, selectionmodel)
        self.vbl.addWidget(self.canvas)

        from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
        self.toolbar_navigation = NavigationToolbar2QT(self.canvas,
                                                       self,
                                                       coordinates=False)

        self.frame_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.frame_slider.setMinimum(0)
        self.frame_slider.setMaximum(self.segmentation.data.shape[2] - 1)
        self.frame_slider.setTickInterval(1)
        self.frame_slider.setSingleStep(1)
        self.frame_slider.setPageStep(self.segmentation.data.shape[2] / 10)
        self.frame_slider.valueChanged.connect(self.on_slider_changed)

        self.toollayout = QtGui.QHBoxLayout()

        self.toollayout.addWidget(self.toolbar_navigation)
        self.toollayout.addWidget(self.frame_slider)

        self.vbl.addLayout(self.toollayout)
        self.setLayout(self.vbl)

        self.segmentation.active_frame_changed.append(
            self.on_active_frame_changed)
Esempio n. 3
0
    def __init__(self, main, ind, dep, color):
        QDialog.__init__(self, main)
        self.main = main
        self.setPalette(main.palette())
        self.ind = ind
        self.dep = dep
        self.color = color
        self.info = QLabel('Click on a point to highlight the corresponding'
                           ' record')
        self.figure = mpl.figure.Figure()
        self.canvas = FigureCanvasQTAgg(self.figure)
        self.canvas.setParent(self)
        self.canvas.setFocus()

        self.toolbar = NavigationToolbar2QT(self.canvas, self)

        self.ax = self.figure.add_subplot(111)
        self.scatterPlot = self.ax.scatter(self.ind,
                                           self.dep,
                                           c=self.color,
                                           picker=5,
                                           cmap=mpl.cm.YlGnBu_r)
        if self.color is not None:
            self.colorbar = self.figure.colorbar(self.scatterPlot)

        self.canvas.mpl_connect('pick_event', self.main.handleClick)

        vbox = QVBoxLayout()
        vbox.addWidget(self.info)
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.toolbar)
        self.setLayout(vbox)

        self.show()
Esempio n. 4
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)

        self.toolbar = NavigationToolbar2QT(self.canvas, self)
        self.toolbar.hide()

        # Just some button
        self.button = QtGui.QPushButton('Plot')
        self.button.clicked.connect(self.plot)

        self.button1 = QtGui.QPushButton('Zoom')
        self.button1.clicked.connect(self.zoom)

        self.button2 = QtGui.QPushButton('Pan')
        self.button2.clicked.connect(self.pan)

        self.button3 = QtGui.QPushButton('Home')
        self.button3.clicked.connect(self.home)

        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)
        layout.addWidget(self.button)
        layout.addWidget(self.button1)
        layout.addWidget(self.button2)
        layout.addWidget(self.button3)
        self.setLayout(layout)
Esempio n. 5
0
        def create_plot():
            """Create the plot."""
            # plot
            self.UI_figure = Figure()
            self.UI_canvas = FigureCanvasQTAgg(self.UI_figure)

            # toolbar
            toolbar = NavigationToolbar2QT(self.UI_canvas, self)

            # layout
            plotL = QtGui.QVBoxLayout(spacing=0)
            plotL.setContentsMargins(0, 0, 0, 0)
            plotL.addWidget(self.UI_canvas, 1)
            plotL.addWidget(toolbar)

            # widget
            plotW = QtGui.QWidget()
            plotW.setLayout(plotL)

            # dock
            plotD = QtGui.QDockWidget(
                "Plot",
                objectName="Plot",
                features=(QtGui.QDockWidget.DockWidgetFloatable
                          | QtGui.QDockWidget.DockWidgetMovable))
            plotD.setWidget(plotW)

            return plotD
Esempio n. 6
0
    def __init__(self):
        QtGui.QWidget.__init__(self)

        c = self.palette().color(self.backgroundRole())
        self._default_color = str((c.red(), c.green(), c.blue()))

        self.canvas = MplCanvas()
        self.manager = FigureManagerQT(self.canvas, MplFigureWidget.count)
        self.mpl_toolbar = NavigationToolbar2QT(self.canvas, None)
        self.mpl_toolbar.setStyleSheet("background-color: rgb%s;" %
                                       self._default_color)
        self.mpl_toolbar.hide()

        MplFigureWidget.count += 1
        all_widgets.append(self)

        self.setToolTip("Figure %d" % self.manager.num)

        self.setFrameShape(QtGui.QFrame.Box)
        self.setFrameShadow(QtGui.QFrame.Plain)
        self.setContentsMargins(1, 1, 1, 1)

        self._layout = QtGui.QVBoxLayout(self)
        self._layout.addWidget(self.canvas)
        self._layout.setContentsMargins(1, 1, 1, 1)
Esempio n. 7
0
    def _refresh_mpl_widget(self):
        """ Create the mpl widget and update the underlying control.

        """
        # Delete the old widgets in the layout, it's just shenanigans
        # to try to reuse the old widgets when the figure changes.
        widget = self.widget
        layout = widget.layout()
        while layout.count():
            layout_item = layout.takeAt(0)
            layout_item.widget().deleteLater()

        # Create the new figure and toolbar widgets. It seems that key
        # events will not be processed without an mpl figure manager.
        # However, a figure manager will create a new toplevel window,
        # which is certainly not desired in this case. This appears to
        # be a limitation of matplotlib. The canvas is manually set to
        # visible, or QVBoxLayout will ignore it for size hinting.
        figure = self.declaration.figure
        if figure:
            canvas = FigureCanvasQTAgg(figure)
            canvas.setParent(widget)
            canvas.setFocusPolicy(Qt.ClickFocus)
            canvas.setVisible(True)
            toolbar = NavigationToolbar2QT(canvas, widget)
            toolbar.setVisible(self.declaration.toolbar_visible)
            layout.addWidget(toolbar)
            layout.addWidget(canvas)
Esempio n. 8
0
 def create_drift_layout(self):
     layout = QtGui.QVBoxLayout()
     self.fig = Figure()
     self.drift_canvas = FigureCanvas(self.fig)
     self.drift_canvas.setParent(self)
     gs = gridspec.GridSpec(1, 2, wspace=0.15, left=0.05, right=0.95)
     line_drift = self.fig.add_subplot(gs[0, 0])
     line_drift.ticklabel_format(useOffset=False)
     line_drift.set_xlabel('Time (min)')
     line_drift.set_ylabel('KHz')
     line_drift.set_title("Line Center Drift")
     self.line_drift = line_drift
     self.line_drift_lines = []
     self.line_drift_fit_line = []
     b_drift = self.fig.add_subplot(gs[0, 1], sharex=line_drift)
     b_drift.ticklabel_format(useOffset=False)
     b_drift.set_xlabel('Time (min)')
     b_drift.set_ylabel('mgauss')
     b_drift.set_title("B Field Drift")
     self.b_drift_twin = b_drift.twinx()
     self.b_drift_twin.set_ylabel('Effective Frequency (kHz)')
     self.b_drift_twin_lines = []
     self.b_drift_lines = []
     self.b_drift_fit_line = []
     self.b_drift = b_drift
     self.mpl_toolbar = NavigationToolbar2QT(self.drift_canvas, self)
     layout.addWidget(self.mpl_toolbar)
     layout.addWidget(self.drift_canvas)
     return layout
Esempio n. 9
0
 def tabbed_qt4_window(self):
     from PyQt4 import QtGui
     from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg, NavigationToolbar2QT
     # mpl backend can already create instance
     # https://stackoverflow.com/a/40031190
     app = QtGui.QApplication.instance()
     if app is None:
         app = QtGui.QApplication([self.title])
     self.root_window = QtGui.QTabWidget()
     self.root_window.setWindowTitle(self.title)
     for name, fig in self.figures.items():
         tab = QtGui.QWidget(self.root_window)
         tab.canvas = FigureCanvasQTAgg(fig)
         vbox = QtGui.QVBoxLayout(tab)
         vbox.addWidget(tab.canvas)
         toolbar = NavigationToolbar2QT(tab.canvas, tab)
         vbox.addWidget(toolbar)
         tab.setLayout(vbox)
         for axes in fig.get_axes():
             if isinstance(axes, Axes3D):
                 # must explicitly allow mouse dragging for 3D plots
                 axes.mouse_init()
         self.root_window.addTab(tab, name)
     self.root_window.show()
     app.exec_()
        def train():
            root2 = tk.Toplevel()
            root2.title("Graph")

            f = Figure(figsize=(5, 5), dpi=100)
            a = f.add_subplot(111)
            a.plot(history.history['loss'])
            a.set_title('Stock Price Predicted')
            a.set_xlabel('epochs', fontsize=14)
            a.set_ylabel('loss of error', fontsize=14)
            a.legend(['train', 'test'],
                     loc='upper center',
                     ncol=3,
                     fancybox=True,
                     shadow=True)

            canvas = FigureCanvasTkAgg(f, root2)
            canvas.show()
            canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)

            toolbar = NavigationToolbar2QT(canvas, root2)
            toolbar.update()
            canvas.tkcanvas.pack(side=tk.TOP,
                                 width=800,
                                 height=500,
                                 fill=tk.BOTH,
                                 expand=True)

            root2.mainloop()
Esempio n. 11
0
    def display(self):
        """
        Show the plot in an interactive window.

        """

        # Host widget for show():
        app = QApplication(sys.argv)
        app.aboutToQuit.connect(app.deleteLater)
        main_frame = QWidget()

        # Attach canvas to host widget:
        canvas = FigureCanvasQTAgg(self)
        canvas.setParent(main_frame)

        # Make navigation toolbar:
        mpl_toolbar = NavigationToolbar2QT(self.canvas, main_frame)

        # Set up layout:
        vbox = QVBoxLayout()
        vbox.addWidget(mpl_toolbar)
        vbox.addWidget(self.canvas)

        # Set the layout to the host widget:
        main_frame.setLayout(vbox)

        # Set figure manager:
        FigureManagerQT(self.canvas, 1)

        # Show plot:
        self.show()
        app.exec_()
Esempio n. 12
0
    def set_imagepanel(self,
                       name=None,
                       cmap='gray',
                       scale='zscale',
                       contrast=0.1):
        """set up the Image Panel"""
        hmin = 150
        wmin = 400
        #set up the control panel
        self.imagpanel = QtGui.QWidget()

        #hmin=wmin*self.naxis2/self.naxis1
        #print self.naxis1, self.naxis2, wmin, hmin

        # Add FITS display widget with mouse interaction and overplotting
        self.imdisplay = ImageDisplay()
        #self.imdisplay.setMinimumWidth(wmin)

        # Set colormap
        self.imdisplay.setColormap(cmap)

        # Set scale mode for dynamic range
        imarr = self.struct[int(self.pid[self.id])].data
        self.imdisplay.scale = scale
        self.imdisplay.contrast = contrast
        self.imdisplay.aspect = 'auto'
        self.imdisplay.loadImage(imarr)
        #self.imdisplay.drawImage()
        hmin = self.imdisplay.width() * self.naxis2 / self.naxis1
        self.imdisplay.setMaximumHeight(hmin)
        self.imdisplay.setMinimumHeight(hmin)

        #add the rectangles
        self.add_mark(self.tx[self.id],
                      self.ty[self.id],
                      'target',
                      color='b',
                      lw=2)
        self.add_mark(self.cx[self.id],
                      self.cy[self.id],
                      'comparison',
                      color='g',
                      lw=2)
        self.imdisplay.redraw_canvas()
        self.imdisplay.axes.set_xticklabels([])
        self.imdisplay.axes.set_yticklabels([])

        self.imdisplay.connectMatplotlibMouseMotion()
        self.imdisplay.mpl_connect('button_press_event', self.onButtonPress)
        self.imdisplay.mpl_connect('key_press_event', self.onKeyPress)

        # Add navigation toolbars for each widget to enable zooming
        self.imagtoolbar = NavigationToolbar2QT(self.imdisplay, self)

        # Set up the layout
        imagLayout = QtGui.QVBoxLayout(self.imagpanel)
        #imagLayout.addWidget(self.imdisplay)
        imagLayout.addWidget(MplCanvas())
        imagLayout.addWidget(self.imagtoolbar)
Esempio n. 13
0
    def create_main_frame(self, filename):
        self.main_frame = QtWidgets.QWidget()
        self.image = None

        self.image, self.image_center = sphelper.import_spimage(
            filename, ["image", "image_center"])

        x_array = numpy.arange(self.image.shape[0]) - self.image_center[0]
        y_array = numpy.arange(self.image.shape[1]) - self.image_center[1]
        X_array, Y_array = numpy.meshgrid(x_array, y_array)
        X_array = numpy.transpose(X_array)
        Y_array = numpy.transpose(Y_array)
        self.r = numpy.sqrt(X_array**2 + Y_array**2)

        ft = numpy.fft.fft2(self.image)
        self.auto_unfiltered = numpy.fft.fftshift(abs(ft))

        self.dpi = 100
        self.fig = Figure((10.0, 10.0), dpi=self.dpi)
        self.canvas = FigureCanvasQTAgg(self.fig)
        self.canvas.setParent(self.main_frame)

        self.axes = self.fig.add_subplot(111)

        self.mpl_toolbar = NavigationToolbar2QT(self.canvas, self.main_frame)

        self.a_slider = QtWidgets.QSlider(QtCore.Qt.Vertical)
        self.a_slider.setMinimum(1)
        self.a_slider.setMaximum(300)
        self.a_slider.setValue(self.a)
        self.a_slider.setTracking(False)

        self.a_label = QtWidgets.QLabel("a = %g" % self.a)

        self.a_slider.sliderMoved.connect(self.a_changed)
        self.a_slider.valueChanged.connect(self.update_image)

        self.filter_box = QtWidgets.QCheckBox("Use filter")

        self.filter_box.stateChanged.connect(self.box_state_changed)

        vbox1 = QtWidgets.QVBoxLayout()
        vbox1.addWidget(self.canvas)
        vbox1.addWidget(self.mpl_toolbar)

        vbox2 = QtWidgets.QVBoxLayout()
        vbox2.addWidget(self.a_label)
        vbox2.addWidget(self.a_slider)
        vbox2.addWidget(self.filter_box)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addLayout(vbox1)
        hbox.addLayout(vbox2)

        self.main_frame.setLayout(hbox)
        self.setCentralWidget(self.main_frame)
        self.update_image()
Esempio n. 14
0
    def __init__(self, parent=None, width=4, height=3, dpi=100):
        self.figure = Figure(figsize=(width, height), dpi=dpi)

        Canvas.__init__(self, self.figure)
        self.setParent(parent)
        Canvas.setSizePolicy(self, QSizePolicy.Expanding,
                             QSizePolicy.Expanding)
        Canvas.updateGeometry(self)

        self.toolbar = NavigationToolbar2QT(canvas=self, parent=self)
        self.toolbar.resize(2000, 25)
Esempio n. 15
0
        def show(qmc):
            # instantiate a navigation toolbar from matplotlib package for
            # the plot and widget
            ntb = NavigationToolbar2QT(qmc, self.dialog_error.widget)

            # package the plot and navigation toolbar within the vertical layout
            self.dialog_error.verticalLayout_chart.addWidget(qmc)
            self.dialog_error.verticalLayout_chart.addWidget(ntb)

            if not self.dialog_error.exec():
                self.dialog_error.verticalLayout_chart.removeWidget(qmc)
                self.dialog_error.verticalLayout_chart.removeWidget(ntb)
Esempio n. 16
0
    def setFigure(self, fig):
        """Replace the current figure shown in the widget with fig"""
        plt.close(self.canvas.figure)

        new_canvas = FigureCanvasQTAgg(fig)
        self.layout.replaceWidget(self.canvas, new_canvas)

        new_toolbar = NavigationToolbar2QT(new_canvas, self)
        self.layout.replaceWidget(self.toolbar, new_toolbar)

        self.toolbar.setParent(None)
        self.toolbar = new_toolbar
        self.canvas = new_canvas
Esempio n. 17
0
    def __init__(self, parent=None):
        super(Plot, self).__init__(parent)
        gridLayout = QtGui.QGridLayout(self)

        self.plot = matplotlib()
        gridLayout.addWidget(self.plot, 1, 1, 1, 2)
        self.toolbar = NavigationToolbar2QT(self.plot, self.plot)
        gridLayout.addWidget(self.toolbar, 2, 1)
        self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Close)
        self.buttonBox.setSizePolicy(QtGui.QSizePolicy.Maximum,
                                     QtGui.QSizePolicy.Maximum)
        self.buttonBox.rejected.connect(self.reject)
        gridLayout.addWidget(self.buttonBox, 2, 2)
Esempio n. 18
0
    def __init__(self, name, parent=None):
        super(PluginDialog, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle(name)

        layout = QVBoxLayout()
        self.fig = BlankCanvas()
        self.ax = self.fig.ax

        self.toolbar = NavigationToolbar2QT(self.fig, self)
        layout.addWidget(self.fig)
        layout.addWidget(self.toolbar)
        self.setLayout(layout)
Esempio n. 19
0
    def _create_main_frame(self, filename):
        self._main_frame = QtGui.QWidget()
        self._image = None
        try:
            self._image = sphelper.import_spimage(filename)
        except IOError:
            print("Must provide a file")
            exit(1)

        self._dpi = 100
        self._fig = Figure((10.0, 10.0), dpi=self._dpi)
        self._fig.subplots_adjust(left=0., right=1., bottom=0., top=1.)
        self._canvas = FigureCanvasQTAgg(self._fig)
        self._canvas.setParent(self._main_frame)

        self._axes = self._fig.add_subplot(111)
        self._axes.set_xticks([])
        self._axes.set_yticks([])

        self._mpl_toolbar = NavigationToolbar2QT(self._canvas,
                                                 self._main_frame)

        self._slider_length = 100
        self._angle_slider = QtGui.QSlider(QtCore.Qt.Vertical)
        self._angle_slider.setMinimum(0)
        self._angle_slider.setMaximum(self._slider_length)
        self._angle_slider.setValue(self._angle)
        self._angle_slider.setTracking(True)

        self._angle_label = QtGui.QLabel(
            f"angle = {self._angle/numpy.pi*180.}")
        self._angle_label.setFixedWidth(100)

        self._angle_slider.sliderMoved.connect(self._angle_changed)

        vbox1 = QtGui.QVBoxLayout()
        vbox1.addWidget(self._canvas)
        vbox1.addWidget(self._mpl_toolbar)

        vbox2 = QtGui.QVBoxLayout()
        vbox2.addWidget(self._angle_label)
        vbox2.addWidget(self._angle_slider)

        hbox = QtGui.QHBoxLayout()
        hbox.addLayout(vbox1)
        hbox.addLayout(vbox2)

        self._main_frame.setLayout(hbox)
        self.setCentralWidget(self._main_frame)
        self._update_image()
    def _create_canvas(self, parent):
        """ Create the MPL canvas. """
        # matplotlib commands to create a canvas
        frame = QtGui.QWidget()
        mpl_canvas = FigureCanvas(self.value)
        mpl_canvas.setParent(frame)
        mpl_toolbar = NavigationToolbar2QT(mpl_canvas, frame)

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(mpl_canvas)
        vbox.addWidget(mpl_toolbar)
        frame.setLayout(vbox)

        return frame
Esempio n. 21
0
    def __init__(self, parent, data, threshold, title):
        QtGui.QWidget.__init__(self)
        
        self.parent = parent
        self.threshold = threshold
        self.setWindowTitle(title)
        
        layout = QtGui.QVBoxLayout()


#        self.binSpinBox = QtGui.QSpinBox()
#        self.binSpinBox.setMinimum(0)
#        self.binSpinBox.setMaximum(500)
#        self.binSpinBox.setSingleStep(1)  
#        self.binSpinBox.setValue(30)     
#        self.binSpinBox.setKeyboardTracking(False)
#        self.connect(self.binSpinBox, QtCore.SIGNAL('valueChanged(int)'), self.binChange)
        
        self.thresholdSpinBox = QtGui.QSpinBox()
        self.thresholdSpinBox.setMinimum(-100)
        self.thresholdSpinBox.setMaximum(100000)
        self.thresholdSpinBox.setSingleStep(1)  
        self.thresholdSpinBox.setValue(self.threshold)     
        self.thresholdSpinBox.setKeyboardTracking(False)
        self.connect(self.thresholdSpinBox, QtCore.SIGNAL('valueChanged(int)'), self.thresholdChange)  
        
        #try:
        self.canvas = HistCanvas(self, data, self.thresholdSpinBox.value())
        #except AttributeError:
            #raise Exception("Has a Dark Ion Catalog Been Retrieved?")
        self.canvas.show()
        ntb = NavigationToolbar2QT(self.canvas, self)

        layout.addWidget(self.canvas)
        layout.addWidget(ntb)
        
#        changeWindowTitleButton = QtGui.QPushButton("Change Window Title", self)
#        changeWindowTitleButton.setGeometry(QtCore.QRect(0, 0, 30, 30))
#        changeWindowTitleButton.clicked.connect(self.changeWindowTitle)
        
              
        
        self.bottomPanel = QtGui.QHBoxLayout()
        
        layout.addLayout(self.bottomPanel)
#        self.bottomPanel.addWidget(self.binSpinBox)
        self.bottomPanel.addWidget(self.thresholdSpinBox)
        
        
        self.setLayout(layout)
 def create_plot_layout(self):
     layout = QtGui.QVBoxLayout()
     self.fig = Figure()
     self.canvas = FigureCanvas(self.fig)
     self.canvas.setParent(self)
     self.axes = self.fig.add_subplot(111)
     self.axes.set_xlim(left=0, right=1)
     self.axes.set_ylim(bottom=0, top=50)
     self.mpl_toolbar = NavigationToolbar2QT(self.canvas, self)
     self.axes.set_title('Camera Readout', fontsize=22)
     self.fig.tight_layout()
     layout.addWidget(self.mpl_toolbar)
     layout.addWidget(self.canvas)
     return layout
Esempio n. 23
0
    def _create_canvas(self, parent):
        """ Create the MPL canvas. """
        # matplotlib commands to create a canvas
        frame = QtGui.QWidget()
        mpl_canvas = FigureCanvas(self.value)
        mpl_toolbar = NavigationToolbar2QT(parent=frame, canvas=mpl_canvas)
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(mpl_canvas)
        vbox.addWidget(mpl_toolbar)
        frame.setLayout(vbox)
        mpl_canvas.setFocusPolicy(QtCore.Qt.ClickFocus)
        mpl_canvas.setFocus()

        return frame  #mpl_canvas
Esempio n. 24
0
    def __init__(self, filters=[]):
        QtGui.QMainWindow.__init__(self)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle("application main window")

        #----------------------------------
        self.file_menu = QtGui.QMenu('&File', self)
        self.menuBar().addMenu(self.file_menu)
        self.file_menu.addAction('&Quit',         self.fileQuit, QtCore.Qt.CTRL + QtCore.Qt.Key_Q)
        #self.file_menu.addAction('&NewFigWindow', self.create_sep_pplWindow, QtCore.Qt.CTRL + QtCore.Qt.Key_N)

        self.menuBar().addSeparator()

        self.help_menu = QtGui.QMenu('&Help', self)
        self.menuBar().addMenu(self.help_menu)
        self.help_menu.addAction('&About', self.about)

        self.main_widget = QtGui.QWidget(self)

        layout = QtGui.QVBoxLayout(self.main_widget)


        #----------------------------------
        self.filters = filters
        for f in filters:
            assert (isinstance(f, FilterBase)), 'unexpected type of filter'

        #----------------------------------
        dc = Fig2D( self.main_widget, width=6, height=6, dpi=100)
        layout.addWidget(dc)
        L=len(filters)
        pl = MPL_Plotter(filters[L-1:L]);
        pl.canvas, pl.fig, pl.axes = dc, dc.fig, dc.axes

        #----------------------------------
        self.mpl_toolbar = NavigationToolbar2QT(dc, self.main_widget)
        layout.addWidget(self.mpl_toolbar)

        #----------------------------------
        dialog = Dialog4Pipe(  filters, self.main_widget, self.exec_pipeline ,  self.statusBar().showMessage )
        dialog.setWindowFlags(QtCore.Qt.Widget)
        layout.addWidget(dialog)


        #----------------------------------
        self.main_widget.setFocus()
        self.setCentralWidget(self.main_widget)

        self.statusBar().showMessage("Ready", 30000)
Esempio n. 25
0
    def __init__(self, parent=None):
        super(SpinBalanceDialog, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle('Spin balance dialog')

        self.fig1 = BlankCanvas()
        self.ax1 = self.fig1.ax
        self.fig2 = BlankCanvas()
        self.ax2 = self.fig2.ax
        self.toolbar1 = NavigationToolbar2QT(self.fig1, self)
        self.toolbar2 = NavigationToolbar2QT(self.fig2, self)
        self.balance_label = QLabel()

        layout1 = QVBoxLayout()
        layout1.addWidget(self.fig1)
        layout1.addWidget(self.toolbar1)
        layout2 = QVBoxLayout()
        layout2.addWidget(self.fig2)
        layout2.addWidget(self.toolbar2)
        layout = QHBoxLayout()
        layout.addLayout(layout1)
        layout.addLayout(layout2)
        layout.addWidget(self.balance_label)
        self.setLayout(layout)
Esempio n. 26
0
    def set_plotpanel(self, hmin=250):
        #set up the control panel
        self.plotpanel = QtGui.QWidget()

        self.lccanvas = MplCanvas()
        self.plotlightcurve()
        #add the actions
        self.lccanvas.mpl_connect('button_press_event', self.onButtonPress)

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QT(self.lccanvas, self)

        # Set up the layout
        plotLayout = QtGui.QVBoxLayout(self.plotpanel)
        plotLayout.addWidget(self.lccanvas)
        plotLayout.addWidget(self.toolbar)
Esempio n. 27
0
 def __init__(self, main_window, locs):
     super().__init__()
     self.main_window = main_window
     self.locs = locs
     self.figure = plt.Figure()
     self.canvas = FigureCanvasQTAgg(self.figure)
     self.plot()
     vbox = QtWidgets.QVBoxLayout()
     self.setLayout(vbox)
     vbox.addWidget(self.canvas)
     vbox.addWidget((NavigationToolbar2QT(self.canvas, self)))
     self.setWindowTitle("Picasso: Filter")
     this_directory = os.path.dirname(os.path.realpath(__file__))
     icon_path = os.path.join(this_directory, "icons", "filter.ico")
     icon = QtGui.QIcon(icon_path)
     self.setWindowIcon(icon)
    def _create_canvas(self, parent):
        print(self.__class__.__name__, ": Creating canvas (_create_canvas)")
        # matplotlib commands to create a canvas
        frame = QtGui.QWidget()
        mpl_canvas = FigureCanvas(self.value)
        mpl_canvas.setParent(frame)
        mpl_toolbar = NavigationToolbar2QT(mpl_canvas, frame)

        # mpl_toolbar.setIconSize(QtCore.QSize(30, 30))  # activate for smaller icon sizes

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(mpl_canvas)
        vbox.addWidget(mpl_toolbar)
        frame.setLayout(vbox)

        return frame
Esempio n. 29
0
    def __init__(self, fig=Figure()):
        super().__init__()

        self.canvas = FigureCanvasQTAgg(fig)
        self.toolbar = NavigationToolbar2QT(self.canvas, self)

        # Just some button connected to `plot` method
        self.button = QtWidgets.QPushButton('Plot Random')
        self.button.clicked.connect(self.setRandomImage)

        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
        # self.layout.addWidget(self.button)

        self.toolbar.setStyleSheet('background: transparent;')
Esempio n. 30
0
    def __init__(self, detections, cmds, settings, sample_rate, parent=None):
        qt.QWidget.__init__(self, parent)

        self.plotters = [
            Plotter(detection, settings, sample_rate)
            for detection in detections
        ]
        self.detections = detections

        self.block_selector = qt.QTabBar()
        for detection in detections:
            title = str(detection.result.block)
            self.block_selector.addTab(title)
        self.cmds = cmds
        self.cmd_selector = qt.QTabBar()
        for cmd in cmds:
            self.cmd_selector.addTab(cmd)

        self.block_selector.currentChanged.connect(self.plot)
        self.cmd_selector.currentChanged.connect(self.plot)

        self.fig = Figure(frameon=True)
        self.canvas = FigureCanvasQTAgg(self.fig)
        self.toolbar = NavigationToolbar2QT(self.canvas, parent)
        self.canvas.mpl_connect('key_press_event', self.on_key_press)
        self.canvas.setSizePolicy(qt.QSizePolicy.Expanding,
                                  qt.QSizePolicy.Expanding)
        self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)

        self.summary_liner = detect.SummaryLineFormatter(sample_rate,
                                                         settings.block_len,
                                                         add_dt=False)
        self.summary_line = qt.QLabel()
        self.summary_line.setAlignment(QtCore.Qt.AlignHCenter)

        vbox = qt.QVBoxLayout()
        vbox.addWidget(qt.QLabel('Detect Analysis'))
        vbox.addWidget(self.block_selector)
        vbox.addWidget(self.cmd_selector)
        vbox.addWidget(self.summary_line)
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.toolbar)
        self.setLayout(vbox)

        self.plot()
        self.canvas.setFocus()