Search code examples
pythonubuntuqt4pyqt4

PyQt4 menubar doesn't appear in Ubuntu


I am using python with Pyqt4 for building app on Ubuntu and seems I have trouble with menubar that doesn't show up, thanks for any help. here is the code:

import sys
from PyQt4 import QtGui
class Example(QtGui.QMainWindow):              
    def __init__(self):
         super(Example, self).__init__()        
         self.initUI()        
    def initUI(self):                      
         exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self)        
         exitAction.setShortcut('Ctrl+Q')
         exitAction.setStatusTip('Exit application')
         exitAction.triggered.connect(QtGui.qApp.quit)
         self.statusBar()
         menubar = self.menuBar()
         fileMenu = menubar.addMenu('&File')
         fileMenu.addAction(exitAction)        
         self.setGeometry(300, 300, 300, 200)
         self.setWindowTitle('Menubar')    
         self.show()       
def main():    
    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
if __name__ == '__main__':
     main()  

Excuse me if the indentation wouldn't be correct but I think it is.


Solution

  • In ubuntu menubar is outside the application . You can find it in global menu