Created
August 15, 2017 21:07
-
-
Save chrismullins/e5ce27ace4f3aa11fb564611e37698bd to your computer and use it in GitHub Desktop.
MainWindow with ImageView instead of GraphicsLayoutWidget
This file contains 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>MainWindowGUI</class> | |
<widget class="QMainWindow" name="MainWindowGUI"> | |
<property name="geometry"> | |
<rect> | |
<x>0</x> | |
<y>0</y> | |
<width>800</width> | |
<height>600</height> | |
</rect> | |
</property> | |
<property name="windowTitle"> | |
<string>MainWindow</string> | |
</property> | |
<widget class="QWidget" name="centralwidget"> | |
<layout class="QGridLayout" name="gridLayout"> | |
<item row="0" column="0"> | |
<layout class="QHBoxLayout" name="horizontalLayout"> | |
<item> | |
<widget class="QPushButton" name="pushButton"> | |
<property name="text"> | |
<string>PushButton</string> | |
</property> | |
</widget> | |
</item> | |
<item> | |
<spacer name="horizontalSpacer"> | |
<property name="orientation"> | |
<enum>Qt::Horizontal</enum> | |
</property> | |
<property name="sizeHint" stdset="0"> | |
<size> | |
<width>40</width> | |
<height>20</height> | |
</size> | |
</property> | |
</spacer> | |
</item> | |
</layout> | |
</item> | |
<item row="1" column="0"> | |
<widget class="ImageView" name="graphicsView"/> | |
</item> | |
</layout> | |
</widget> | |
<widget class="QMenuBar" name="menubar"> | |
<property name="geometry"> | |
<rect> | |
<x>0</x> | |
<y>0</y> | |
<width>800</width> | |
<height>20</height> | |
</rect> | |
</property> | |
</widget> | |
<widget class="QStatusBar" name="statusbar"/> | |
<widget class="QToolBar" name="toolBar"> | |
<property name="windowTitle"> | |
<string>toolBar</string> | |
</property> | |
<attribute name="toolBarArea"> | |
<enum>TopToolBarArea</enum> | |
</attribute> | |
<attribute name="toolBarBreak"> | |
<bool>false</bool> | |
</attribute> | |
</widget> | |
</widget> | |
<customwidgets> | |
<customwidget> | |
<class>ImageView</class> | |
<extends>QGraphicsView</extends> | |
<header>pyqtgraph</header> | |
</customwidget> | |
</customwidgets> | |
<resources/> | |
<connections/> | |
</ui> |
This file contains 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 PyQt5 import QtCore, QtGui, uic | |
import pyqtgraph as pq | |
import numpy as np | |
from PIL import Image | |
qtCreatorFile = "MainWindowGUI.ui" # Enter file here. | |
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile) | |
class MyApp(QtGui.QMainWindow, Ui_MainWindow): | |
def __init__(self): | |
QtGui.QMainWindow.__init__(self) | |
Ui_MainWindow.__init__(self) | |
self.setupUi(self) | |
#self.dataplot = self.graphicsView.addPlot(title="My Data") | |
im = Image.open('../bridge512x512.tif') | |
data = np.array(im) | |
self.imv = self.graphicsView.setImage(data) | |
def btn_clk(self): | |
L = [1,2,3,4,5] | |
self.dataplot.plot(L) | |
if __name__ == "__main__": | |
app = QtGui.QApplication(sys.argv) | |
window = MyApp() | |
window.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment