<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Le 25/08/11 07:59, uahmed a écrit :
    <blockquote
cite="mid:CAEUvQQzxtM1gBzyabpgj-Bzx=5e45GBU3jX0gQpZ_SKWwLbBjg@mail.gmail.com"
      type="cite">Hi <br>
      <br>
      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 ?<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>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
PyQt mailing list    <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></pre>
    </blockquote>
    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 class="moz-signature">-- <br>
      Vincent V.V.<br>
      <a href="https://launchpad.net/oqapy">Oqapy</a> . <a
        href="https://launchpad.net/qarte+7">Qarte+7</a> . <a
        href="https://launchpad.net/paqager">PaQager</a></div>
  </body>
</html>