Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to call splot in interactive mode from a Qt5 GUI application #153

Open
noste99 opened this issue Nov 18, 2023 · 1 comment
Open

Comments

@noste99
Copy link

noste99 commented Nov 18, 2023

When calling the IRAF command iraf.onedspec.splot(filename) inside a python function (making use of subprocess.run) linked to a Qt5 button on the GUI, a window opens with title graphics1 but it remains black and the following traceback info is printed:

`Traceback (most recent call last):
File "/archive/stefan/ARCHIVE/ePython/EC_PIPELINE/EC_Envelopes.py", line 117, in triggeredImageView
pb.viewImage(self.lbl_val_SCIE.text())
File "/archive/stefan/ARCHIVE/ePython/EC_PIPELINE/pipe_Blocks.py", line 83, in viewImage
cmd = iraf.onedspec.splot(imname)
File "/usr/lib/python3/dist-packages/pyraf/iraftask.py", line 836, in call
return self.run(*args, **kw)
File "/usr/lib/python3/dist-packages/pyraf/iraftask.py", line 375, in run
self._run(redirKW, specialKW)
File "/usr/lib/python3/dist-packages/pyraf/iraftask.py", line 880, in _run
irafexecute.IrafExecute(self, iraf.getVarDict(), **redirKW)
File "/usr/lib/python3/dist-packages/pyraf/irafexecute.py", line 348, in IrafExecute
irafprocess.run(task, pstdin=stdin, pstdout=stdout, pstderr=stderr)
File "/usr/lib/python3/dist-packages/pyraf/irafexecute.py", line 512, in run
self.slave()
File "/usr/lib/python3/dist-packages/pyraf/irafexecute.py", line 644, in slave
xmit()
File "/usr/lib/python3/dist-packages/pyraf/irafexecute.py", line 827, in xmit
gki.kernel.append(numpy.frombuffer(xdata, dtype=numpy.int16))
File "/usr/lib/python3/dist-packages/pyraf/gki.py", line 901, in append
self.stdgraph.append(arg, isUndoable)
File "/usr/lib/python3/dist-packages/pyraf/gki.py", line 901, in append
self.stdgraph.append(arg, isUndoable)
File "/usr/lib/python3/dist-packages/pyraf/gki.py", line 561, in append
self.translate(buffer, 0)
File "/usr/lib/python3/dist-packages/pyraf/gkitkbase.py", line 822, in translate
self.incrPlot() # pure virtual, must be overridden
File "/usr/lib/python3/dist-packages/pyraf/gkitkplot.py", line 125, in incrPlot
function(args)
File "/usr/lib/python3/dist-packages/pyraf/gkitkplot.py", line 302, in tkplot_polyline
gw.create_line(
(tuple(scaled.ravel().astype(numpy.int32))), **options)
File "/usr/lib/python3.10/tkinter/init.py", line 2823, in create_line
return self._create('line', args, kw)
File "/usr/lib/python3.10/tkinter/init.py", line 2805, in _create
return self.tk.getint(self.tk.call(
_tkinter.TclError: bad screen distance "2.0"

`
All other iraf commands work fine in my application. I refer here to splot because it is rather simple to use, but the objective of my application is to pass manually through the different steps of the calibration of an ECHELLE spectrum. What blocks me is apall running in an interactive mode and due to the fact this seems incompatible with Qt5 I am blocked. Thanks in advance for your advice.

@noste99
Copy link
Author

noste99 commented Dec 24, 2023

For the time being the workaround I found was based on the use of a subprocess. The python function I wrote setting first the splot parameters and then launches the splot task is now saved in a self-standing .py script. The latter is launched by clicking a button in a Qt5 GUI using the command: subprocess.run(["python3.10", "splot_sub.py"]).
The splot command first asks whether the Image line/aperture to be plotted is the one set in the line parameter. When confirmed, a typical IRAF interactive graphics window opens outside the Qt5 application. The latter waits until the work in the graphics window is finished by typing "q". Once that happened, the Qt5 application takes control again. It would of course be nice to integrate the IRAF graphics window in the Qt5 application window but for the time being the workaround is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant