[PyKDE] Another problem with custom widgets and pyuic4

Andreas Pakulat apaku at gmx.de
Mon Jan 16 16:11:53 GMT 2006


Hi,

Torsten this is for you:

There is a problem setting various parameters on custom widgets, for
example changing the sizePolicy in designer for a custom widget results
in pyuic4 failing to generate the code with:

andreas at morpheus:~/projects/pyfilmdbsimpleui/ui>pyuic4 moviewidget.ui -o Ui_moviewidget.py
DEBUG:root:UI version is 4.0
DEBUG:root:uiname is MovieWidget
DEBUG:root:toplevel widget is QWidget
DEBUG:root:push QWidget MovieWidget
DEBUG:root:push QGridLayout gridlayout
DEBUG:root:push QGroupBox groupBox
DEBUG:root:push QVBoxLayout vboxlayout
DEBUG:root:push QHBoxLayout hboxlayout
DEBUG:root:push QLabel label
DEBUG:root:pop widget QLabel label
DEBUG:root:new topwidget self.groupBox
DEBUG:root:push QLineEdit title
DEBUG:root:pop widget QLineEdit title
DEBUG:root:new topwidget self.groupBox
DEBUG:root:pop layout QHBoxLayout hboxlayout
DEBUG:root:push QHBoxLayout hboxlayout1
DEBUG:root:push QVBoxLayout vboxlayout1
DEBUG:root:push ReleaseWidget release
DEBUG:root:pop widget ReleaseWidget release
DEBUG:root:new topwidget self.groupBox
DEBUG:root:pop layout QVBoxLayout vboxlayout1
Traceback (most recent call last):
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/pyuic.py", line 44, in ?
    sys.exit(Compiler.compileUi(args[1], options))
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/Compiler/__init__.py", line 44, in compileUi
    widget = ui_compiler.compileUi(input_file)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/Compiler/compiler.py", line 59, in compileUi
    return self.parse(filename)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 387, in parse
    actor(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 271, in createUserInterface
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 183, in createLayout
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 192, in handleItem
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 133, in createWidget
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 183, in createLayout
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 192, in handleItem
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 183, in createLayout
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 192, in handleItem
    self.traverseWidgetTree(elem)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 261, in traverseWidgetTree
    handler(self, child)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 132, in createWidget
    self.stack.push(self.setupObject(widgetClass(elem), parent, elem))
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/uiparser.py", line 108, in setupObject
    self.wprops.setProperties(obj, branch)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/properties.py", line 100, in setProperties
    getattr(self, propname)(widget, prop)
  File "/home/andreas/python2.4/lib/python2.4/site-packages/PyQt4/uic/properties.py", line 152, in sizePolicy
    sizePolicy.setHeightForWidth(widget.sizePolicy().hasHeightForWidth())
AttributeError: 'NoneType' object has no attribute 'hasHeightForWidth'
[24260 refs]

The .ui-file for this is attached.

I guess the problem is that the custom widget is not instantiated though
I always thought you do not execute the code you generate??

Andreas

-- 
You own a dog, but you can only feed a cat.
-------------- next part --------------
<ui version="4.0" >
 <author></author>
 <comment></comment>
 <exportmacro></exportmacro>
 <class>MovieWidget</class>
 <widget class="QWidget" name="MovieWidget" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>873</width>
    <height>288</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>Form</string>
  </property>
  <layout class="QGridLayout" name="gridLayout1">
   <property name="margin" >
    <number>0</number>
   </property>
   <property name="spacing" >
    <number>6</number>
   </property>
   <item row="0" column="0" >
    <widget class="QGroupBox" name="groupBox" >
     <property name="enabled" >
      <bool>true</bool>
     </property>
     <property name="title" >
      <string>Movie</string>
     </property>
     <layout class="QVBoxLayout" name="vboxlayout1">
      <property name="margin" >
       <number>6</number>
      </property>
      <property name="spacing" >
       <number>6</number>
      </property>
      <item>
       <layout class="QHBoxLayout" name="hboxLayout1" >
        <property name="margin" >
         <number>0</number>
        </property>
        <property name="spacing" >
         <number>6</number>
        </property>
        <item>
         <widget class="QLabel" name="label" >
          <property name="enabled" >
           <bool>true</bool>
          </property>
          <property name="text" >
           <string>Title:</string>
          </property>
         </widget>
        </item>
        <item>
         <widget class="QLineEdit" name="title" >
          <property name="enabled" >
           <bool>true</bool>
          </property>
          <property name="sizePolicy" >
           <sizepolicy>
            <hsizetype>7</hsizetype>
            <vsizetype>5</vsizetype>
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
         </widget>
        </item>
       </layout>
      </item>
      <item>
       <layout class="QHBoxLayout" name="hboxlayout2">
        <property name="margin" >
         <number>0</number>
        </property>
        <property name="spacing" >
         <number>6</number>
        </property>
        <item>
         <layout class="QVBoxLayout" name="vboxlayout2">
          <property name="margin" >
           <number>0</number>
          </property>
          <property name="spacing" >
           <number>6</number>
          </property>
          <item>
           <widget class="ReleaseWidget" name="release" >
            <property name="toolTip" >
             <string>Release</string>
            </property>
           </widget>
          </item>
          <item>
           <spacer>
            <property name="orientation" >
             <enum>Qt::Vertical</enum>
            </property>
            <property name="sizeHint" >
             <size>
              <width>20</width>
              <height>40</height>
             </size>
            </property>
           </spacer>
          </item>
         </layout>
        </item>
        <item>
         <widget class="PersonWidget" name="persons" >
          <property name="sizePolicy" >
           <sizepolicy>
            <hsizetype>5</hsizetype>
            <vsizetype>5</vsizetype>
            <horstretch>3</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
         </widget>
        </item>
       </layout>
      </item>
     </layout>
    </widget>
   </item>
  </layout>
 </widget>
 <pixmapfunction></pixmapfunction>
 <customwidgets>
  <customwidget>
   <class>ReleaseWidget</class>
   <extends></extends>
   <header>widgets/releasewidget.h</header>
   <container>0</container>
   <pixmap></pixmap>
  </customwidget>
  <customwidget>
   <class>PersonWidget</class>
   <extends></extends>
   <header>widgets/personwidget.h</header>
   <container>0</container>
   <pixmap></pixmap>
  </customwidget>
 </customwidgets>
 <resources>
  <include location="../../filmdbsimpleui.qrc" />
 </resources>
 <connections/>
</ui>


More information about the PyQt mailing list