[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Removing a Layout
From:       Samuel GARCIA <sgarcia () olfac ! univ-lyon1 ! fr>
Date:       2008-09-24 9:15:55
Message-ID: 48DA054B.4070900 () olfac ! univ-lyon1 ! fr
[Download RAW message or body]

Hi list,
I have a problem with PyQT.
I am a little lost with something I don't understand.

I try to remove a QVBoxLayout containing other widget.
I have a list of theses QVBoxLayout contained in a scrollArea.

When I want to delete one, all dessapear !

The short code is easier to understand my problem.

If someone could look at it and give THE advice, I could save precious time.

Tanhks a lot

Samuel





-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Samuel Garcia
Laboratoire de Neurosciences Sensorielles, Comportement, Cognition.
CNRS - UMR5020 - Universite Claude Bernard LYON 1
Equipe logistique et technique
50, avenue Tony Garnier
69366 LYON Cedex 07
FRANCE
Tél : 04 37 28 74 64
Fax : 04 37 28 76 01
http://olfac.univ-lyon1.fr/unite/equipe-07/
http://neuralensemble.org/trac/OpenElectrophy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


["test_remove_layout.py" (text/x-python)]

# -*- coding: utf-8 -*-

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys


class MainWin(QWidget) :
	def __init__(self, parent = None) :
		QWidget.__init__(self, parent)
		
		mainlayout = QVBoxLayout()
		but = QPushButton('Add')
		mainlayout.addWidget(but)
		self.connect(but,SIGNAL('clicked()'),self.addVBox)
		
		w = QWidget()
		self.vboxScroll = QVBoxLayout()
		w.setLayout(self.vboxScroll)
		scroll = QScrollArea()
		scroll.setWidget(w)
		scroll.setWidgetResizable(True)
		mainlayout.addWidget(scroll)
		
		self.setLayout(mainlayout)
	
	def addVBox(self):
		h = QHBoxLayout()
		h.addWidget(QLabel('label1'))
		h.addWidget(QLabel('label2'))
		
		but = QPushButton('del')
		h.addWidget(but)
		self.connect( but, SIGNAL('clicked()'), self.delHBox )
		
		self.vboxScroll.addLayout(h)
	
	def delHBox(self):
		self.sender().parent().setVisible(False)
		self.vboxScroll.removeWidget(self.sender().parent())
		

if __name__ == '__main__':
	app = QApplication(sys.argv)
	mainwin = MainWin()
	mainwin.show()
	app.exec_()
	
	
	

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic