[Pythonmac-SIG] py2app and PyQt4

Jeremy Sanders jeremy at jeremysanders.net
Fri Nov 21 18:06:18 CET 2008


Would it be possible for someone to have a look at the test case I've 
included? It is a very simple PyQt4 program to load a dialog from a ui 
file.

py2app doesn't seem to handle the PyQt4.uic module properly. It also 
leaves out sip.py.

Thanks

Jeremy

-- 
Jeremy Sanders <jeremy at jeremysanders.net>
http://www.jeremysanders.net/                Cambridge, UK
Public Key Server PGP Key ID: E1AAE053
-------------- next part --------------
#!/usr/bin/env python

import sys
import os.path

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.uic import loadUi

class TestDialog(QDialog):
    def __init__(self, *args):
        QDialog.__init__(self, *args)
	dirname = os.path.dirname( os.path.abspath(__file__) )

        loadUi(os.path.join(dirname, 'test.ui'), self)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    dialog = TestDialog()
    dialog.show()
    app.exec_()
-------------- next part --------------
<ui version="4.0" >
 <class>Dialog</class>
 <widget class="QDialog" name="Dialog" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>Dialog</string>
  </property>
  <layout class="QVBoxLayout" name="verticalLayout" >
   <item>
    <widget class="QLabel" name="label" >
     <property name="text" >
      <string>test</string>
     </property>
    </widget>
   </item>
  </layout>
 </widget>
 <resources/>
 <connections/>
</ui>
-------------- next part --------------
#!/usr/bin/env python

from distutils.core import setup, Extension
from distutils.command.install_data import install_data

import py2app

# Pete Shinner's distutils data file fix... from distutils-sig
#  data installer with improved intelligence over distutils
#  data files are copied into the project directory instead
#  of willy-nilly
class smart_install_data(install_data):
    def run(self):
        # need to change self.install_dir to the library dir
        install_cmd = self.get_finalized_command('install')
        self.install_dir = getattr(install_cmd, 'install_lib')
        return install_data.run(self)

setup(name = 'test',
      app = ['test.py'],
      cmdclass = { 'install_data': smart_install_data },
      data_files = [ ('', ['test.ui']) ],
      )


More information about the Pythonmac-SIG mailing list