Utiliser Freecad dans Q widget pyqt5
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Utiliser Freecad dans Q widget pyqt5
Bonjour
J ai crée un logiciel en Python 3.6 à l'aide de pyqt5 pour la GUI
Je voulais savoir s'il était possible d introduire ou ancrer Freecad dans Q widget de mon appli
C est juste pour faire un Viewer dans mon appli (charger des steps, déplacer des objets utiliser les outils de mesures de Freecad)
J ai crée un logiciel en Python 3.6 à l'aide de pyqt5 pour la GUI
Je voulais savoir s'il était possible d introduire ou ancrer Freecad dans Q widget de mon appli
C est juste pour faire un Viewer dans mon appli (charger des steps, déplacer des objets utiliser les outils de mesures de Freecad)
Re: Utiliser Freecad dans Q widget pyqt5
Merci de votre réponse
Je vais étudier cette piste et je posterai la solution quand ça sera opérationnelle
Je vais étudier cette piste et je posterai la solution quand ça sera opérationnelle
Re: Utiliser Freecad dans Q widget pyqt5
Au passage, si jamais tu souhaites refaire ce genre de chose, je te conseille plutôt Qt for Python (autrement dit PySide2) que PyQt.
Comme c'est maintenant soutenu par Qt directement, c'est plus complet et plus à jour.
Comme c'est maintenant soutenu par Qt directement, c'est plus complet et plus à jour.
Re: Utiliser Freecad dans Q widget pyqt5
Ci joint un exemple de code pour intégrer FreeCad dans un widget
Code: Select all
import subprocess
import sys
import time
import win32gui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import (QWidget, QApplication,
QVBoxLayout)
class Main(QWidget):
"""Classe représentant les options de configuration de GRUB"""
def __init__(self, parent=None):
QWidget.__init__(self, parent)
# create a process
exePath = "C:\\xxx\\FreeCAD 0.18\\bin\\FreeCAD.exe"
subprocess.Popen (exePath)
# Temps démarrage FreeCad
time.sleep (10)
hwnd = win32gui.FindWindowEx (0, 0, 0, "FreeCAD 0.18")
window = QWindow.fromWinId (hwnd)
self.container = self.createWindowContainer (window)
self.setGeometry (500, 500, 800, 800)
layout = QVBoxLayout (self)
layout.addWidget (self.container)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
win = Main()
win.setWindowTitle("Test FreeCAD")
sys.exit(app.exec_())
Re: Utiliser Freecad dans Q widget pyqt5
Excellent Tonio16, merci beaucoup pour le partage
Formations - Assistance - Développement : https://freecad-france.com
Re: Utiliser Freecad dans Q widget pyqt5
Hi
First of all, sorry about that I can only speak English here.
What if I want to display an App inside FreeCAD, I had a try, but I cound't import win32gui.
Is there any way to fix it?
Many thanks.
Best Regards,
Mea08kw
Re: Utiliser Freecad dans Q widget pyqt5
HiTonio16 wrote: ↑Sun Oct 27, 2019 10:29 am Ci joint un exemple de code pour intégrer FreeCad dans un widgetCode: Select all
import subprocess import sys import time import win32gui from PyQt5.QtGui import * from PyQt5.QtWidgets import (QWidget, QApplication, QVBoxLayout) class Main(QWidget): """Classe représentant les options de configuration de GRUB""" def __init__(self, parent=None): QWidget.__init__(self, parent) # create a process exePath = "C:\\xxx\\FreeCAD 0.18\\bin\\FreeCAD.exe" subprocess.Popen (exePath) # Temps démarrage FreeCad time.sleep (10) hwnd = win32gui.FindWindowEx (0, 0, 0, "FreeCAD 0.18") window = QWindow.fromWinId (hwnd) self.container = self.createWindowContainer (window) self.setGeometry (500, 500, 800, 800) layout = QVBoxLayout (self) layout.addWidget (self.container) self.show() if __name__ == "__main__": app = QApplication(sys.argv) win = Main() win.setWindowTitle("Test FreeCAD") sys.exit(app.exec_())
First of all, sorry about that I can only speak English here.
What if I want to display an App inside FreeCAD, I had a try, but I cound't import win32gui.
Is there any way to fix it?
Many thanks.
Best Regards,
Mea08kw
Re: Utiliser Freecad dans Q widget pyqt5
Hi @mea08kw,
please use a translator to post in French in this sub-forum.
Pour embarquer une fenêtre d'une autre application dans FreeCAD, regarde :
To embed an external app window in FreeCAD, see:
please use a translator to post in French in this sub-forum.
Pour embarquer une fenêtre d'une autre application dans FreeCAD, regarde :
To embed an external app window in FreeCAD, see: