[PyQt] When to and not to pass parent argument to widget constructors
rj_pyqt_qwzqfors at objectmail.com
Tue Apr 22 15:43:32 BST 2014
I am learning PyQt in order to rewrite my wxPython application to
use it. Having been accustomed to using wxPython, I am used to being
required to pass a parent as an argument to the constructor of every
non-top-level widget. But in PyQt, the parent argument is often
optional, and I am having some difficulty to know when I should and
shouldn't use it.
From what I have learned so far, I was guessing that perhaps the
parent argument should not be used in cases where the parent of the
widget will later be specified by calling a function (such as
QStatusBar.addPermanentWidget, QToolBar.addWidget, ,
QTabWidget.addTab, etc.), but should be used in all other cases. Is
this correct? Could someone please help clarify this?
Also, which is the more acceptable practice:
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import QAction,
(I know that generally the use of wild imports is discouraged in
Python, but it's much easier than having to add a widget to the
import list whenever I use another one.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt