SOLVED: no halt at matplotlib.pyplot.show()
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: no halt at matplotlib.pyplot.show()
I put an input() call after matplotlib.pyplot.show() just to see if this could force my macro to pause and give the main thread focus to the plot ... and indeed it does. The plot becomes interactive. However, this is of course no solution because it would mean I have to press enter in the Python console to resume the process. I therefore instead tried to lock the thread of my macro using the threading.Lock.acquire() method and unlock it in my button-press handler with threading.Lock.release(). However, threading.Lock.acquire() does not manage to hold the execution of my macro.
I am way out of my depth here and would appreciate some help.
I am way out of my depth here and would appreciate some help.
Re: no halt at matplotlib.pyplot.show()
@oliveroxtoby would you mind weighing in ? since CfdOF leverages plot workbench I figured you may know a thing or 2 about this issue?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: no halt at matplotlib.pyplot.show()
maybe use args to the call? or look at the plt mode
https://matplotlib.org/stable/api/_as_g ... .show.html
fc might behave funny since one suppose mpl is using fc-qt main-loop
if you can boil it down to a mve others might be quick to figure out how to do it
https://matplotlib.org/stable/api/_as_g ... .show.html
fc might behave funny since one suppose mpl is using fc-qt main-loop
if you can boil it down to a mve others might be quick to figure out how to do it
Re: no halt at matplotlib.pyplot.show()
I tried to run Matplotlib in a separate thread, but it objects to this. Easiest would be to load my script as a module from the Python Console, so it runs in the main thread. How do I get FC to recognize my .py as a module? I tried placing a dummy.py into a ../Mod/fcFEM, directory, but >>>import fcFEM did not do the trick. Do I need to register my file somewhere?
Re: no halt at matplotlib.pyplot.show()
SORRY - the answer is here: https://wiki.freecadweb.org/Workbench_creation. Import works now.
Re: no halt at matplotlib.pyplot.show()
Do you mind explicitly pasting the solution? (For posterity)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: no halt at matplotlib.pyplot.show()
right, running it in a separate thread is probably not the easiest way to get it working.
(but admittedly have not tried anything with mpl and fc, so not really in the know here)
regarding imports, once the penny drops that fc appears to skips a level of folders (compared to vanilla python) it becomes easier to do working imports
with file structure:
and files
from the console it becomes...
ps: meant to say: mpl might behave funny since one suppose mpl is using fc-qt main-loop (in the earlier post)
ps2: if nothing else works you can always make your own qt-frame/dialogue as any example of making a fc dialogue and embed a figurecanvas... https://matplotlib.org/stable/gallery/u ... gskip.html
(but admittedly have not tried anything with mpl and fc, so not really in the know here)
regarding imports, once the penny drops that fc appears to skips a level of folders (compared to vanilla python) it becomes easier to do working imports
with file structure:
Code: Select all
userdir
|- Mod
| |- testmodule
| | |- submodule
| | | | dummy2.py
| | | dummy.py
Code: Select all
# -*- coding: utf-8 -*-
# dummy.py
print('imported', __file__)
def foo():
print('in foo')
return 5
Code: Select all
# -*- coding: utf-8 -*-
# dummy2.py
print('imported', __file__)
def bar():
print('in bar')
return 10
from the console it becomes...
Code: Select all
# on linux
>>> import dummy
imported /home/x/.FreeCAD/Mod/testmodule/dummy.py
>>> from submodule import dummy2
imported /home/x/.FreeCAD/Mod/testmodule/submodule/dummy2.py
>>> dummy.foo()
in foo
5
>>> dummy2.bar()
in bar
10
>>>
ps2: if nothing else works you can always make your own qt-frame/dialogue as any example of making a fc dialogue and embed a figurecanvas... https://matplotlib.org/stable/gallery/u ... gskip.html
Re: no halt at matplotlib.pyplot.show()
Thanks!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: no halt at matplotlib.pyplot.show()
Import works, but the issue with Matlibplot persists. I also notice that it isn't consistent and therefore difficult to reproduce. For example, adding an input() statement after plt.show() activated the buttons at some point in time, but when I tried this at a later point in time, it didn't. There are some posts around that report problems with running Matplotlib with Python 3.10, e.g. https://stackoverflow.com/questions/695 ... ython-3-10, where it says:
Code: Select all
"After some digging and testing I think I've found out that Matplotlib, and pylab aren't compatible with python3.10 yet. For the time being I've kept python3.9 along with 3.10 so whenever I use matplotlib, numpy, or pylab, I just use version 3.9"
Re: no halt at matplotlib.pyplot.show()
python 3.10 is still problematic for using in FreeCAD, JFYI
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs