[PyQt] removeWidget
uahmed
gleam.uahmed at gmail.com
Thu Aug 25 10:39:46 BST 2011
Hi
Thanks for the reply , I used .close() . I guess this will destroy the
widget and will not leave memory for it .
On Thu, Aug 25, 2011 at 2:22 PM, Hans-Peter Jansen <hpj at urpla.net> wrote:
> On Thursday 25 August 2011, 10:43:20 Vincent Vande Vyvre wrote:
> > Le 25/08/11 07:59, uahmed a écrit :
> > Hi
> >
> > I want to add widget in (f1) function and want to remove the widget
> > from (f2) function . I tried the same thing in same function it do
> > work but when i try to remove the widget from another it doesnt . Any
> > help ?
> >
> > Code :
> >
> >
> > import sys,os
> > from functools import partial
> > from PyQt4 import QtGui, QtCore
> > import Skype4Py
> > import time
> > import socket
> >
> >
> > class main():
> > def f1(self):
> > print "f1"
> > buttons['user'] = QtGui.QToolButton(widget)
> > layout.addWidget(buttons['user'])
> > widget.setLayout(layout)
> > def f2(self):
> > print "f2"
> > layout.removeWidget(buttons['user'])
> > widget.setLayout(layout)
> >
> >
> > app = QtGui.QApplication(sys.argv)
> > widget = QtGui.QWidget()
> > layout = QtGui.QVBoxLayout()
> > buttons = {}
> > sk = main()
> > sk.f1()
> > sk.f2()
> > widget.show()
> > sys.exit(app.exec_())
> >
> >
> > _______________________________________________
> > PyQt mailing list PyQt at riverbankcomputing.com
> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> > Remove is NOT delete.
> >
> > Try that:
> >
> > def f2(self):
> > print "f2"
> > buttons['user'].deleteLater()
> > layout.removeWidget(buttons['user'])
> > widget.setLayout(layout)
>
> Consider using .show() and .hide()
>
> Pete
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110825/79ae1e8b/attachment.html>
More information about the PyQt
mailing list