如何在pyQT4上为pyQT5

时间:2017-12-08 14:39:53

标签: python linux python-2.7 pyqt4 pyqt5

这是显示图形的代码的一部分。我在windows上使用pyqt4,但在linux上我使用anaconda,所以只需要pyqt5,当我更新这段代码时不行。谁知道如何在linux上安装pyqt4或如何将此代码更新为pyqt5? (Python 2.7)

from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar

 def showfig(self):
    self.main_frame = QWidget()
    self.figure = plt.figure()
    self.ax = self.figure.add_subplot(111)
    # this is the Canvas Widget that displays the `figure`
    # it takes the `figure` instance as a parameter to __init__
    self.canvas = FigureCanvas(self, self.figure)
    self.canvas.setParent(self.main_frame)

    self.kpress = self.figure.canvas.mpl_connect('key_press_event', self.flip)

    self.mpress = self.figure.canvas.mpl_connect('button_press_event', self.on_press)
    self.mrelea = self.figure.canvas.mpl_connect('button_release_event', self.on_release)
    self.kmove = self.figure.canvas.mpl_connect('motion_notify_event', self.on_motion)


    self.canvas.setFocusPolicy( Qt.ClickFocus )
    self.canvas.setFocus()

编辑:

这是出现的错误

overlay loaded
Traceback (most recent call last):
   File "editor.py", line 1006, in newover
      self.overset = Overset(parent=self)
   File "editor.py", line 650, in __init__
      self.showfig()
   File "editor.py", line 746, in showfig
      self.canvas = FigureCanvas(self, self.figure)
TypeError: __init__() takes exactly2 arguments (3 given) 

0 个答案:

没有答案