I've got the code below, and I was planning on making several classes all within the same "import". I was hoping to instantiate each class and get a return value with the widgets I'm making.
This isn't really a PyQt question at all, more of a "good practices" question, as I'll have a class for each widget.
Should I make functions that return the widgets that were created, if so how? How do I ensure it is difficult to directly instantiate the class if that is the best method for what I'm after?
I'd like to be able to do something like ....
tabs = wqTabWidget( ['firstTab', 'Second', 'Last Tab'] )
or (which ever is a better practice)
tabs = wqInstance.createTabs( ['firstTab', 'Second', 'Last Tab'] )
Here's my class so far....
from PyQt4 import QtCore as qc
from PyQt4 import QtGui as qg
class wqTabWidget(qg.QTabWidget):
def __init__(self, *args):
apply(qg.QTabWidget.__init__,(self, ))
tabList = []
tabNames = args[0]
for name in tabNames:
tabWidget = qg.QWidget()
self.addTab(tabWidget, name)
tabList.append( { name:tabWidget } )
print 'hi'
if __name__ == '__main__':
app = qg.QApplication(sys.argv)
window = wqTabWidget(['hi', 'there', 'and', 'stuff'])
window.show()
app.exec_()