Raw File
Tip revision: c45a7e66a8a89c436d41b8431938b35acfa4e53b authored by Heiner Atze on 17 August 2021, 11:38:48 UTC
Tip revision: c45a7e6
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
Created on Tue Jan 22 18:50:06 2019

@author: kantundpeterpan

import sys
from PyQt5 import QtGui
from PyQt5 import QtWidgets

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.backends.backend_qt5 import FigureManagerQT
from matplotlib.backend_managers import ToolManager
from matplotlib.backend_tools import add_tools_to_manager
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
#plt.rcParams['toolbar'] = 'toolmanager'
import random

class Window(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        # a figure instance to plot on
        self.figure = Figure()

        # this is the Canvas Widget that displays the `figure`
        # it takes the `figure` instance as a parameter to __init__
        self.canvas = FigureCanvas(self.figure)
        #self.manager = FigureManagerQT(self.canvas,1)
        self.figure.canvas.mpl_connect('key_press_event', self.home)
        #self.toolmanager = ToolManager(self.figure)

        # this is the Navigation widget
        # it takes the Canvas widget and a parent
        self.toolbar = NavigationToolbar(self.canvas, self)
        #self.canvas.manager.toolbar = self.toolbar

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

        # set the layout
        layout = QtWidgets.QVBoxLayout()
        #add a Tools
    def home(self):
    def plot(self):
        ''' plot some random stuff '''
        # random data
        data = [random.random() for i in range(10)]

        # create an axis
        ax = self.figure.add_subplot(111)

        # discards the old graph

        # plot data
        ax.plot(data, '*-')

        # refresh canvas
back to top