Two points in addition.
- I modified it as follows,
- wx.BufferedPaintDC(self.panel, self.bitmap)
+ dc = wx.BufferedPaintDC(self.panel, self.bitmap)
I attach the last modified files. I hope these would help people who want to start dealing with images.
test-drawing-speed-ver2+.zip (5.5 KB)
- Someone may want to use wx GUI and pyqtgraph function lIke this.
import wx
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
class Frame(wx.Frame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.btn = wx.Button(self, label="Press me")
self.btn.Bind(wx.EVT_BUTTON, self.run)
def run(self, evt):
self.qfrm = pg.GraphicsLayoutWidget(title=self.__module__)
image = pg.ImageItem() # create image
view = self.qfrm.addViewBox() # create view
view.setAspectLocked(True)
view.addItem(image)
def update():
h, w = 768, 1152
src = (255 * np.random.rand(h, w)).astype(np.uint8)
image.setImage(src.T)
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start()
self.qfrm.show()
pg.exec()
if __name__ == "__main__":
qApp = QtGui.QApplication()
app = wx.App()
frm = Frame(None)
frm.Show()
app.MainLoop()
WX-QT Dream Tag!