On 10/6/07, <b class="gmail_sendername">Phil Thompson</b> <<a href="mailto:phil@riverbankcomputing.co.uk">phil@riverbankcomputing.co.uk</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Saturday 06 October 2007, Arve Knudsen wrote:<br>> On 10/6/07, Phil Thompson <<a href="mailto:phil@riverbankcomputing.co.uk">phil@riverbankcomputing.co.uk</a>> wrote:<br>> > On Saturday 06 October 2007, Arve Knudsen wrote:
<br>> > > On 10/6/07, Phil Thompson <<a href="mailto:phil@riverbankcomputing.co.uk">phil@riverbankcomputing.co.uk</a>> wrote:<br>> > > > On Friday 05 October 2007, Arve Knudsen wrote:<br>> > > > > Hi
<br>> > > > > I've just written a Designer plugin in Python, which I have to say<br>> ><br>> > is<br>> ><br>> > > > very<br>> > > ><br>> > > > > nice. However I discovered some surprising behaviour in pyuic. My
<br>> > > > > widget contains Qt properties (defined using pyqtProperty), but the<br>> > > > > generated<br>> > > ><br>> > > > code<br>> > > ><br>> > > > > don't use the properties, instead it tries to use the underlying
<br>> > > ><br>> > > > methods!?<br>> > > ><br>> > > > > I discovered this for the reason that I use a different naming<br>> > > ><br>> > > > convention
<br>> > > ><br>> > > > > than pyuic apparently expected. For instance, I had a property<br>> ><br>> > "value",<br>> ><br>> > > > for<br>> > > >
<br>> > > > > which pyuic expected there to be a setter method "setValue". I hope<br>> ><br>> > it<br>> ><br>> > > > > isn't on purpose that pyuic tries to use underlying methods instead
<br>> ><br>> > of<br>> ><br>> > > > the<br>> > > ><br>> > > > > properties themselves?<br>> > > > ><br>> > > > > I'm using PyQt 4.3
commercial edition.<br>> > > > ><br>> > > > > Thanks,<br>> > > > > Arve<br>> > > ><br>> > > > If everything is working as it should then it depends on what you
<br>> > > > have called<br>> > > > the setter. If it begins with "set" then pyuic (and uic) should use<br>> > > > it directly and not use setProperty(). However this has probably not
<br>> > > > had<br>> ><br>> > a<br>> ><br>> > > > lot<br>> > > > of testing.<br>> > > ><br>> > > > What have you called your setter?<br>> > >
<br>> > > Let's say the property is called "value". I called my setter<br>> > > _set_value, pyuic inferred the setter's name to be setValue.<br>> > ><br>> > > Does uic behave differently to pyuic?
<br>> > ><br>> > ><br>> > > I haven't used uic for some time, but this point is kind of moot since<br>> ><br>> > C++<br>> ><br>> > > doesn't have properties while Python does :)
<br>> ><br>> > Qt/C++ does have properties.<br>> ><br>> > > The point is that I can't see<br>> > > that there is any reason for pyuic to try and use the setter method,<br>> ><br>
> > when<br>> ><br>> > > it can simply use the property (i.e., obj.value = something).<br>> ><br>> > Because it needs to have the same behaviour as uic. If it doesn't then it<br>> > is
<br>> > clearly a pyuic bug. If not then it may be a bug in the implementation of<br>> > pyqtProperty.<br>><br>> I'm not sure I follow you here, but I'll let you comment on my attached<br>> example first.
<br>><br>> Can you send me a .ui file?<br>><br>><br>> Better yet, I've attached a modified PyDemo example where the setZoom<br>> method is renamed to _set_zoom (to mimic my naming convention) and a basic
<br>> form using the widget. This illustrates the problem. There's no problem<br>> modifying PyDemo's zoom property as it were another attribute, e.g.,<br>> demo.zoom = 1, but the pyuic generated code insists on calling setZoom
<br>> which isn't there.<br><br>It is fixed in tonight's snapshot. The fix is to call setProperty() (as uic<br>does). Setting the attribute directly would only work if the property was<br>defined using pyqtProperty, but pyuic cannot distinguish between those and
<br>ordinary Qt properties and so it has to assume the latter.</blockquote><div><br>Great, thanks for fixing this. I didn't consider that pyuic has to deal with both Qt and PyQt properties.<br><br>Arve<br></div><br></div>
<br>