Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Hans-Peter Jansen Newsgroups: de.comp.lang.python Subject: =?utf-8?q?=5BPython-de=5D_Re=3A_When_should_I_use_=22parent=3DNone=22_in_=5F=5Fini=5F=5F_and?= Date: Fri, 08 Oct 2021 18:05:58 +0200 Lines: 62 Message-ID: <10908767.Al5bunHUc5@xrated> References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de KAHB0Q7qrchCAH+LCkLf6AtGFnnin8Ei0i1xE+csWgrQ== Authentication-Results: mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Virus-Scanned: amavisd at 'smile.earth' In-Reply-To: X-Provags-ID: V03:K1:jcfHRSyFzmHh22vCYu6bLhvdnSCAJ6Owm541RI9/wvfxsibP3Ml 5VFH1BC5sFcfB/2gPqDU/B4m94dPHehbbuwENmuiZsCmVCP0Kett8O26StwMBMmC3IT2Npg 4y34DIuJdmfcUBSOFIpjIaRhrhkeVrqhesOSFgU7jAnGB6XAW3NVsPqaIheRV6wljvf/7U4 zFSrSgPwq/ZaYjHmrBDZA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:ZCncqnhU6Nw=:2AANdVBfMyg5TKfJMSIHP4 onvpacWyQ//cQQDZloTWVCQO0P5+R3G8pk061xsW9cr8LzVPADQ9KF/yUiWpd366KgpI1q3Z6 gTUFE56lQG5sQ8N0Rb+1qPIXf0MvTI+DzVXzXohEewXnxy3xdR4sznn+kxAD6r8CRkhYvQQ05 J6MJog1GjoDvqYu0zyNSZvAJxKhT+PYXUNkv9u0fdiLrdfUPzinN/1mZCFEZk6KDu7gAvr6cQ 6iqnNnhqJdFdZzBATYauCVvkv0DhOxdonX38g6xdQuN9lnrqP7ji4kSmUjW0cjOw/Q57Brl4R /dxBl/MSRtBQR5Nm/94gkej17JpVwpeElA9dngNei9Ar5Xt+Mvubcxoqo1wEwsazgqP0KLySG jkeQTmJMbmmg8IaaQilRTbrwSOJpGXRsXYWzZXrm44g7f6eeZokY4c8HcikRJ50QnqGvzh63u kjrPu8gpOwfrUaC18FiHN33t/fSwxwL6cI+VTp+mk2QbDYQgTvdfkcFBF2OMbhW/ver2Uu9v8 TpP4JdGY3nXcuYqT9eYDRiOGaVSxwNV5SnWWEjR62Eg4xhmFpPgnEiulUmbvOzKwdKNtXaTdO pSbdJ7xKyPCtu44+BS9LoaWMgtGvthIr7BQ8jc/hUEdNJ0jNzDvB7mYg+7fFJqAesoT1y1fvp CfuL2wi6FzDxqbMF+LxSTuvQJfJO4EFdetScveMVExy9HZMa5Hb5e/4aJbnjDLcMRkTg41wLf zKZIBl4Io0vZJcPtPiNdHHxbVzsOZoYZ8s53KA== Message-ID-Hash: YRIUBLDQDQONG2MQ7HZUSFL2PIJ7QVDA X-Message-ID-Hash: YRIUBLDQDQONG2MQ7HZUSFL2PIJ7QVDA X-MailFrom: hpj@urpla.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-python-de.python.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.5 Precedence: list List-Id: Die Deutsche Python Mailingliste Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Xref: csiph.com de.comp.lang.python:5743 Mohsen, in deutschen Usergruppen solltest du dir die Arbeit machenm, auch deutsch z= u=20 schreiben. Die Antwort auf diese Frage habe ich dir schon in der vorherigen Mail gegeb= en. Cheers, Pete Am Freitag, 8. Oktober 2021, 12:17:15 CEST schrieb Mohsen Owzar: > When should I use "parent=3DNone" in __ini__ and "parent" in super() > Hi Guys > I've sent this question to other Python community but didn't get any answ= er. > I hope that here I can get an explanation of how to use parent in the > Python OOP. >=20 > I'm writing since almost one-year codes in Python, using TKinter and PyQt= 5. > I'm somehow able to writes GUIs in both of them. >=20 > But since I'm using more Pyqt5 and using classes with initialization and > super() constructs, and also I saw lots of videos and examples of coding > them, I still don=E2=80=99t know exactly how and when should I use the pa= rent in > __init()__ and super() construct. >=20 > For example, the following lines use "parent=3DNone" in the __init__ cons= truct > and "parent" in the super() construct. And sometimes I do not see any of > them in these two constructs. >=20 > class MyClass1(QWidget): > def __init__(self, name, parent=3DNone): > super(MyClass1, self).__init__(parent) > print(self.parent().test) >=20 > And sometimes without "parent" like the following: >=20 > class MyClass2(QWidget): > def __init__(self, name): > super(MyClass2, self).__init__() > print(self.parent().test) >=20 > Could anyone explain this to me when and for which action I have to use t= he > first one "MyClass1" and when the second one "MyClass2"? >=20 > Mohsen > _______________________________________________ > python-de Mailingliste -- python-de@python.org > Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an > python-de-leave@python.org > https://mail.python.org/mailman3/lists/python-de.python.org/ > Mitgliedsadresse: hpj@urpla.net