[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyKDE] setText of all LineEdits with button click
From: Bill Burns <billburns () pennswoods ! net>
Date: 2004-09-25 16:57:29
Message-ID: 200409251301.29834.billburns () pennswoods ! net
[Download RAW message or body]
Torsten wrote:
> Try something like this (solution 1):
> <code>
> class MyLineEdit(QLineEdit):
> ~ # keeps track of all instances of MyLineEdit,
> ~ # but is buggy if instances are removed
> ~ allinstances = []
> ~ def __init__(self, parent):
> ~ self.allinstances.append(self)
> ~ QLineEdit.__init__(self, parent)
> ~ self.setText("hello")
>
> ~ def set(self, txt):
> ~ self.setText(txt)
>
> ~ def setAll(cls, x):
> ~ for le in cls.allinstances:
> ~ le.set(x)
>
> ~ setAll=classmethod(setAll)
> </code>
>
> and then
> <code>
> def setLineEdit(self):
> MyLineEdit.setAll("hi")
> </code>
>
>
> solution 2:
> <code>
> def setLineEdit(self):
> ~ for name in self.__dict__:
> ~ w = getattr(self, name)
> ~ if isinstance(w, MyLineEdit):
> ~ w.set("hi")
> </code>
>
> There are certainly some more solutions, maybe this helps you finding the
> best one.
>
> greetings
>
> Torsten
Torsten,
Thank you very much! I tried your solution 2 and it works great. I will also
take a look at solution 1.
Thank you Torsten and thank you Michael for your help!!
Bill
_______________________________________________
PyKDE mailing list PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic