LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-13-2015, 03:01 AM   #1
dr_berta
Member
 
Registered: Sep 2005
Location: Carpi (Modena) - Italy
Distribution: Ubuntu 20.04_x86_64 LTS; Slackware 13 64bit; Gentoo, Fedora, Yocto
Posts: 77

Rep: Reputation: 1
Python with qt GUI: recursion depth exceeded error with pushbutton


Hi all,
developping a small project with python and using Qt4 to get the main window form, I'm encountering the "recursion depth exceeded error" pressing a pushbutton.
As attachment you find the project code (please rename the files as .py).
The callback function generating the error is applyCbk()

I'm just a newbie with python and I don't understand where is the error.

Any suggestion?
Thanks
Attached Files
File Type: txt __init__ .txt (5.0 KB, 15 views)
File Type: txt gui.txt (18.7 KB, 15 views)
File Type: txt about .txt (4.0 KB, 13 views)

Last edited by dr_berta; 11-13-2015 at 03:13 AM.
 
Old 11-13-2015, 11:24 AM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
The problem is not with Python but with PyQt4. You have the pushButtons connected to themselves, hence the recursion error.

From gui.txt:
Code:
QtCore.QObject.connect(self.applyButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.applyButton.click)
QtCore.QObject.connect(self.startButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.startButton.click)
QtCore.QObject.connect(self.exportButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.exportButton.click)
You need to remove those connections in Qt Designer.

Here is a simple example reproducing the error:
Code:
#!/usr/bin/python3 

import sys
from PyQt4 import QtGui, QtCore

class mainWindow(QtGui.QMainWindow):
    def __init__(self, parent = None):
        super(mainWindow, self).__init__(parent)
        self.pushButton = QtGui.QPushButton("Push Me", self)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.pushButton.click)
        
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    win = mainWindow()
    win.show()
    app.exec_()

Last edited by norobro; 11-13-2015 at 02:05 PM. Reason: QAction connect statements are okay
 
Old 11-13-2015, 04:20 PM   #3
dr_berta
Member
 
Registered: Sep 2005
Location: Carpi (Modena) - Italy
Distribution: Ubuntu 20.04_x86_64 LTS; Slackware 13 64bit; Gentoo, Fedora, Yocto
Posts: 77

Original Poster
Rep: Reputation: 1
Thank you norobro.
I followed your suggestion and the code now works.

The only thing is that now I missed the button animation. How is it possible to restore it?

I did those connections only to have the animation, then I did another connection with the same signal to associate some actions with the button click
 
Old 11-13-2015, 04:32 PM   #4
dr_berta
Member
 
Registered: Sep 2005
Location: Carpi (Modena) - Italy
Distribution: Ubuntu 20.04_x86_64 LTS; Slackware 13 64bit; Gentoo, Fedora, Yocto
Posts: 77

Original Poster
Rep: Reputation: 1
I think I solved the animation problem.
Setting the autodefault property the button return to its original state.

Thank you for your help
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I got error while installing python-tk python-psycopg2 python-twisted saili kadam Linux - Newbie 1 09-05-2015 03:03 AM
recursion gui free software Leck Linux - Newbie 13 01-27-2015 07:26 PM
Apache2 recursion error in debian 4 twlilinux Linux - Server 1 06-20-2008 08:53 AM
tar: '--no-recursion' option doesn't prevent recursion Earl Parker II Slackware 12 08-17-2004 02:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration