Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
self.object
#1
Hi guys, i need to ask.
https://github.com/nengkya/PyQt/blob/mas...ainForm.py
Line 21 and below. Why :
self.layout = QGridLayout()
and
layout = QGridLayout()
give the same result ?
Reply
#2
One sets it to be a class attribute, the other doesn't. As self.layout is not used in any other functions or referenced anywhere else, and setLayout was already called using it, it doesn't make a difference.

If there is no need to use it elsewhere however it shouldn't be a class attribute.
Reply
#3
(Jan-28-2018, 06:20 PM)Mekire Wrote: If there is no need to use it elsewhere however it shouldn't be a class attribute
Sometimes it is necessary to keep a reference to an object, even if it is not used elsewhere. I don't know if this is the case here, but in python an instance exists only when there is at least one reference to this instance.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020