diff --git a/src/Gui/FreeCADGuiInit.py b/src/Gui/FreeCADGuiInit.py index 4fb68162baa9..e702ab32654d 100644 --- a/src/Gui/FreeCADGuiInit.py +++ b/src/Gui/FreeCADGuiInit.py @@ -127,6 +127,7 @@ def InitApplications(): # signal that the gui is up App.GuiUp = 1 App.Gui = FreeCADGui +FreeCADGui.Workbench = Workbench Gui.addWorkbench(NoneWorkbench()) diff --git a/src/Tools/embedded/PySide/mainwindow.py b/src/Tools/embedded/PySide/mainwindow.py new file mode 100644 index 000000000000..ea217fe174bf --- /dev/null +++ b/src/Tools/embedded/PySide/mainwindow.py @@ -0,0 +1,53 @@ +import sys +#sys.path.append("") + +from PySide import QtCore, QtGui +import FreeCAD, FreeCADGui + +from ui_mainwindow import Ui_MainWindow + +class MainWindow(QtGui.QMainWindow): + def __init__(self, parent = None): + super(MainWindow, self).__init__(parent) + from PySide import QtNetwork + # Webkit is used to create icons from SVG files. This could cause a deadlock + # when setting up the internally used network interface. Doing this before + # creating the icons fixes the issue. + QtNetwork.QNetworkConfigurationManager() + + def showEvent(self, event): + FreeCADGui.showMainWindow() + self.setCentralWidget(FreeCADGui.getMainWindow()) + # Need version >= 0.16.5949 + class BlankWorkbench(FreeCADGui.Workbench): + MenuText = "Blank" + ToolTip = "Blank workbench" + def Initialize(self): + return + def GetClassName(self): + return "Gui::BlankWorkbench" + FreeCADGui.addWorkbench(BlankWorkbench) + FreeCADGui.activateWorkbench("BlankWorkbench") + + @QtCore.Slot() + def on_actionEmbed_triggered(self): + return + + @QtCore.Slot() + def on_actionDocument_triggered(self): + FreeCAD.newDocument() + + @QtCore.Slot() + def on_actionCube_triggered(self): + FreeCAD.ActiveDocument.addObject("Part::Box") + FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.ActiveView.fitAll() + +app=QtGui.QApplication(sys.argv) +ui=Ui_MainWindow() +mw=MainWindow() +ui.setupUi(mw) +ui.actionEmbed.setVisible(False) +mw.resize(1200,800) +mw.show() +app.exec_() diff --git a/src/Tools/embedded/PySide/mainwindow.ui b/src/Tools/embedded/PySide/mainwindow.ui new file mode 100644 index 000000000000..3c51146ed3b9 --- /dev/null +++ b/src/Tools/embedded/PySide/mainwindow.ui @@ -0,0 +1,55 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 25 + + + + + FreeCAD + + + + + + + + + + + Embed + + + + + Document + + + + + Cube + + + + + + diff --git a/src/Tools/embedded/PySide/mainwindow2.py b/src/Tools/embedded/PySide/mainwindow2.py new file mode 100644 index 000000000000..62ea1bf5dcfd --- /dev/null +++ b/src/Tools/embedded/PySide/mainwindow2.py @@ -0,0 +1,35 @@ +import sys +#sys.path.append("") + +from PySide import QtCore, QtGui +import FreeCADGui + +class MainWindow(QtGui.QMainWindow): + def __init__(self, parent = None): + super(MainWindow, self).__init__(parent) + from PySide import QtNetwork + # Webkit is used to create icons from SVG files. This could cause a deadlock + # when setting up the internally used network interface. Doing this before + # creating the icons fixes the issue. + QtNetwork.QNetworkConfigurationManager() + + def showEvent(self, event): + FreeCADGui.showMainWindow() + self.setCentralWidget(FreeCADGui.getMainWindow()) + # Need version >= 0.16.5949 + class BlankWorkbench(FreeCADGui.Workbench): + MenuText = "Blank" + ToolTip = "Blank workbench" + def Initialize(self): + self.appendMenu("Menu",["Std_New", "Part_Box"]) + return + def GetClassName(self): + return "Gui::PythonBlankWorkbench" + FreeCADGui.addWorkbench(BlankWorkbench) + FreeCADGui.activateWorkbench("BlankWorkbench") + +app=QtGui.QApplication(sys.argv) +mw=MainWindow() +mw.resize(1200,800) +mw.show() +app.exec_() diff --git a/src/Tools/embedded/PySide/mainwindow3.py b/src/Tools/embedded/PySide/mainwindow3.py new file mode 100644 index 000000000000..c1f6f7fe813d --- /dev/null +++ b/src/Tools/embedded/PySide/mainwindow3.py @@ -0,0 +1,53 @@ +import sys +#sys.path.append("") + +from PySide import QtCore, QtGui +import FreeCAD, FreeCADGui +import ctypes + +from ui_mainwindow import Ui_MainWindow + +class MainWindow(QtGui.QMainWindow): + def __init__(self, parent = None): + super(MainWindow, self).__init__(parent) + from PySide import QtNetwork + # Webkit is used to create icons from SVG files. This could cause a deadlock + # when setting up the internally used network interface. Doing this before + # creating the icons fixes the issue. + QtNetwork.QNetworkConfigurationManager() + + @QtCore.Slot() + def on_actionEmbed_triggered(self): + FreeCADGui.showMainWindow() + hwnd=self.winId() + PyCObject_AsVoidPtr = ctypes.PYFUNCTYPE(ctypes.c_void_p, ctypes.py_object)(('PyCObject_AsVoidPtr', ctypes.pythonapi)) + addr = PyCObject_AsVoidPtr(hwnd) + FreeCADGui.embedToWindow(hex(addr)) + # Need version >= 0.16.5949 + class BlankWorkbench(FreeCADGui.Workbench): + MenuText = "Blank" + ToolTip = "Blank workbench" + def Initialize(self): + return + def GetClassName(self): + return "Gui::BlankWorkbench" + FreeCADGui.addWorkbench(BlankWorkbench) + FreeCADGui.activateWorkbench("BlankWorkbench") + + @QtCore.Slot() + def on_actionDocument_triggered(self): + FreeCAD.newDocument() + + @QtCore.Slot() + def on_actionCube_triggered(self): + FreeCAD.ActiveDocument.addObject("Part::Box") + FreeCAD.ActiveDocument.recompute() + FreeCADGui.ActiveDocument.ActiveView.fitAll() + +app=QtGui.QApplication(sys.argv) +ui=Ui_MainWindow() +mw=MainWindow() +ui.setupUi(mw) +mw.resize(1200,800) +mw.show() +app.exec_() diff --git a/src/Tools/embedded/PySide/ui_mainwindow.py b/src/Tools/embedded/PySide/ui_mainwindow.py new file mode 100644 index 000000000000..e0da9672bfd5 --- /dev/null +++ b/src/Tools/embedded/PySide/ui_mainwindow.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'mainwindow.ui' +# +# Created: Fri Nov 20 18:03:04 2015 +# by: pyside-uic 0.2.13 running on PySide 1.1.0 +# +# WARNING! All changes made in this file will be lost! + +from PySide import QtCore, QtGui + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(800, 600) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25)) + self.menubar.setObjectName("menubar") + self.menuFreeCAD = QtGui.QMenu(self.menubar) + self.menuFreeCAD.setObjectName("menuFreeCAD") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.actionEmbed = QtGui.QAction(MainWindow) + self.actionEmbed.setObjectName("actionEmbed") + self.actionDocument = QtGui.QAction(MainWindow) + self.actionDocument.setObjectName("actionDocument") + self.actionCube = QtGui.QAction(MainWindow) + self.actionCube.setObjectName("actionCube") + self.menuFreeCAD.addAction(self.actionEmbed) + self.menuFreeCAD.addAction(self.actionDocument) + self.menuFreeCAD.addAction(self.actionCube) + self.menubar.addAction(self.menuFreeCAD.menuAction()) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) + self.menuFreeCAD.setTitle(QtGui.QApplication.translate("MainWindow", "FreeCAD", None, QtGui.QApplication.UnicodeUTF8)) + self.actionEmbed.setText(QtGui.QApplication.translate("MainWindow", "Embed", None, QtGui.QApplication.UnicodeUTF8)) + self.actionDocument.setText(QtGui.QApplication.translate("MainWindow", "Document", None, QtGui.QApplication.UnicodeUTF8)) + self.actionCube.setText(QtGui.QApplication.translate("MainWindow", "Cube", None, QtGui.QApplication.UnicodeUTF8)) +