xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
Other
127 stars 62 forks source link

error in plot_chifit: PyNoAppError: The wx.App object must be created first! #413

Closed duoduoss closed 4 months ago

duoduoss commented 1 year ago

Dear @newville

I have been trying to use python (in Spyder) for path fitting. I just encountered a new (it worked yesterday) error that I could not see the plots of fitting results, but the fitting itself worked out with a ".out" file: " plot_chifit(dset, title='Ti66_fitting', rmax=6)

File "C:\ProgramData\xrayLarch\lib\site-packages\larch\wxlib\xafsplots.py", line 683, in plot_chifit _plot(dataset.data.k, data_chik+offset, xmin=kmin, xmax=kmax,

File "C:\ProgramData\xrayLarch\lib\site-packages\larch\wxlib\plotter.py", line 486, in _plot plotter = _getDisplay(wxparent=wxparent, win=win, size=size,

File "C:\ProgramData\xrayLarch\lib\site-packages\larch\wxlib\plotter.py", line 339, in _getDisplay display, isnew = _get_disp(symname, creator, win, display_dict, wxparent,

File "C:\ProgramData\xrayLarch\lib\site-packages\larch\wxlib\plotter.py", line 327, in _get_disp display = creator(window=win, wxparent=wxparent,

File "C:\ProgramData\xrayLarch\lib\site-packages\larch\wxlib\plotter.py", line 114, in init PlotFrame.init(self, parent=None, size=size,

File "C:\ProgramData\xrayLarch\lib\site-packages\wxmplot\plotframe.py", line 18, in init BaseFrame.init(self, parent=parent, title=title,

File "C:\ProgramData\xrayLarch\lib\site-packages\wxmplot\baseframe.py", line 58, in init wx.Frame.init(self, parent, -1, title, **kws)

PyNoAppError: The wx.App object must be created first!"

Could you please help me with this?
Thank you in advance, Best regards

newville commented 1 year ago

@duoduoss Yes, the current plotting requires wxPython to be installed. I have not tried using that from within Spyder, but I'm not too surprised that it doesn't work very well from within a Qt environment.

maurov commented 4 months ago

@duoduoss I am closing this issue because it was already replied by @newville. You cannot use the standard plotting of Larch inside a Qt environment. Please, use larch.plot.plotly_xafsplots module instead.