[PyQt] modules, nameSpaces, and Wizards
James Polk
jpolk5001 at yahoo.com
Wed Jan 5 18:12:30 GMT 2011
Good Day to All,
I'd like to engage the heavy weight gurus out there,
but anyone is welcome to respond,..
(Apologies for the long-winded email, but difficult
to accurate explain)
Though not new to software development, I'm still a bit
of a green horn in PyQt, and in my usual habit of running
before I learn to walk, I've began to code the fun things
and glossed over a few foundation basics, one of which
is modules and namespaces. I'm used to using these constructs
from other languages and applications, and I had gleaned
how to use these, albeit at a novice level. But now, I've
got a need where I need to do something kinda' fancy, but
not covered in any of the books I have, nor after web searching,
so here is the dilemma...
I had created 3 separate PyQt apps, each having the same
development path...
from Designer ----> AAA.ui
from pyuic.py ----> ui_AAA.py
then in my main program, I do the import
import ui_AAA.py as AAX
then write the rest,etc....
So, I was tasked to string these 3 apps togther into a
continuing sequence,..so I looking at QWizard, and I've
been successful at coding a very small, bare-bones PyQt
program that puts in of the three UIs into the 1,2,3 nature
of the wizard. Near the top of this program are
import ui_AAA.py as AAX
import ui_BBB.py as BBX
import ui_CCC.py as CCX
My Main Function looks like this:
class MainWizard(QtGui.QWizard):
def __init__(self, parent=None):
QtGui.QWizard.__init__(self, parent)
self.topWObject = parent
self.setWizardStyle(1)
self.setGeometry(400, 200, 650, 750)
self.setPage(0,Step1_CreateAsset_Dialog(self))
self.setPage(1,Step2_UpdateData_dialog(self))
self.setPage(2,Step3_Publish_dialog(self))
and the "Step 1" (Page0) functions is as follow:
class Step1_CreateAsset_Dialog(QtGui.QWizardPage,Wizard_CreateAsset):
def __init__(self, parent=None):
QtGui.QWizardPage.__init__(self,parent)
Wizard_CreateAsset.__init__(self)
self.setupUi(self)
and the other functions for steps 2 & 3 (Page1 & Page2) are essentially
identical...This all works,...and I am much relieved ;-)
But here's my problem...
Each of these underlying 3 apps, have their own "main" function,
which I can copy&paste in easy enough,...but also each of them
have kinda' long supporting functions. After a test, I found
I could "brute force" it, and copy&paste the entire program
into (and under) the stepX function above,...but rather than
do that,...isn't there a way, where I can do another "import"
statement and *link* the old-way program into the new-way (wizard) one?
>From other work,...I know that I could do
import main_AAA.py as AAA_Main
and in subsequent statements,...use the namespace like
self.whatever(AAA_Main.whatever())
etc,etc...which works in the initial "class" definition function,
but I can't find the right syntax or something to pull in all the
other functions.
I copied
main_AAA.py
to
stripped_main_AAA.py
and stripped out everything except the functions,...and tried to
import it back into the wizard main as:
import stripped_main_AAA.py as AAA_stm
but calling the functions inside "stripped_main_AAA.py" using
the nameSpace prefix "AAA_stm" doesn't work...the first thing
it complains about are graphic elements.
in stripped_main_AAA.py, there's
self.WarningLabel
but addressing that element back in the Wizard proram as
AAA_stm.WarningLabel
or
AAA.WarningLabel
neither works....
So, strategically thinking,...what's the best way to achieve this kind
of program/module sharing/linking?
Any thoughts, suggestions, advice, or words of wisdom, is mostly greatly
appreciated,
Thank you,
-James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110105/7a5041c1/attachment-0001.html>
More information about the PyQt
mailing list