Not starting GUI in Windows

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
pedrovbeltran
Posts: 4
Joined: Mon Jan 16, 2023 9:28 am
Contact:

Not starting GUI in Windows

Post by pedrovbeltran »

I'm currently working on a program that automates a certain script, but I call the showMainWindow(), but I got nothing going on. Here's a piece of my scirpt (it's large):

Code: Select all

import FreeCAD as App
import FreeCADGui as Gui

Gui.showMainWindow()

# Do something

Gui.exec_loop()
I tried to modify this by "import threading" and try to execute the exec_loop() as a thread but still I have nothing going on. The only way this works properly is if I execute this script through FreeCADCmd, but I'd like this script to be independent.
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Not starting GUI in Windows

Post by heda »

pedrovbeltran wrote: Mon Jan 23, 2023 8:43 am The only way this works properly is if I execute this script through FreeCADCmd
yes, why would any other python session have full access to the fc session...
unless one sets that other session up properly, but why would one spend time even thinking about doing that when
freecadcmd is available for use without any hazzles and things work?

"but I'd like this script to be independent."

independent from what more specifically?
freecad?

flip it, whatever you miss in fc-environment, put it in there - you can pip install anything you'd like (or compile to match if you prefer that)
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Not starting GUI in Windows

Post by onekk »

pedrovbeltran wrote: Mon Jan 23, 2023 8:43 am ...
this works properly is if I execute this script through FreeCADCmd, but I'd like this script to be independent.
Obviously the Gui is not responding as simply importing FreeCADGui is not like executing FreeCAD so there is no mainwindow to show if you haven't started it.

There are around some posts that describe how to make Gui work when FreeCAD is invoked by an external Python interpreter but is clearly stated that this is not "the way FreeCAD was designed for" so many things are not working.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
carlos.costacano
Posts: 10
Joined: Fri Mar 24, 2023 8:17 pm

Re: Not starting GUI in Windows

Post by carlos.costacano »

heda wrote: Mon Jan 23, 2023 9:36 pm flip it, whatever you miss in fc-environment, put it in there - you can pip install anything you'd like (or compile to match if you prefer that)
would you explain how to pip install to use with FreeCADcmd

thanks in advance
Post Reply