python - PyQT Qtabwidget hide and close certain tab -


is possible hide , close tab in qtabwidget? have 5 tabs, 2 of them plots , generated while using software. first want hide 2 plots in beginning , second want make them closable after there generated. possible? self.settabsclosable(true) tabs closable.

thanks

import sys pyqt4 import qtgui  class qcustomtabwidget (qtgui.qtabwidget):     def __init__ (self, parent = none):         super(qcustomtabwidget, self).__init__(parent)         self.settabsclosable(true)         self.tabcloserequested.connect(self.closetab)         in range(1, 10):             self.addtab(qtgui.qwidget(), 'tab %d' % i)      def closetab (self, currentindex):         currentqwidget = self.widget(currentindex)         currentqwidget.deletelater()         self.removetab(currentindex)  myqapplication = qtgui.qapplication([]) myqcustomtabwidget = qcustomtabwidget() myqcustomtabwidget.show() sys.exit(myqapplication.exec_()) 

you can remove close button of tabs should not closed. done function settabbutton of qtabbar, this:

qtgui.qtabwidget.tabbar().settabbutton(0, qtgui.qtabbar.rightside,none) 

here, set button of first tab none.

with same function, create own close button on tab (and remove self.settabsclosable(true))


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -