Created
November 9, 2015 12:32
-
-
Save sash13/eed9e805d446227bd39e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <ui version="4.0"> | |
| <class>MainWindow</class> | |
| <widget class="QMainWindow" name="MainWindow"> | |
| <property name="geometry"> | |
| <rect> | |
| <x>0</x> | |
| <y>0</y> | |
| <width>724</width> | |
| <height>436</height> | |
| </rect> | |
| </property> | |
| <property name="windowTitle"> | |
| <string>MainWindow</string> | |
| </property> | |
| <widget class="QWidget" name="centralwidget"> | |
| <property name="sizePolicy"> | |
| <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | |
| <horstretch>0</horstretch> | |
| <verstretch>0</verstretch> | |
| </sizepolicy> | |
| </property> | |
| <layout class="QHBoxLayout" name="horizontalLayout_2"> | |
| <item> | |
| <widget class="QGroupBox" name="plotBox"> | |
| <property name="sizePolicy"> | |
| <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | |
| <horstretch>0</horstretch> | |
| <verstretch>0</verstretch> | |
| </sizepolicy> | |
| </property> | |
| <property name="title"> | |
| <string>Plot</string> | |
| </property> | |
| <layout class="QVBoxLayout" name="verticalLayout_3"> | |
| <item> | |
| <widget class="PlotWidget" name="us1_plot"> | |
| <property name="frameShape"> | |
| <enum>QFrame::Box</enum> | |
| </property> | |
| <property name="interactive"> | |
| <bool>true</bool> | |
| </property> | |
| <property name="dragMode"> | |
| <enum>QGraphicsView::NoDrag</enum> | |
| </property> | |
| <property name="resizeAnchor"> | |
| <enum>QGraphicsView::NoAnchor</enum> | |
| </property> | |
| </widget> | |
| </item> | |
| <item> | |
| <widget class="PlotWidget" name="us2_plot"/> | |
| </item> | |
| <item> | |
| <widget class="PlotWidget" name="us3_plot"/> | |
| </item> | |
| <item> | |
| <widget class="PlotWidget" name="battery_plot"/> | |
| </item> | |
| </layout> | |
| </widget> | |
| </item> | |
| <item> | |
| <widget class="QGroupBox" name="controlBox"> | |
| <property name="title"> | |
| <string>Control</string> | |
| </property> | |
| <layout class="QVBoxLayout" name="verticalLayout_4"> | |
| <item> | |
| <widget class="QPushButton" name="pushButton"> | |
| <property name="text"> | |
| <string>PushButton</string> | |
| </property> | |
| </widget> | |
| </item> | |
| </layout> | |
| <zorder>plotBox</zorder> | |
| <zorder>pushButton</zorder> | |
| </widget> | |
| </item> | |
| </layout> | |
| </widget> | |
| <widget class="QMenuBar" name="menubar"> | |
| <property name="geometry"> | |
| <rect> | |
| <x>0</x> | |
| <y>0</y> | |
| <width>724</width> | |
| <height>21</height> | |
| </rect> | |
| </property> | |
| </widget> | |
| <widget class="QStatusBar" name="statusbar"/> | |
| </widget> | |
| <customwidgets> | |
| <customwidget> | |
| <class>PlotWidget</class> | |
| <extends>QGraphicsView</extends> | |
| <header>pyqtgraph</header> | |
| </customwidget> | |
| </customwidgets> | |
| <resources/> | |
| <connections/> | |
| </ui> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''import sys | |
| from PyQt4 import QtCore, QtGui''' | |
| import pyqtgraph as pg | |
| from pyqtgraph.Qt import QtCore, QtGui | |
| import numpy as np | |
| import sys | |
| from test_ui import Ui_MainWindow | |
| class StartQT4(QtGui.QMainWindow): | |
| def __init__(self, parent=None): | |
| QtGui.QWidget.__init__(self, parent) | |
| self.ui = Ui_MainWindow() | |
| self.ui.setupUi(self) | |
| self.ui.us1_plot.setLabel('bottom', 'Time', 's') | |
| self.ui.us1_plot.setDownsampling(mode='peak') | |
| self.ui.us1_plot.setClipToView(True) | |
| self.ui.us1_plot.setLimits(xMax=0) | |
| self.curve_us1 = self.ui.us1_plot.plot() | |
| self.us1_data = np.empty(100) | |
| self.us1_data_ptr = 0 | |
| self.timer = pg.QtCore.QTimer() | |
| self.timer.timeout.connect(self.update) | |
| self.timer.start(50) | |
| def update(self): | |
| self.us1_data[self.us1_data_ptr] = np.random.normal() | |
| self.us1_data_ptr += 1 | |
| if self.us1_data_ptr >= self.us1_data.shape[0]: | |
| tmp = self.us1_data | |
| self.us1_data = np.empty(self.us1_data.shape[0] * 2) | |
| self.us1_data[:tmp.shape[0]] = tmp | |
| self.curve_us1.setData(self.us1_data[:self.us1_data_ptr]) | |
| self.curve_us1.setPos(-self.us1_data_ptr, 0) | |
| self.curve_us1.setData(self.us1_data[:self.us1_data_ptr]) | |
| if __name__ == "__main__": | |
| app = QtGui.QApplication(sys.argv) | |
| myapp = StartQT4() | |
| myapp.show() | |
| sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment