set parent to None in PySide

343 views
Skip to first unread message

Samuele Carcagno

unread,
Mar 24, 2014, 9:00:13 PM3/24/14
to julia...@googlegroups.com
another PySide.jl question, how to set the parent to None
after removing a widget? If I attempt it I get the following error:

julia> pw_prm_sizer_0[:removeWidget](wd["fieldLabel"][1])

julia> wd["fieldLabel"][1][:setParent](None)
ERROR: PyError (PyObject_Call) <type 'exceptions.TypeError'>
TypeError("'PySide.QtGui.QWidget.setParent' called with wrong argument
types:\n PySide.QtGui.QWidget.setParent(PyCall.jlwrap)\nSupported
signatures:\n PySide.QtGui.QWidget.setParent(PySide.QtGui.QWidget)\n
PySide.QtGui.QWidget.setParent(PySide.QtGui.QWidget,
PySide.QtCore.Qt.WindowFlags)",)

in pyerr_check at /home/sam/.julia/v0.3/PyCall/src/exception.jl:58
in pycall at /home/sam/.julia/v0.3/PyCall/src/PyCall.jl:85
in fn at /home/sam/.julia/v0.3/PyCall/src/conversions.jl:181

j verzani

unread,
Mar 24, 2014, 9:25:25 PM3/24/14
to julia...@googlegroups.com
I don't really know. This of course is an issue, as it likely won't get garbage collected once removed. I thought setting the parent to `nothing` would work, but it doesn't. If you find something that does work please let me know.

Samuele Carcagno

unread,
Mar 25, 2014, 7:01:54 AM3/25/14
to julia...@googlegroups.com
On 25/03/14 01:25, j verzani wrote:
> I don't really know. This of course is an issue, as it likely won't get
> garbage collected once removed. I thought setting the parent to
> `nothing` would work, but it doesn't. If you find something that does
> work please let me know.

thanks, setting the parent to `nothing' (as opposed to `None`) does seem
to work in the sense that I don't get an error message, and the GUI
seems to be behaving properly (no floating widgets or other issues so
far), although I don't know what's happening under the hood.

Sam

Steven G. Johnson

unread,
Mar 25, 2014, 5:12:30 PM3/25/14
to julia...@googlegroups.com
The analogue of Python's None in Julia is nothing (which will get converted to None on the Python side), whereas None in Julia is a completely different object (an empty type union, in fact).

So, try just passing nothing (without the quotes) instead of None.

Steven G. Johnson

unread,
Mar 25, 2014, 5:16:24 PM3/25/14
to julia...@googlegroups.com
On Tuesday, March 25, 2014 5:12:30 PM UTC-4, Steven G. Johnson wrote:
So, try just passing nothing instead of None.

Oh, nevermind, I see that you did that.

Regarding whether it is garbage-collected, you have to make sure that you aren't holding any references to the object.  (Once a Python object is garbage-collected on the Julia side, it releases the reference on the Python side as well.)

j verzani

unread,
Mar 25, 2014, 5:23:06 PM3/25/14
to julia...@googlegroups.com
Thanks for that clarification, wasn't sure exactly how that happened.
Reply all
Reply to author
Forward
0 new messages