-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Hey @newville first, thanks for this library!
Not sure if it matters, but I am running on Linux with wayland.
wxmplot version is 2025.1.6
I tried running demo.py with the self-updating plots and they don't seem to work.
The screen updates only after some sort of interaction happens, such as left mouse clicks and window resizing.
I also wrote a small app that has a button to trigger update_traces and verify the behavior. I post that below.
I dug through your code a bit and I found a comment in plotpanel.py
def oplot(...):
# ...code
if not delay_draw:
self.draw()
# self.canvas.Refresh()
conf.ntrace = conf.ntrace + 1
return _linesAfter uncommenting # self.canvas.Refresh(), my small app works as expected. But the demo still doesn't. I didn't get around to fixing it, but explicitly calling self.plotframe.panel.canvas.Refresh() makes it work but isn't ideal.
Here is the small app:
from numpy import ones, linspace, cos, random
import wx
from wxmplot import PlotPanel
class Frame(wx.Frame):
def __init__(self):
super().__init__(None, title="Counter", size=wx.Size(400,400))
self.panel = wx.Panel(self)
self.button = wx.Button(self.panel, label="0")
self.button.Bind(wx.EVT_BUTTON, self.on_click)
self.plot = PlotPanel(self.panel, (300, 400))
self.plot.plot([0], [1], color='red', linewidth=1)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.button, 0, wx.EXPAND | wx.ALL, 5)
sizer.Add(self.plot, 1, wx.EXPAND | wx.ALL, 5)
self.panel.SetSizer(sizer)
def on_click(self, event):
# Make up some data
npts = 20
x = linspace(0, 40.0, npts)
y = 0.4 * cos(x/2.0) + random.normal(scale=0.03, size=npts)
# Plot these new points
self.plot.update_line(0, x,y, True)
# Uncomment to actually refresh the panel contents.
# self.plot.canvas.Refresh()
app = wx.App(False)
Frame().Show()
app.MainLoop()