From: daniele <dga...@gm...> - 2005-02-13 14:56:50
|
Hi, I=B4m new to matplotlib. I=B4m writing a program using wxPython. The purpose of it is to insert some prices in a form and get a plot of them in a graph inside the main window. Is it possible to refresh the graph with the new values after a button is pushed? How? Thank you very much. DG |
From: John H. <jdh...@ac...> - 2005-02-13 19:56:04
|
>>>>> "daniele" =3D=3D daniele <dga...@gm...> writes: daniele> Hi, I=B4m new to matplotlib. I=B4m writing a program using daniele> wxPython. The purpose of it is to insert some prices in a daniele> form and get a plot of them in a graph inside the main daniele> window. Is it possible to refresh the graph with the new daniele> values after a button is pushed? How? Thank you very daniele> much. DG You want to define some function that updates the data in your plot and then calls canvas.draw(). You can then connect that callback to the clicked event of your button. See, for example, embedding_in_wx3.py in the matplotlib examples directory, which does just this (thanks Andrew!) JDH |
From: daniele <dga...@gm...> - 2005-02-14 18:53:12
|
Thank you very much for your advice. Unfortunately when I try to run the script I get: File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils= .py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Python24\MathPlot_examples\examples\embedding_in_wx3.py", line 156, in ? app =3D MyApp(0) File "C:\Python24\Lib\site-packages\wx-2.5.3-msw-ansi\wx\_core.py", line 5301, in __init__ self._BootstrapApp() File "C:\Python24\Lib\site-packages\wx-2.5.3-msw-ansi\wx\_core.py", line 4980, in _BootstrapApp return _core_.PyApp__BootstrapApp(*args, **kwargs) File "C:\Python24\MathPlot_examples\examples\embedding_in_wx3.py", line 111, in OnInit self.panel =3D XRCCTRL(self.frame,"MainPanel") File "C:\Python24\Lib\site-packages\wx-2.5.3-msw-ansi\wx\xrc.py", line 203, in XRCCTRL return window.FindWindowById(XRCID(str_id)) AttributeError: 'NoneType' object has no attribute 'FindWindowById' Which frankly I don=B4t understand. Any further advice? Thank you, DG |
From: John H. <jdh...@ac...> - 2005-02-16 14:41:58
|
>>>>> "daniele" =3D=3D daniele <dga...@gm...> writes: daniele> Thank you very much for your advice. Unfortunately when daniele> I try to run the script I get: daniele> File daniele> "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scr= iptutils.py", daniele> line 310, in RunScript exec codeObject in daniele> __main__.__dict__ File daniele> "C:\Python24\MathPlot_examples\examples\embedding_in_wx3.py"= , daniele> line 156, in ? app =3D MyApp(0) File daniele> "C:\Python24\Lib\site-packages\wx-2.5.3-msw-ansi\wx\_core.py= ", daniele> line 5301, in __init__ self._BootstrapApp() File daniele> "C:\Python24\Lib\site-packages\wx-2.5.3-msw-ansi\wx\_core.py= ", daniele> line 4980, in _BootstrapApp return daniele> _core_.PyApp__BootstrapApp(*args, **kwargs) File daniele> "C:\Python24\MathPlot_examples\examples\embedding_in_wx3.py"= , daniele> line 111, in OnInit self.panel =3D daniele> XRCCTRL(self.frame,"MainPanel") File daniele> "C:\Python24\Lib\site-packages\wx-2.5.3-msw-ansi\wx\xrc.py", daniele> line 203, in XRCCTRL return daniele> window.FindWindowById(XRCID(str_id)) AttributeError: daniele> 'NoneType' object has no attribute 'FindWindowById' daniele> Which frankly I don=B4t understand. Any further advice? daniele> Thank you, DG This looks either like a wx version problem or a bad wx install.=20 wx gurus, is app =3D MyApp(0) expected to work on wx-2.5.3 ? Can anyone test this examples/embedding_in_wx3.py under a similar configuration? JDH |
From: Chris B. <Chr...@no...> - 2005-02-16 19:17:35
|
John Hunter wrote: > wx gurus, is app = MyApp(0) expected to work on wx-2.5.3 ? I'm not sure, but app = wx.GetApp() should. > Can anyone test this examples/embedding_in_wx3.py under a similar > configuration? I've been meaning to do this for ages, so I guess now's a good time. I'll report back if/when I get to it! -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: Matt N. <new...@ca...> - 2005-02-16 20:11:28
|
I haven't tried wxPython with Python2.4, but with WinXP, Python 2.3.2, wxPython 2.5.3.1, and matplotlib 0.72.0, embedding_in_wx.py embedding_in_wx2.py embedding_in_wx3.py all work ok for me. For completeness, embedding_in_wx4.py fails: Traceback (most recent call last): File "embedding_in_wx4.py", line 22, in ? from matplotlib.numerix import rand ImportError: cannot import name rand but replacing from matplotlib.numerix import rand with from matplotlib.numerix.random_array import random as rand fixes that problem. I think embedding_in_wx4.py has some other problems (Toolbar2 is not visible without a resize, the window does not respond to all events, including closing the window), but that's a separate topic. I agree with John's assessment that the original poster probably had a bad install of wx. Does the wx demo run ok?? Do any other matplotlib examples run? If so, another suggestion would be to try to replace MyApp(0) with PySimpleApp(0). Hope that helps, --Matt |