Hide critical pyqt warning when checkboc is clicked

I am developing a GUI using PyQt4 on a Linux Ubuntu machine (XFCE desktop environment). I am using Python 2.7.

Everything works fine, except that when I click the checkbox, this message is displayed in the console (even this doesn't affect the GUI execution):

(python:9482): Gtk-CRITICAL **: IA__gtk_widget_get_direction: assertion 'GTK_IS_WIDGET (widget)' failed

Here's a piece of code that displays a list of checkboxes:

def SFCheckList(self):
    groupBox = QtGui.QGroupBox("SF Functions List")
    self.grid = QtGui.QGridLayout()
    self.checkBoxList = [[], []]

    #Reading supported SF functions
    try:
        sql = "SELECT SF FROM Locators"
        cursor.execute(sql)
        results = cursor.fetchall()
    except:
        print "Error: unable to fecth data (SF Functions)"


    #Building the Checkbox List
    for SF in results:
        self.checkBoxList[0].append(QtGui.QCheckBox(SF[0])) 
        self.checkBoxList[1].append(SF[0])

    self.SFCheckListDisplay()
    groupBox.setLayout(self.grid)

    return groupBox

def SFCheckListDisplay(self):
    l = sqrt(len(self.checkBoxList[0]))
    if(l!=int(l)):
        l= int(l) + 1

    i=0
    j=0
    for cb in self.checkBoxList[0]:
        self.grid.addWidget(cb, i, j)
        j+=1
        if(j==l):
            i+=1
            j=0

      

I am using the console to get information about tests. How can I prevent this message from appearing?

Thank!

+3


source to share


1 answer


I had a similar problem with the following code on Windows 7, PyQt5:

import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

class Window(QWidget):
    def __init__(self, *args, **kwargs):
        QWidget.__init__(self, *args, **kwargs)
        self.stderr_backup = None

        self.label = QLabel("Test", self)

        self.layout = QHBoxLayout()
        self.layout.addWidget(self.label)

        self.setLayout(self.layout)

        self.show()

app = QApplication(sys.argv)
win = Window()
sys.exit(app.exec_())

      

The error message from Qt was as follows, but the application still worked correctly.

QWindowsWindow::setGeometry: Unable to set geometry 42x35+520+270 on QWidgetWindow/'WindowClassWindow'. Resulting geometry:  112x35+520+270 (frame: 8, 29, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 42x35, maximum size: 16777215x16777215).

      



I was able to disable the message using:

def handler(msg_type, msg_log_context, msg_string):
    pass

PyQt5.QtCore.qInstallMessageHandler(handler)

      

However, I'm not sure if this will work on PyQt4 in your case as well.

+2


source







All Articles