Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt4 import QtGui,QtCore
- #from PySide import QtGui,QtCore
- import FreeCAD
- 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)
- raise Exception("No tab widget found")
- class test(object):
- def setupUi(self,object):
- self.pushButton = QtGui.QPushButton(object)
- self.pushButton.setText("The Button")
- self.pushButton.show()
- QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.make_it_happen)
- def make_it_happen(self):
- FreeCAD.Console.PrintMessage('You pressed the button!\n')
- def kill_the_button(self):
- self.pushButton.hide()
- mw = getMainWindow()
- tab = getComboView(getMainWindow())
- tab2 = QtGui.QTabWidget(parent = mw)
- tab.addTab(tab2,"A Special Tab")
- panel = test()
- panel.setupUi(tab2)
- #tab.removeTab(2) #remove tab2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement