[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Creating custom widget for designer
From: Jorge Tornero <jtorlistas () gmail ! com>
Date: 2014-08-29 12:45:26
Message-ID: CAEHjKAtQ0-7Mh5wsqcoeRqjwQ3RGDArSWANXY9uA2HX8K+CKVw () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Florian,
Thank you for your wise advice. When I was asking precisely for what's
better from a clean code perspective.
I've made the widget again whitout the "nested classes" and it works
perfectly.
Thank you very much
Jorge Tornero
2014-08-29 9:41 GMT+02:00 Florian Bruhin <me@the-compiler.org>:
> Hi,
>
> * Jorge Tornero <jtorlistas@gmail.com> [2014-08-21 04:59:10 +0200]:
> > Dear all,
> > I've created a custom widget which can be used from within designer-qt4,
> > following the few recipes available out there.
> >
> > It works as expected but, because I'm not a pro, I'm looking for some
> > advice on the way I've implemented the widget.
> >
> > Basically: the base class is a QLineEdit in which a key event triggers a
> > Qdialog which has customized QComboBox inside. Therefore I've implemented
> > the widget as a single class in this fashion (simplified)
> >
> > class myLineEdit(QLineEdit):
> > class myPopupDialog(QDialog):
> >
> > class myCustomCombo(QComboBox):
> > (Definition of myCustomCombo goes here)
> > (Definition of mypopupdialog goes here, including some
> customcombos)
> >
> > (Defi ition of mylineedit goes here including key event handler
> > that execs a mypopupdialog)
> >
> > This, say so, class-!nesting schema is very strange to me, so let me
> > ask you if this is a correct way of implementing such widgets,
> > providing they're going to be used as designer plugins.
> >
> > Thank you very much for your advice
>
> I don't know anything about designer plugins, so this is more from the
> general Python perspective:
>
> This certainly works - I sometimes use it for small helper functions.
> It seems like it works fine with classes as well.
>
> However, IMHO it would be cleaner to just define multiple classes in a
> module, all on the toplevel, like this:
>
>
> class myCustomCombo(QComboBox):
> (Definition of myCustomCombo goes here)
>
>
> class myPopupDialog(QDialog):
> (Definition of mypopupdialog goes here, including some
> customcombos)
>
>
> class myLineEdit(QLineEdit):
> (Definition of mylineedit goes here including key event handler
> that execs a mypopupdialog)
>
>
> Florian
>
> --
> http://www.the-compiler.org | me@the-compiler.org (Mail/XMPP)
> GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
> I love long mails! | http://email.is-not-s.ms/
>
> _______________________________________________
> PyQt mailing list PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
[Attachment #5 (text/html)]
<div dir="ltr"><div><div><div>Hi Florian,<br><br></div>Thank you for your wise \
advice. When I was asking precisely for what's better from a clean code \
perspective.<br><br>I've made the widget again whitout the "nested \
classes" and it works perfectly.<br> <br></div>Thank you very \
much<br><br></div>Jorge Tornero<br></div><div class="gmail_extra"><br><br><div \
class="gmail_quote">2014-08-29 9:41 GMT+02:00 Florian Bruhin <span dir="ltr"><<a \
href="mailto:me@the-compiler.org" \
target="_blank">me@the-compiler.org</a>></span>:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Hi,<br> <br>
* Jorge Tornero <<a \
href="mailto:jtorlistas@gmail.com">jtorlistas@gmail.com</a>> [2014-08-21 04:59:10 \
+0200]:<br> <div><div class="h5">> Dear all,<br>
> I've created a custom widget which can be used from within \
designer-qt4,<br> > following the few recipes available out there.<br>
><br>
> It works as expected but, because I'm not a pro, I'm looking for \
some<br> > advice on the way I've implemented the widget.<br>
><br>
> Basically: the base class is a QLineEdit in which a key event triggers a<br>
> Qdialog which has customized QComboBox inside. Therefore I've \
implemented<br> > the widget as a single class in this fashion (simplified)<br>
><br>
> class myLineEdit(QLineEdit):<br>
> class myPopupDialog(QDialog):<br>
><br>
> class myCustomCombo(QComboBox):<br>
> (Definition of myCustomCombo goes here)<br>
> (Definition of mypopupdialog goes here, including some \
customcombos)<br> ><br>
> (Defi ition of mylineedit goes here including key event handler<br>
> that execs a mypopupdialog)<br>
><br>
> This, say so, class-!nesting schema is very strange to me, so let me<br>
> ask you if this is a correct way of implementing such widgets,<br>
> providing they're going to be used as designer plugins.<br>
><br>
> Thank you very much for your advice<br>
<br>
</div></div>I don't know anything about designer plugins, so this is more from \
the<br> general Python perspective:<br>
<br>
This certainly works - I sometimes use it for small helper functions.<br>
It seems like it works fine with classes as well.<br>
<br>
However, IMHO it would be cleaner to just define multiple classes in a<br>
module, all on the toplevel, like this:<br>
<div class=""><br>
<br>
class myCustomCombo(QComboBox):<br>
(Definition of myCustomCombo goes here)<br>
<br>
<br>
</div>class myPopupDialog(QDialog):<br>
<div class=""> (Definition of mypopupdialog goes here, including some<br>
customcombos)<br>
<br>
<br>
</div>class myLineEdit(QLineEdit):<br>
(Definition of mylineedit goes here including key event handler<br>
that execs a mypopupdialog)<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
Florian<br>
<br>
--<br>
<a href="http://www.the-compiler.org" target="_blank">http://www.the-compiler.org</a> \
| <a href="mailto:me@the-compiler.org">me@the-compiler.org</a> \
(Mail/XMPP)<br>
GPG 0xFD55A072 | <a href="http://the-compiler.org/pubkey.asc" \
target="_blank">http://the-compiler.org/pubkey.asc</a><br>
I love long mails! | <a href="http://email.is-not-s.ms/" \
target="_blank">http://email.is-not-s.ms/</a><br> \
</font></span><br>_______________________________________________<br> PyQt mailing \
list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" \
target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br></div>
[Attachment #6 (text/plain)]
_______________________________________________
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