Monday, April 14, 2014

PyQt addToolBarBreak () - Create Two Toolbars

We can use addToolBarBreak () to create two toolbars. One is followed by another with a line break. Here is an example of PyQt.

import sys
from PyQt4 import QtGui

class MyMainWindow (QtGui.QMainWindow):
   
    def __init__ (self):
        super (MyMainWindow, self).__init__ ()
       
        Toolbar1 = self.addToolBar ("")
        self.addToolBarBreak ()
        Toolbar2 = self.addToolBar ("")
       
        Cb = QtGui.QComboBox ()
        Toolbar1.addWidget (Cb)
        Cb = QtGui.QComboBox ()
        Toolbar1.addWidget (Cb)

        Cb = QtGui.QComboBox ()
        Toolbar2.addWidget (Cb)
        Cb = QtGui.QComboBox ()
        Toolbar2.addWidget (Cb)
       
        self.setGeometry (300, 300, 300, 200)
        self.setWindowTitle ('Multiple Toolbars')
        self.show ()
       
def main():
    App = QtGui.QApplication (sys.argv)
    MainWindow = MyMainWindow ()
    sys.exit (App.exec_ ())

if __name__ == '__main__':
    main()



We can also use addToolBarBreak () to create multiple toolbars.

No comments:

Post a Comment