[PyQt] pyuic4 bug with QButtonGroup?

Jason Tiller jason at sonos.org
Sat Jul 3 06:37:23 BST 2010


Hi, All, :)

I encountered what I believe is a bug in pyuic4's generation of
QButtonGroup code.  I created a simple .ui that contains nothing more
than:

    * 2 QRadioButtons
    * 1 QButtonGroup that contains them

Running the output through pyuic4

Python User Interface Compiler 4.7.2 for Qt version 4.6.2

produces a busted ui_*.py file, of which this is a snippet:

----------
...
self.radioButton.setObjectName("radioButton")
self.QtGui.QApplication.translate("Form", "buttonGroup", None, QtGui.QApplication.UnicodeUTF8) = QtGui.QButtonGroup(Form)
self.QtGui.QApplication.translate("Form", "buttonGroup", None, QtGui.QApplication.UnicodeUTF8).setObjectName("QtGui.QApplication.translate(\"Form\", \"buttonGroup\", None, QtGui.QApplication.UnicodeUTF8)")
self.QtGui.QApplication.translate("Form", "buttonGroup", None, QtGui.QApplication.UnicodeUTF8).addButton(self.radioButton)
self.radioButton_2 = QtGui.QRadioButton(Form)
self.radioButton_2.setGeometry(QtCore.QRect(70, 120, 109, 22))
self.radioButton_2.setObjectName("radioButton_2")
self.QtGui.QApplication.translate("Form", "buttonGroup", None, QtGui.QApplication.UnicodeUTF8) = QtGui.QButtonGroup(Form)
...
----------

The error is, as you'd expect:

----------
jasont at jasont-desktop:~/wc/trunk/code/MainGUI$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ui_untitled
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "ui_untitled.py", line 19
     self.QtGui.QApplication.translate("Form", "buttonGroup", None, QtGui.QApplication.UnicodeUTF8) = QtGui.QButtonGroup(Form)
SyntaxError: can't assign to function call
----------

I've attached the dead-simple untitled.ui file, the translated
ui_untitled.py file, and a Designer screenshot showing my form.

Interestingly, if I run it through 'pyuic4 -p', it launches the GUI
just fine.

Phil, is there something I'm doing wrong here?

Thanks,

---Jason
-------------- next part --------------
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>Form</class>
 <widget class="QWidget" name="Form">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Form</string>
  </property>
  <widget class="QRadioButton" name="radioButton">
   <property name="geometry">
    <rect>
     <x>70</x>
     <y>90</y>
     <width>109</width>
     <height>22</height>
    </rect>
   </property>
   <property name="text">
    <string>RadioButton</string>
   </property>
   <attribute name="buttonGroup">
    <string>buttonGroup</string>
   </attribute>
  </widget>
  <widget class="QRadioButton" name="radioButton_2">
   <property name="geometry">
    <rect>
     <x>70</x>
     <y>120</y>
     <width>109</width>
     <height>22</height>
    </rect>
   </property>
   <property name="text">
    <string>RadioButton</string>
   </property>
   <attribute name="buttonGroup">
    <string>buttonGroup</string>
   </attribute>
  </widget>
 </widget>
 <resources/>
 <connections/>
 <buttongroups>
  <buttongroup name="buttonGroup"/>
 </buttongroups>
</ui>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ui_untitled.py
Type: text/x-python
Size: 2209 bytes
Desc: 
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100702/c9e160c5/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: designer.png
Type: image/png
Size: 71688 bytes
Desc: 
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100702/c9e160c5/attachment-0001.png>


More information about the PyQt mailing list