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

List:       pykde
Subject:    [PyQt] Drop to QTDesigner using PyQt4 problem
From:       Mathias.MAZEL () akka ! eu
Date:       2015-11-09 17:04:27
Message-ID: OFE07BE6D3.6F709048-ONC1257EF8.005DCABB-C1257EF8.005DCAC0 () akka ! eu
[Download RAW message or body]

[Attachment #2 (text/html)]

<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" \
size="2"><div><span style="font-family: monospace, 'Courier New', Courier, monospace; \
font-size: 12.8px;">Using PyQt4 + QT4.8.4, I'd like to drop (external) textual \
content to a widget defined as a PyQt4 plugin in QtDesigner</span></div><div><font \
face="monospace, Courier New, Courier, monospace"><br></font></div><div><font \
face="monospace, Courier New, Courier, monospace">I use two python classes \
:</font></div><div><font face="monospace, Courier New, Courier, monospace">- \
widgetlabelplugin.py inherited from \
QPyDesignerCustomWidgetPlugin</font></div><div><font face="monospace, Courier New, \
Courier, monospace">- widgetlabel.py inherited from QLabel</font></div><div><font \
face="monospace, Courier New, Courier, monospace"><br></font></div><div><font \
face="monospace, Courier New, Courier, monospace">Overriding the dropEvent in \
(widgetlabel.py), I'm able to retrieve "external textual content" and to set _model \
property.</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace">I do the following steps :</font></div><div><font face="monospace, Courier \
New, Courier, monospace">1 - Launch designer bu previously setting PYQTDESIGNERPATH \
to the .py path</font></div><div><font face="monospace, Courier New, Courier, \
monospace">2 - Create a dialog without button</font></div><div><font face="monospace, \
Courier New, Courier, monospace">3 - Drop a PyGMT/ WiddgetLabel on the \
dialog</font></div><div><font face="monospace, Courier New, Courier, monospace">4 - \
Drop a "textual content" (from notepad) to the widgetlabel \
label</font></div><div><font face="monospace, Courier New, Courier, monospace">&nbsp; \
-&gt; at this step, the label is updated on the dialog but not on the properties \
browser on the right</font></div><div><font face="monospace, Courier New, Courier, \
monospace">5 - Save Dialog from Qt designer tool bar&nbsp;</font></div><div><font \
face="monospace, Courier New, Courier, monospace">&nbsp; -&gt; ui file doesn't \
contain any "textual content" neither for QLabel/text, nor \
WidgetLabel/model</font></div><div><font face="monospace, Courier New, Courier, \
monospace">6 - In Qt designer, If I select dialog background and reselect \
WidgetLabel, properties are updated in the browser, they are still not saved if I \
save the ui !</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace">Thanks for your help !</font></div><div><font face="monospace, Courier \
New, Courier, monospace"><br></font></div><div><font face="monospace, Courier New, \
Courier, monospace">----------------------------------------------------------------------------------</font></div><div><font \
face="monospace, Courier New, Courier, monospace">python class : \
widgetlabelplugin.py</font></div><div><font face="monospace, Courier New, Courier, \
monospace">----------------------------------------------------------------------------------</font></div><div><font \
face="monospace, Courier New, Courier, monospace"># A demonstration custom widget \
plugin for PROJECT Qt Designer.</font></div><div><font face="monospace, Courier New, \
Courier, monospace">from PyQt4 import QtGui, QtDesigner</font></div><div><font \
face="monospace, Courier New, Courier, monospace"><br></font></div><div><font \
face="monospace, Courier New, Courier, monospace">from widgetlabel import \
WidgetLabel</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace"># This class implements the interface expected by Qt Designer to access \
the</font></div><div><font face="monospace, Courier New, Courier, monospace"># custom \
widget. &nbsp;See the description of the \
QDesignerCustomWidgetInterface</font></div><div><font face="monospace, Courier New, \
Courier, monospace"># class for full details.</font></div><div><font face="monospace, \
Courier New, Courier, monospace">class \
WidgetLabelPlugin(QtDesigner.QPyDesignerCustomWidgetPlugin):</font></div><div><font \
face="monospace, Courier New, Courier, monospace"><br></font></div><div><font \
face="monospace, Courier New, Courier, monospace">&nbsp; &nbsp; # Initialise the \
instance.</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; def __init__(self, parent=None):</font></div><div><font \
face="monospace, Courier New, Courier, monospace">&nbsp; &nbsp; &nbsp; &nbsp; \
super(WidgetLabelPlugin, self).__init__(parent)</font></div><div><font \
face="monospace, Courier New, Courier, monospace"><br></font></div><div><font \
face="monospace, Courier New, Courier, monospace">&nbsp; &nbsp; &nbsp; &nbsp; \
self._initialized = False</font></div><div><font face="monospace, Courier New, \
Courier, monospace"><br></font></div><div><font face="monospace, Courier New, \
Courier, monospace">&nbsp; &nbsp; # Initialise the custom widget for use with the \
specified formEditor</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; # interface.</font></div><div><font face="monospace, Courier \
New, Courier, monospace">&nbsp; &nbsp; def initialize(self, \
formEditor):</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; &nbsp; &nbsp; if self._initialized:</font></div><div><font \
face="monospace, Courier New, Courier, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; return</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; &nbsp; &nbsp; self._initialized = \
True</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; # Return True if the custom widget has been \
intialised.</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; def isInitialized(self):</font></div><div><font \
face="monospace, Courier New, Courier, monospace">&nbsp; &nbsp; &nbsp; &nbsp; return \
self._initialized</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; # Return a new instance of the custom widget with the given \
parent.</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; def createWidget(self, parent):</font></div><div><font \
face="monospace, Courier New, Courier, monospace">&nbsp; &nbsp; &nbsp; &nbsp; return \
WidgetLabel(parent)</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; # Return the name of the class that implements the custom \
widget.</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; def name(self):</font></div><div><font face="monospace, \
Courier New, Courier, monospace">&nbsp; &nbsp; &nbsp; &nbsp; return \
"WidgetLabel"</font></div><div><font face="monospace, Courier New, Courier, \
monospace"><br></font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; # Return the name of the group to which the custom widget \
belongs. &nbsp;A new</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; # group will be created if it doesn't already \
exist.</font></div><div><font face="monospace, Courier New, Courier, \
monospace">&nbsp; &nbsp; <span id="e-$new-1-bodyrich-editor-misspell-256" \
class="s-rtetext-misspelled tr-spellcheck-wordid-9 tr-spellcheck-correctionid-256" \
spellindex="256" transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-9 \
tr-spellcheck-correctionid-256"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>def</span> <span \
id="e-$new-1-bodyrich-editor-misspell-257" class="s-rtetext-misspelled \
tr-spellcheck-wordid-30 tr-spellcheck-correctionid-257" spellindex="257" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-30 \
tr-spellcheck-correctionid-257"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>group</span>(<span \
id="e-$new-1-bodyrich-editor-misspell-258" class="s-rtetext-misspelled \
tr-spellcheck-wordid-7 tr-spellcheck-correctionid-258" spellindex="258" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-7 \
tr-spellcheck-correctionid-258"><img class="s-nodisplay" \
style="width:0px;height:0px;" \
border="none"></span>self</span>):</font></div><div><font face="monospace, Courier \
New, Courier, monospace">&nbsp; &nbsp; &nbsp; &nbsp; <span \
id="e-$new-1-bodyrich-editor-misspell-259" class="s-rtetext-misspelled \
tr-spellcheck-wordid-6 tr-spellcheck-correctionid-259" spellindex="259" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-6 \
tr-spellcheck-correctionid-259"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>return</span> "<span \
id="e-$new-1-bodyrich-editor-misspell-260" class="s-rtetext-misspelled \
tr-spellcheck-wordid-29 tr-spellcheck-correctionid-260" spellindex="260" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-29 \
tr-spellcheck-correctionid-260"><img class="s-nodisplay" \
style="width:0px;height:0px;" \
border="none"></span>PyGMT</span>"</font></div><div><font face="monospace, Courier \
New, Courier, monospace"><br></font></div><div><font face="monospace, Courier New, \
Courier, monospace">&nbsp; &nbsp; # <span id="e-$new-1-bodyrich-editor-misspell-261" \
class="s-rtetext-misspelled tr-spellcheck-wordid-18 tr-spellcheck-correctionid-261" \
spellindex="261" transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-18 \
tr-spellcheck-correctionid-261"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>Return</span> <span \
id="e-$new-1-bodyrich-editor-misspell-262" class="s-rtetext-misspelled \
tr-spellcheck-wordid-10 tr-spellcheck-correctionid-262" spellindex="262" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-10 \
tr-spellcheck-correctionid-262"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>the</span> <span \
id="e-$new-1-bodyrich-editor-misspell-263" class="s-rtetext-misspelled \
tr-spellcheck-wordid-25 tr-spellcheck-correctionid-263" spellindex="263" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-25 \
tr-spellcheck-correctionid-263"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>icon</span> <span \
id="e-$new-1-bodyrich-editor-misspell-264" class="s-rtetext-misspelled \
tr-spellcheck-wordid-15 tr-spellcheck-correctionid-264" spellindex="264" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-15 \
tr-spellcheck-correctionid-264"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>used</span> <span \
id="e-$new-1-bodyrich-editor-misspell-265" class="s-rtetext-misspelled \
tr-spellcheck-wordid-28 tr-spellcheck-correctionid-265" spellindex="265" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-28 \
tr-spellcheck-correctionid-265"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>to</span> <span \
id="e-$new-1-bodyrich-editor-misspell-266" class="s-rtetext-misspelled \
tr-spellcheck-wordid-27 tr-spellcheck-correctionid-266" spellindex="266" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-27 \
tr-spellcheck-correctionid-266"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>represent</span> <span \
id="e-$new-1-bodyrich-editor-misspell-267" class="s-rtetext-misspelled \
tr-spellcheck-wordid-10 tr-spellcheck-correctionid-267" spellindex="267" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-10 \
tr-spellcheck-correctionid-267"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>the</span> <span \
id="e-$new-1-bodyrich-editor-misspell-268" class="s-rtetext-misspelled \
tr-spellcheck-wordid-2 tr-spellcheck-correctionid-268" spellindex="268" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-2 \
tr-spellcheck-correctionid-268"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>custom</span> <span \
id="e-$new-1-bodyrich-editor-misspell-269" class="s-rtetext-misspelled \
tr-spellcheck-wordid-1 tr-spellcheck-correctionid-269" spellindex="269" \
transient="element" style="background-image: \
url(https://imail.akka.eu/iNotes/Forms9.nsf/squiggle.gif?OpenFileResource&amp;MX&amp;TS=20140122T145817,12Z);"><span \
transient="contents" class="tr-spellcheck-wordid-1 \
tr-spellcheck-correctionid-269"><img class="s-nodisplay" \
style="width:0px;height:0px;" border="none"></span>widget</span> in <span \
id="e-$new-1-bodyrich-editor-misspell-270" class="s-rtetext-misspelled \
tr-spellcheck-wordid-26 tr-spellcheck-correctionid-270" spellindex="270" \
transient="element" style="background-image: \


[Attachment #3 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://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