DockArea

95 views
Skip to first unread message

Wahabo Ouedraogo

unread,
May 12, 2020, 11:01:52 PM5/12/20
to pyqtgraph
Greetings,

When i run my code, i obtain this error:

Traceback (most recent call last):
  File "d:/Documents/VISUAL STUDIO CODE EXO/Untitled-f.py", line 58, in <module>
    w = Window()
  File "d:/Documents/VISUAL STUDIO CODE EXO/Untitled-f.py", line 49, in __init__
    self.dockArea = pg.DockArea()
AttributeError: module 'pyqtgraph' has no attribute 'DockArea'
PS D:\Documents\VISUAL STUDIO CODE EXO\MEMOIRE> & C:/Users/ThinkPad/AppData/Local/Programs/Python/Python38/python.exe "d:/Documents/VISUAL STUDIO CODE EXO/Untitled-f.py"
PS D:\Documents\VISUAL STUDIO CODE EXO\MEMOIRE> 

here, the script:


from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import random
import sys

class Window(QtGui.QWidget):
    
    def __init__(self,parent = None):
        
        QtGui.QWidget.__init__(self,parent)
        pg.setConfigOptions(antialias=True)
        pg.setConfigOptions(background = "k")
        
        self.setParent(parent)
    
        data = np.random.normal(size=(5060))
        data = data.ravel()
        self.x1 = np.linspace(0,20,10)
        self.y1 =  np.arange(0,10)
        
        self.x = np.linspace(0,15,10)

        self.x2 = np.arange(0,10)
        self.y2 = np.linspace(0,20,10)

        N = 600
        T = 1.0 / 800.0
        xa = np.linspace(0.0, N*T, N)
        ya = np.sin(50.0 * 2.0*np.pi*xa) + 0.5*np.sin(80.0 * 2.0*np.pi*xa)
        
        Y = np.sin(np.linspace(020600))
        self.plot = pg.PlotItem()
        self.plot.plot(self.x1,self.y2)
        self.plot.plot(y=ya)
        self.plot.plot(Y,pen = pg.mkPen(color = 'r'))
        self.plot.showButtons()
        
        self.plot2 = pg.PlotItem()
        self.plot2.plot(self.x1, self.y2,pen=pg.mkPen(cosmetic=True,color="r",width=2))
        self.plot2.plot(self.x1,self.x2)
        self.plot2.plot(self.y1,self.y2)
        self.plot2.scatterPlot(self.y2,self.x)

        self.dockArea = pg.DockArea()

        self.graphicslayouwidget = pg.GraphicsLayoutWidget()
        self.graphicslayouwidget.addItem(self.plot)
        self.graphicslayouwidget.addItem(self.plot2)

        self.graphicslayouwidget.show()
    
if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = Window()
    sys.exit(app.exec_())

Jerzy Karczmarczuk

unread,
May 13, 2020, 3:28:28 AM5/13/20
to pyqt...@googlegroups.com

On 13/05/2020 5:01 am, Wahabo Ouedraogo wrote:

Greetings,

When i run my code, i obtain this error:

Traceback (most recent call last):
  File "d:/Documents/VISUAL STUDIO CODE EXO/Untitled-f.py", line 58, in <module>
    w = Window()
  File "d:/Documents/VISUAL STUDIO CODE EXO/Untitled-f.py", line 49, in __init__
    self.dockArea = pg.DockArea()
AttributeError: module 'pyqtgraph' has no attribute 'DockArea'
PS D:\Documents\VISUAL STUDIO CODE EXO\MEMOIRE> & C:/Users/ThinkPad/AppData/Local/Programs/Python/Python38/python.exe "d:/Documents/VISUAL STUDIO CODE EXO/Untitled-f.py"
PS D:\Documents\VISUAL STUDIO CODE EXO\MEMOIRE> 

here, the script:

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import pyqtgraph as pg
/.../
        self.dockArea = pg.DockArea()

Perfectly normal. The package pyqtgraph has no DockArea attribute. It suffices to type dir(pg) to see it, couldn't you do it yourself before complaining? No idea where did you copy the included script from, but I suggest to verify:

from pyqtgraph.dockarea import DockArea

At least it works here.

Jerzy Karczmarczuk
/Caen, France/





Avast logo

This email has been checked for viruses by Avast antivirus software.
www.avast.com


Reply all
Reply to author
Forward
0 new messages