Active Topics

 


Reply
Thread Tools
Posts: 113 | Thanked: 13 times | Joined on Nov 2008 @ Darmstadt, Germany
#21
I just started developing with Python and PyGTK (and GTK as a whole) a week ago. I've been working with Qt some years ago and dont remember having so many problems with certain aspects, so i think i will switch to PyQt. And the purchase of Trolltech/QtSoftware seems to hint at the possibility that OS2009 (if there will be one) will get some serious Qt-loving....

@Nyrath:
The flickr-pics only show the application in windowed mode. Do you know if there's support for the hardware keys and fullscreen integrated?
 
Posts: 113 | Thanked: 13 times | Joined on Nov 2008 @ Darmstadt, Germany
#22
Ok, now I've got a serious problem. Whats wrong with the following code?

Code:
import sys
from PyQt4 import QtCore, QtGui
      
class SlmListView( QtGui.QWidget ):
    def __init( self, parent = None, core = None ):
        QtGui.QWidget.__init__( self, parent )  
        self.myLayout = QtGui.QVBoxLayout()
        self.setLayout( self.myLayout )
        
    def populate( self ):
        for i in [1, 2, 3]:
            self.myLayout.addWidget( QtGui.QPushButton( str( i ) ) )
            
           
class SlmMainView( QtGui.QMainWindow ):
    def __init__( self, parent = None ):
        QtGui.QWidget.__init__( self, parent )
        
        self.slmListView = SlmListView() 
        self.slmListView.populate()
        self.setCentralWidget( self.slmListView )


if __name__ == "__main__":
    app = QtGui.QApplication( sys.argv )
    slmMainView = SlmMainView()
    slmMainView.show()
    sys.exit( app.exec_() )

When executing it i always get the following message:
Code:
C:\develop\Python>python app.py
Traceback (most recent call last):
  File "app.py", line 26, in <module>
    slmMainView = SlmMainView()
  File "app.py", line 20, in __init__
    self.slmListView.populate()
  File "app.py", line 12, in populate
    self.myLayout.addWidget( QtGui.QPushButton( str( i ) ) )
AttributeError: myLayout
Help?
 
Nyrath's Avatar
Posts: 92 | Thanked: 50 times | Joined on Jan 2006 @ the praeternatural tower
#23
Let me do a quick check. I should be able to figure out your problem when I get back to my main computer.
 
Nyrath's Avatar
Posts: 92 | Thanked: 50 times | Joined on Jan 2006 @ the praeternatural tower
#24
In line five you have the following:
Code:
def __init( self, parent = None, core = None ):
You forgot the two trailing underscores after "init". It should be:
Code:
def __init__( self, parent = None, core = None ):
When you add them, the program displays a window with three buttons stacked vertically.

The error message was "AttributeError". It says that it could not find the attribute "myLayout" in the SlmListView. What happened was that the __init creator never got called, because it has the wrong name. So the myLayout never got created. So it could not be found.

How did I find the error? I figured there was something wrong with the myLayout. So I put in lines "print myLayout" when it was created and before it was used in populate(). The print in the constructor never happened. That's when I realize the constructor was never being called. And that led me to discover that it was mis-named.

Last edited by Nyrath; 2008-11-22 at 01:52.
 

The Following 2 Users Say Thank You to Nyrath For This Useful Post:
Posts: 113 | Thanked: 13 times | Joined on Nov 2008 @ Darmstadt, Germany
#25
Wow, thanks, you're a genius! I had nearly given up on it. Forgetting stuff like underscores, dots, commas etc) is typical for me *g* Thank you!
 
Nyrath's Avatar
Posts: 92 | Thanked: 50 times | Joined on Jan 2006 @ the praeternatural tower
#26
Glad I could help.
 
Posts: 46 | Thanked: 0 times | Joined on Dec 2008 @ Grenoble (France)
#27
I'm currently developping a panohead driving application in PyGTK, and start to have serious troubles (I got some seg. fault on some OS, not on others...). That's a long time I plan to switch to PyQt, as I also use it in my every-day job.

The question is: is it planned to have a PyQt version for OS2007? Some users of my app. are running it on 770s, and I don't want them to be excluded from futur devs...
 
MountainX's Avatar
Posts: 415 | Thanked: 193 times | Joined on Jun 2009 @ A place with no mountains
#28
Originally Posted by fpp View Post
I downloaded an old favourite of mine, Treeline...
It ran without problems
Great news for me because I want to run Treeline too. Being a newbie to the n810, I would love to see a step-by-step guide to getting Treeline to run. (I do not have PyQt or any related packages installed yet.)
 
Posts: 6 | Thanked: 0 times | Joined on Aug 2009
#29
I try PyQt for Diablo and get segmentation fault
Should PyQt works in scratchbox?
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#30
PyQt most certainly works on Diablo. Can you post some code that demostrates the crash ? Most of the time segfaults happen when objects get destructed 'behind' PyQt's back and then you try to reference them.
 
Reply

Tags
pyqt, python


 
Forum Jump


All times are GMT. The time now is 23:41.