[PyQt] removeWidget

uahmed gleam.uahmed at gmail.com
Thu Aug 25 06:59:02 BST 2011


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_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110825/0180c3d8/attachment.html>


More information about the PyQt mailing list