I have the following skeleton code:

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QToolTip, QMainWindow, QTextEdit
from PyQt5.QtGui import QIcon, QFont
from PyQt5.QtCore import Qt


class Editor(QMainWindow):

    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.initUI()

    # --------------------------------------

    def initMenubar(self):

      menubar = self.menuBar()

      fileMenuBtn = menubar.addMenu("File")
      editMenuBtn = menubar.addMenu("Edit")
      viewMenuBtn = menubar.addMenu("View")

    # --------------------------------------    
    def initToolbars(self):

      self.toolbar = self.addToolBar("Options")
      # Makes the next toolbar appear underneath this one
      self.addToolBarBreak()
      self.formatbar = self.addToolBar("Format")        

    # --------------------------------------        
    def initUI(self):
        QToolTip.setFont(QFont('Monospace', 10))

        self.setToolTip('<b>Proofor</b> main window')

        #self.text = QTextEdit(self)
        #self.setCentralWidget(self.text)


        # Initialize a statusbar for the window
        self.statusbar = self.statusBar()

        self.initToolbars()
        self.initMenubar()

        self.setWindowTitle('Proofor - proof editor')
        #self.setWindowIcon(QIcon('dots.png'))

        #self.setGeometry(100, 100, 500, 500)

# ================================================

def main():

    app = QApplication(sys.argv)
    main = Editor()
    main.show()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

If run this code as is (python editor.py), then everything works okay. However, if I un-comment the lines that add a QTextEdit widget, in initUI, I get the following warnings appearing:

(python:1949): Gtk-CRITICAL **: IA__gtk_widget_style_get: assertion 'GTK_IS_WIDGET (widget)' failed
QWidget::setMinimumSize: (/Editor) The largest allowed size is (16777215,16777215)

The window that would otherwise pop-up doesn't, but I can still close up the application. Instead, if in main I have main.showMaximized() rather than main.show(), I cause my computer to crash. This does not happen if I don't have a QTextEdit widget set as the central widget, since otherwise, a normal, maximized window appears.

Any ideas regarding what's happening?


edit for posterity: issue was occurring within my Anaconda Python distribution, I had installed pyqt5 which was conflicting with the native pyqt4.

share|improve this question
up vote 1 down vote accepted

Under python 3.4, pyqt5, ubuntu 14.04 lts your code works well. It seems to be a problem of the default style on your installation

try to change the style by running your code with e.g.

python editor.py -style windows

see Qt-Docs QStyle

you can find the available styles by

print(QStyleFactory.keys())

after importing QStyleFactory from QtWidgets

share|improve this answer
    
Thanks for this answer. I have two questions for you: 1) do you get the following warnings when running the code and 2) why does your answer work (I tried it, and it does work -- I am on Ubuntu 15.10) – user89 Dec 13 '15 at 20:02
    
Worth noting that out of the styles I have available (windows, fusion, and gtk+), it is the gtk+ one that causes my computer to completely crash! – user89 Dec 13 '15 at 20:14
    
i had the error message with my own app under ubuntu 13.xx and found the solution (setting another style) by duckduckgo. since ubuntu 14.04 my app runs without this error. your code doesn't show any error message even if i run it with -style gtk+ – a_manthey_67 Dec 13 '15 at 20:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.