Hi <br><br>Thanks for the reply , I used .close() . I guess this will destroy the widget and will not leave memory for it . <br><br><div class="gmail_quote">On Thu, Aug 25, 2011 at 2:22 PM, Hans-Peter Jansen <span dir="ltr"><<a href="mailto:hpj@urpla.net">hpj@urpla.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">On Thursday 25 August 2011, 10:43:20 Vincent Vande Vyvre wrote:<br>
> Le 25/08/11 07:59, uahmed a écrit :<br>
> Hi<br>
><br>
> I want to add widget in (f1) function and want to remove the widget<br>
> from (f2) function . I tried the same thing in same function it do<br>
> work but when i try to remove the widget from another it doesnt . Any<br>
> help ?<br>
><br>
> Code :<br>
><br>
><br>
> import sys,os<br>
> from functools import partial<br>
> from PyQt4 import QtGui, QtCore<br>
> import Skype4Py<br>
> import time<br>
> import socket<br>
><br>
><br>
> class main():<br>
> def f1(self):<br>
> print "f1"<br>
> buttons['user'] = QtGui.QToolButton(widget)<br>
> layout.addWidget(buttons['user'])<br>
> widget.setLayout(layout)<br>
> def f2(self):<br>
> print "f2"<br>
> layout.removeWidget(buttons['user'])<br>
> widget.setLayout(layout)<br>
><br>
><br>
> app = QtGui.QApplication(sys.argv)<br>
> widget = QtGui.QWidget()<br>
> layout = QtGui.QVBoxLayout()<br>
> buttons = {}<br>
> sk = main()<br>
> sk.f1()<br>
> sk.f2()<br>
> widget.show()<br>
> sys.exit(app.exec_())<br>
><br>
><br>
> _______________________________________________<br>
> PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
> <a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
> Remove is NOT delete.<br>
><br>
> Try that:<br>
><br>
> def f2(self):<br>
> print "f2"<br>
> buttons['user'].deleteLater()<br>
> layout.removeWidget(buttons['user'])<br>
> widget.setLayout(layout)<br>
<br>
</div></div>Consider using .show() and .hide()<br>
<br>
Pete<br>
<div><div></div><div class="h5">_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></div></div></blockquote></div><br>