[PyKDE] pyuic patch for use with designer 3

Christian Bird cbird at lineo.com
Tue Jun 18 12:44:00 BST 2002

Hello all,

I've been using PyQt and qt designer 3 quite a lot lately and was a bit bummed 
that I couldn't use the integrated source editor when creating slots 
connected to signals for various widgets.  To overcome this, I hacked a bit 
on pyuic so that it will include the code from various functions defined in 
foo.ui.h when creating a python class from foo.ui.  I don't know if this will 
be helpful at all for others, but it's helped me a lot.

To use it, apply the patch to PyQt-3.2.4/pyuic/form.cpp

Then, in qt designer, when you need to edit a slot and the source
editor appears, enter python code between the curly braces (don't worry about 
the correct starting indent level, each line is prepended with a correct 
indentation) and then make sure that the ui.h file is in the same directory 
as the ui file when using pyuic.  Here's an example of one of my slots.

void DebMainWindowFrm::browsePushButtonClicked()
import os    
done = 0
while not done:
	filename = QFileDialog.getOpenFileName("*.deb", "", self, 
"DebianPackageSelector", "Select Debian Package File (.deb)")
	filename = str(filename).strip()
	if filename == "":
	if not os.path.exists(filename):
		status = QMessageBox.critical(self, "Bad Filename", """<qt>
			The filename you specified <b>%s</b> does not exist.  Would you like to 
select another file
			or cancel?</qt>""" % filename, "&Select File", "&Cancel", None, 0, 1)
		if status == 0:
		if status == 1:
	done = 1 

If you use this, you'll need to turn off all of the fancy options for the C++ 
editor in designer.  Let me know if anyone has problems.

-- Christian Bird

cbird at lineo.com

The diff is attached
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyuic.patch
Type: text/x-diff
Size: 4809 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20020618/dedaab67/pyuic.bin

More information about the PyQt mailing list