i am currently trying to write a user interface for one of my NGSolve simulations using PyQt5.
In the attached MWE, the user interface is used to read in a parameter and execute the poisson.py script using the provided parameter via pressing a ‘start script’ button.
The computed result should then be shown in the Netgen Window, such that one can quickly adjust the parameter and view the effect on the result.
This is where things don’t work out yet. The Netgen window is opened and updated only after the GUI window is closed, despite Draw() is called in the successfully executed script.
If a Netgen window is already open, the window is frozen until the UI is terminated.
On top of that, i would like to embed or dock the Netgen window into the PyQt UI, such that the user only has one window to focus on.
Hope that someone with a little bit of experience in PyQt5 and NGSolve can help me out here
thanks for your response! Looks exactly like what I’m looking for.
Unfortunately I am not very experienced in managing Ubuntu packages and run into some trouble installing it.
NgsGui works on an older version of ipykernel, but I’d like to use Spyder IDE, which requires the latest version of ipykernel . Through the installation i thus get the error message that : ‘ngsgui 0.1.11 requires ipykernel<5, but you’ll have ipykernel 5.3.4 which is incompatible’.
Can you tell me how to resolve this?
Running the demo programs Spyder encounters an unknown internal error.
When i play around with the lighting and clipping settings, it dissappears after a while most times…
I would also like to set the min and max value of the drawn function programatically, is this possible?
In the meantime i tried to find a workaround for the GUI using the VTK output of ngsolve. The field is written as .vtk file via vtk = VTKOutput(…) and calling vtk.Do(). It is then read back in to a PyQt vtk object and integrated in the display:
I attached the example code. In my opinion, this looks really nice and is very convenient for the user. Unfortunately, the vtk output file gets very large, when a more complex mesh is used, and the writing/reading takes a long time. If one could skip that step by converting the NGSolve vtk-object to a PyQt vtk-object this may work much faster.
Maybe someone with a little experince knows if and how this is possible.
Can you send the script creating the clipping error?
Going via vtk is an option, but the ngsolve vtk object doesn’t have anything to do with the python vtk objects provided by pyqt… To bypass the writing you would have to extract the required information manually from the ngsolve objects (for example as numpy arrays) and put it into pyqt… Which is some work I guess and needs some understanding of vtk and ngsolve.
The script creating the clipping error is basically the one i started with (i attached it again). In my console window i get the warning:
libpng warning: bKGD: invalid
But i cant find anything related to ngsgui, all forum entries for this warning relate to *.png files…
Extracting the information manually from the ngsolve vtk object to convert it into pyqt seems too much of a task for me right now, but thanks for confirming
not sure if you read my last posting but i noticed that for the example script i sent, the scene commands (i.e. scene.setShowWireframe(True) ) are also broken. Calling them leads to an error in ngsgui/startup.py:
‘SpyderKernel’ object has no attribute ‘send_spyder_msg’
Im on ipykernel 5.3.4. So maybe still a kernel problem?
It seems like you are trying to use the Spyder integration. Which version of spyder do you use? I think I have tested it with 4.1
I cannot reproduce your flickering as well. Can you send the script that is producing it (you only included some pyqt scripts but they do not use ngsgui. Also do you have the most current versions of the software packages ngsgui and ngsolve? Which versions of python, pyqt,… are you using?
my ultimate goal is to use a pyqt GUI to manipulate the output in the NGSgui Window (merging them into one window would be cool but is beyond my abilities). Thats why im using pyqt.
The examples i attached earlier open a pyqt window, that, besides the clipping error, succesfully changes the output in the ngsgui tab in Spyder. Btw you are correct, i am using Spyder 4.1.4 with Python 3.7, NGSolve 6.2.2004 and NGSgui 0.1.13.dev0.
The clipping error already occurs running the following simple poisson example without pyqt. It opens the NGSgui Tab in Spyder and displays the solution, but most of the times it has the clipping error.
Hm I cannot reproduce the clipping error yet…
With the setting of parameters, you are right, this wasn’t working in spyder due to a change in their interface. It is fixed now. Note that to set the colormap you first have to turn autoscale off:
thanks for fixing the setting of parameters! Adding Buttons etc. to ngsgui is a great feature, but my application is too extensive to be embedded in the ngs window (it contains several scrollbars, sliders, progressbars and so on).
I might have some new info on the clipping error though:
When running the program from a terminal, the following message is shown:
b’active samplers with a different type refer to the same texture image unit’, which relates to an OpenGL problem i think…
Displaying the edge numbers also reveals, that they are in fact in the right place and it is only a display-error.
Creating a plugin allows you to completely change everything about the gui. So basically you get the gui object at initialization and you can do with it whatever you want. You can patch classes and functions and therefore create the interface that you like. It has the advantage, that the gui class itself still handles the interfacing to the concurrent python thread in which it is running the code and it also handles shared contextes between multiple rendering windows. But you can of course build your own application and take some guidance from the source code of the ngsgui