1# -*- coding: utf-8 -*- 2""" 3ConsoleWidget is used to allow execution of user-supplied python commands 4in an application. It also includes a command history and functionality for trapping 5and inspecting stack traces. 6 7""" 8import initExample ## Add path to library (just for examples; you do not need this) 9 10import pyqtgraph as pg 11from pyqtgraph.Qt import QtCore, QtGui 12import numpy as np 13import pyqtgraph.console 14 15app = pg.mkQApp() 16 17## build an initial namespace for console commands to be executed in (this is optional; 18## the user can always import these modules manually) 19namespace = {'pg': pg, 'np': np} 20 21## initial text to display in the console 22text = """ 23This is an interactive python console. The numpy and pyqtgraph modules have already been imported 24as 'np' and 'pg'. 25 26Go, play. 27""" 28c = pyqtgraph.console.ConsoleWidget(namespace=namespace, text=text) 29c.show() 30c.setWindowTitle('pyqtgraph example: ConsoleWidget') 31 32if __name__ == '__main__': 33 pg.exec() 34