qiskit-metal icon indicating copy to clipboard operation
qiskit-metal copied to clipboard

It works but suddenly close after redenring GUI

Open dgks0n opened this issue 9 months ago • 2 comments

Hi there~ I tried to make a sample with qiskit-metal version 0.1.5 with below steps. I created simple python file name as helloworld.py with simple snippets:

from qiskit_metal import MetalGUI
from qiskit_metal import designs

design = designs.DesignPlanar()
design.overwrite_enabled = True

design.chips.main.size.size_x = '11mm'
design.chips.main.size.size_y = '9mm'

gui = MetalGUI(design)

Finally, I executed that python scripts by using command python helloworld.py, it works but immediately close GUI after that. I even cannot see the GUI and there is no error logs.

Strange thing is, it works as well with above code snippets with Jupyter notebook. I am wondering why? How can I solve this problem?

dgks0n avatar Jan 22 '25 15:01 dgks0n

If you’re running from a script, it might be closing the event loop in QT, the gui framework we use. In Jupiter, the way we automatically set it up is that there is a background asynchronous event that is running and keeping the GUI open. There is a function somewhere in the documentation or if you just google it or ask some AI agent to tell you how to run it from a script so that the event loop runs in the background or blocks the executionSent from my iPhoneOn Jan 22, 2025, at 10:07 AM, dgks0n @.***> wrote: Hi there~ I tried to make a sample with qiskit-metal version 0.1.5 with below steps. I created simple python file name as helloworld.py with simple snippets: from qiskit_metal import MetalGUI from qiskit_metal import designs

design = designs.DesignPlanar() design.overwrite_enabled = True

design.chips.main.size.size_x = '11mm' design.chips.main.size.size_y = '9mm'

gui = MetalGUI(design)

Finally, I executed that python scripts by using command python helloworld.py, it works but immediately close GUI after that. I even cannot see the GUI and there is no error logs. Strange thing is, it works as well with above code snippets with Jupyter notebook. I am wondering why? How can I solve this problem?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

zlatko-minev avatar Jan 22 '25 15:01 zlatko-minev

@zlatko-minev I think this is the issue I brought up on the Slack a while back.

@dgks0n the workaround is to add a call to gui.qApp.exec_() in the script, which is a blocking call that should make the GUI behave. Be aware that it will cause a segfault after the window is closed, so is only suitable for the end of the script after all generation functions have been run.

SamWolski avatar Feb 11 '25 15:02 SamWolski