[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Idea: Show QObject.objectName() in __repr__
From:       Florian Bruhin <me () the-compiler ! org>
Date:       2014-06-17 9:24:20
Message-ID: 20140617092420.GA24492 () lupin
[Download RAW message or body]

This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

[Attachment #2 (multipart/signed)]
This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.


I noticed the __repr__ of Qt objects is usually just python's default,
which isn't too useful.

Then I had an idea: What about showing the objectName in __repr__ for
all QObjects as default in PyQt? So basically having something like
this as __repr__:

    def __repr__(self):
        name = self.objectName()
        if name:
            return '<{} named {}>'.format(self.__class__.__name__, name)
        else:
            return '<{}>'.format(self.__class__.__name__)

Florian

-- 
http://www.the-compiler.org | me@the-compiler.org (Mail/XMPP)
             GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/

[Attachment #5 (application/pgp-signature)]
[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic