[SOLVED]how to set the Combo View to "Model" from Python
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[SOLVED]how to set the Combo View to "Model" from Python
hello
I am trying to find out how to set the Combo View to "Model" from Python.
The only code I can find for this is the code listed for "Adding a Tab to the Combo View" on the page "Code Snippets"(http://www.freecadweb.org/wiki/index.ph ... Combo_View). Unfortunately I do not have the PyQt4 library on my version of FreeCAD and so this code will not run.
thanks
Dean
OS: Mac OS X
Word size: 64-bit
Version: 0.14.3703 (Git)
Branch: releases/FreeCAD-0-14
Hash: c6edd47334a3e6f209e493773093db2b9b4f0e40
Python version: 2.7.5
Qt version: 4.8.6
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0
I am trying to find out how to set the Combo View to "Model" from Python.
The only code I can find for this is the code listed for "Adding a Tab to the Combo View" on the page "Code Snippets"(http://www.freecadweb.org/wiki/index.ph ... Combo_View). Unfortunately I do not have the PyQt4 library on my version of FreeCAD and so this code will not run.
thanks
Dean
OS: Mac OS X
Word size: 64-bit
Version: 0.14.3703 (Git)
Branch: releases/FreeCAD-0-14
Hash: c6edd47334a3e6f209e493773093db2b9b4f0e40
Python version: 2.7.5
Qt version: 4.8.6
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0
Last edited by piffpoof on Wed Dec 24, 2014 6:46 am, edited 1 time in total.
Re: how to set the Combo View to "Model" from Python
Code: Select all
from PySide import QtCore, QtGui
mw=Gui.getMainWindow()
dw=mw.findChildren(QtGui.QDockWidget)
for i in dw:
if i.objectName() == "Combo View":
tab = i.findChild(QtGui.QTabWidget)
break
tab.setCurrentIndex(1)
Re: how to set the Combo View to "Model" from Python
thank you,wmayer wrote:Code: Select all
from PySide import QtCore, QtGui mw=Gui.getMainWindow() dw=mw.findChildren(QtGui.QDockWidget) for i in dw: if i.objectName() == "Combo View": tab = i.findChild(QtGui.QTabWidget) break tab.setCurrentIndex(1)
one small point, I think the last line of code should read
Code: Select all
tab.setCurrentIndex(0)
Dean
Re: how to set the Combo View to "Model" from Python
yes.one small point, I think the last line of code should read
Re: how to set the Combo View to "Model" from Python
hi
from PySide "Adding a Tab to the Combo View"
mario
from PySide "Adding a Tab to the Combo View"
Code: Select all
# create new Tab in ComboView
from PySide import QtGui,QtCore
from PySide import QtGui,QtCore
#from PySide import uic
def getMainWindow():
"returns the main window"
# using QtGui.qApp.activeWindow() isn't very reliable because if another
# widget than the mainwindow is active (e.g. a dialog) the wrong widget is
# returned
toplevel = QtGui.qApp.topLevelWidgets()
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
def getComboView(mw):
dw=mw.findChildren(QtGui.QDockWidget)
for i in dw:
if str(i.objectName()) == "Combo View":
return i.findChild(QtGui.QTabWidget)
elif str(i.objectName()) == "Python Console":
return i.findChild(QtGui.QTabWidget)
raise Exception ("No tab widget found")
mw = getMainWindow()
tab = getComboView(getMainWindow())
tab2=QtGui.QDialog()
tab.addTab(tab2,"A Special Tab")
#uic.loadUi("/myTaskPanelforTabs.ui",tab2)
tab2.show()
#tab.removeTab(2)
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: how to set the Combo View to "Model" from Python
Hi Wmayerwmayer wrote: ↑Sat Dec 13, 2014 9:03 pmCode: Select all
from PySide import QtCore, QtGui mw=Gui.getMainWindow() dw=mw.findChildren(QtGui.QDockWidget) for i in dw: if i.objectName() == "Combo View": tab = i.findChild(QtGui.QTabWidget) break tab.setCurrentIndex(1)
I'm wondering if we could close combo view from Python.
Best Regards,
Mea08kw
Re: how to set the Combo View to "Model" from Python
Last post has been solved by executing i.close().mea08kw wrote: ↑Tue Feb 07, 2023 2:51 amHi Wmayerwmayer wrote: ↑Sat Dec 13, 2014 9:03 pmCode: Select all
from PySide import QtCore, QtGui mw=Gui.getMainWindow() dw=mw.findChildren(QtGui.QDockWidget) for i in dw: if i.objectName() == "Combo View": tab = i.findChild(QtGui.QTabWidget) break tab.setCurrentIndex(1)
I'm wondering if we could close combo view from Python.
Best Regards,
Mea08kw
One more question: as FreeCAD's Task system will automatically add OK/Cancel buttons, I'm wondering how to remove those two buttons or edit the signal slot in those two buttons?
Re: [SOLVED]how to set the Combo View to "Model" from Python
You cannot modify the existing signal/slot connections. What you can do is to hide the buttons withOne more question: as FreeCAD's Task system will automatically add OK/Cancel buttons, I'm wondering how to remove those two buttons or edit the signal slot in those two buttons?
Code: Select all
from PySide import QtWidgets
mw = Gui.getMainWindow()
box = mw.findChild(QtWidgets.QDialogButtonBox)
for btn in box.buttons():
btn.hide()
Re: [SOLVED]how to set the Combo View to "Model" from Python
Thanks for your code.wmayer wrote: ↑Tue Feb 07, 2023 10:53 amYou cannot modify the existing signal/slot connections. What you can do is to hide the buttons withOne more question: as FreeCAD's Task system will automatically add OK/Cancel buttons, I'm wondering how to remove those two buttons or edit the signal slot in those two buttons?Code: Select all
from PySide import QtWidgets mw = Gui.getMainWindow() box = mw.findChild(QtWidgets.QDialogButtonBox) for btn in box.buttons(): btn.hide()
In the meantime, I found we could edit the connections by def accept(self) and def reject(self)
Re: [SOLVED]how to set the Combo View to "Model" from Python
In addition, I'm wondering if "Model" tab and "Tasks" tab can be hidden in combo view. If it can be only deleted, will the document or object items be deleted also?