Initializing forms in PyQT

T

tanner

I'm new to Python & PyQT so please bear with me.

I have a collection of QT Designer generated .ui files that will comprise
the app interface. These are compiled using pyuic under Eric3.

My problem is that these .ui files are still evolving, and that my mods to
the the forms' code get clobbered whenever I regenerate the .ui files.

Is there a method to embed python code in the actual .ui files themselves?
Or is there an accepted method of having a form either manually or
automatically initialize itself by calling a seperate file?

(The source code of Eric3 generally seems to organize related .ui files into
subdirectories, each of which contains an __init__.py file. I'm not sure of
the mechanics of how/when this file is handled.)

QT Designer generates stubs for SLOTS in it's code. I wish to over-ride
replace the SLOTS fuctions through the use of my seperate file. Any help or
comments is appreciated.
 
T

Torsten Marek

I'm new to Python & PyQT so please bear with me.

I have a collection of QT Designer generated .ui files that will comprise
the app interface. These are compiled using pyuic under Eric3.

My problem is that these .ui files are still evolving, and that my mods to
the the forms' code get clobbered whenever I regenerate the .ui files.
You are not supposed to put any code in there.
Is there a method to embed python code in the actual .ui files themselves?
Or is there an accepted method of having a form either manually or
automatically initialize itself by calling a seperate file?

(The source code of Eric3 generally seems to organize related .ui files into
subdirectories, each of which contains an __init__.py file. I'm not sure of
the mechanics of how/when this file is handled.)

QT Designer generates stubs for SLOTS in it's code. I wish to over-ride
replace the SLOTS fuctions through the use of my seperate file. Any help or
comments is appreciated.
Yes, just use the signal/slot mechanism of Qt Designer to generate the
slots (don't bother that they have C++ names) and just write your Python
(!, no C++-to-Python translation) into the editor of Designer. The
functions are saved in the .ui.h file, which will be scanned by pyuic
and added to your Python class. You might also want to add the -x switch
to pyuic, so that it adds code to show the class (but I do not know
whether this works, because I never used it).
But remember, the normal way of using those Qt Designer generated files
is to subclass them, if you want to do something more complex.

If you have more questions, maybe you want to have a look at the
PyQt/PyKDE mailing list (addresses are on the PyQt page,
www.riverbankcomputing.co.uk)

greets

Torsten
 
L

Larry goodman

The other thing you can do is inherit a new for from your designed
form and override the slots you want to code. That way when your gui
class gets regenerated, you dont lose any of your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top