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)

from PySide import QtGui
mw = FreeCADGui.getMainWindow()
dws = mw.findChildren(QtGui.QDockWidget)

# objectName may be :
# "Report view"
# "Tree view"
# "Property view"
# "Selection view"
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 3)
        spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem1, 3, 0, 1, 3)
        self.charging = QtGui.QCheckBox(BatteryPublisher)
        self.charging.setObjectName("charging")
        self.gridLayout.addWidget(self.charging, 2, 0, 1, 3)

        self.retranslateUi(BatteryPublisher)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), BatteryPublisher.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), BatteryPublisher.reject)
        QtCore.QMetaObject.connectSlotsByName(BatteryPublisher)

    def retranslateUi(self, BatteryPublisher):
        BatteryPublisher.setWindowTitle(QtGui.QApplication.translate("BatteryPublisher", "Battery Publisher", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setText(QtGui.QApplication.translate("BatteryPublisher", "Empty", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setText(QtGui.QApplication.translate("BatteryPublisher", "Full", None, QtGui.QApplication.UnicodeUTF8))
        self.charging.setText(QtGui.QApplication.translate("BatteryPublisher", "Charging", None, QtGui.QApplication.UnicodeUTF8))


if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    BatteryPublisher = QtGui.QDialog()
    ui = Ui_BatteryPublisher()
    ui.setupUi(BatteryPublisher)
    BatteryPublisher.show()
    sys.exit(app.exec_())