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

List:       pykde
Subject:    [PyQt] Using uic on KUrl has problems with KFile::ExistingOnly
From:       Shaheed <srhaque () theiet ! org>
Date:       2011-07-10 18:53:06
Message-ID: 201107101953.06720.srhaque () theiet ! org
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

I'm using PyKDE4, and trying to load Designer .ui files. I have a problem with one \
file which has the following KUrl widget:

    <widget class="KUrlRequester" name="kcfg_executable">
     <property name="mode">
      <set>KFile::ExistingOnly|KFile::File</set>
     </property>
    </widget>

When I try to load this using the uic module, I get the following error:

Traceback (most recent call last):
  File "./kterminal_example.py", line 43, in create
    self.creator = ExecutableEditor()
  File "./kterminal_example.py", line 21, in __init__
    self.ui = uic.loadUi("Projects/exekutor/src/ExecutableEditor.ui")
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/__init__.py", line 221, in loadUi
    return DynamicUILoader().loadUi(uifile, baseinstance)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/Loader/loader.py", line 71, in loadUi
    return self.parse(filename, basedir)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 886, in parse
    actor(elem)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 729, in \
createUserInterface  self.traverseWidgetTree(elem)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 707, in \
traverseWidgetTree  handler(self, child)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 449, in \
createLayout  self.traverseWidgetTree(elem)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 707, in \
traverseWidgetTree  handler(self, child)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 486, in handleItem
    self.traverseWidgetTree(elem)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 707, in \
traverseWidgetTree  handler(self, child)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 208, in \
createWidget  self.stack.push(self.setupObject(widget_class, parent, elem))
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py", line 177, in setupObject
    self.wprops.setProperties(obj, branch)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py", line 403, in \
setProperties  prop_value = self.convert(prop, widget)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py", line 368, in convert
    return func(prop[0], **args)
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py", line 113, in _set
    expr = [self._pyEnumMember(v) for v in prop.text.split('|')]
  File "/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py", line 108, in \
_pyEnumMember  raise AttributeError("unknown enum %s" % cpp_name)
AttributeError: unknown enum KFile::ExistingOnly

I have checked that importing KFile (from PyKDE4.kio) in the main program makes no \
difference, and that importing it from the interpreter  prompt allows me to print the \
value of KFile.ExistingOnly. So I guess from this last line that the issue is that \
the uic module somehow  needs to know how to resolve the KFile name. Any ideas on how \
to resolve this issue would be appreciated.

Thanks, Shaheed


[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" \
content="1" /><style type="text/css"> p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'helvetica'; font-size:13pt; \
font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">Hi,</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><br /></p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">I'm using PyKDE4, and trying to load Designer .ui \
files. I have a problem with one file which has the following KUrl widget:</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p> \
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    &lt;widget \
class=&quot;KUrlRequester&quot; name=&quot;kcfg_executable&quot;&gt;</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">     &lt;property \
name=&quot;mode&quot;&gt;</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">      &lt;set&gt;KFile::ExistingOnly|KFile::File&lt;/set&gt;</p> \
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">     &lt;/property&gt;</p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    &lt;/widget&gt;</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p> \
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">When I try to load this using \
the uic module, I get the following error:</p> <p style="-qt-paragraph-type:empty; \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Traceback (most recent call \
last):</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">  File \
&quot;./kterminal_example.py&quot;, line 43, in create</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">    self.creator = ExecutableEditor()</p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">  File \
&quot;./kterminal_example.py&quot;, line 21, in __init__</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    self.ui = \
uic.loadUi(&quot;Projects/exekutor/src/ExecutableEditor.ui&quot;)</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/__init__.py&quot;, line 221, in \
loadUi</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    return \
DynamicUILoader().loadUi(uifile, baseinstance)</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/Loader/loader.py&quot;, line 71, in \
loadUi</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    return \
self.parse(filename, basedir)</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 886, in \
parse</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
actor(elem)</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 729, in \
createUserInterface</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">    self.traverseWidgetTree(elem)</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 707, in \
traverseWidgetTree</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
handler(self, child)</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 449, in \
createLayout</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
self.traverseWidgetTree(elem)</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 707, in \
traverseWidgetTree</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
handler(self, child)</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 486, in \
handleItem</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
self.traverseWidgetTree(elem)</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 707, in \
traverseWidgetTree</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
handler(self, child)</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 208, in \
createWidget</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
self.stack.push(self.setupObject(widget_class, parent, elem))</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/uiparser.py&quot;, line 177, in \
setupObject</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
self.wprops.setProperties(obj, branch)</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py&quot;, line 403, in \
setProperties</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    \
prop_value = self.convert(prop, widget)</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py&quot;, line 368, in \
convert</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    return \
func(prop[0], **args)</p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py&quot;, line 113, in \
_set</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    expr = \
[self._pyEnumMember(v) for v in prop.text.split('|')]</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">  File \
&quot;/usr/lib/pymodules/python2.7/PyQt4/uic/properties.py&quot;, line 108, in \
_pyEnumMember</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">    raise \
AttributeError(&quot;unknown enum %s&quot; % cpp_name)</p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">AttributeError: unknown enum \
KFile::ExistingOnly</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><br /></p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">I have checked that importing KFile (from \
PyKDE4.kio) in the main program makes no difference, and that importing it from the \
interpreter prompt allows me to print the value of KFile.ExistingOnly. So I guess \
from this last line that the issue is that the uic module somehow needs to know how \
to resolve the KFile name. Any ideas on how to resolve this issue would be \
appreciated.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><br /></p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">Thanks, Shaheed</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br \
/></p></body></html>



_______________________________________________
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