|
From: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - 2008-12-31 16:27:55
|
On Tue, 30 Dec 2008 12:24:20 -0800 "Alec Bennett" <wry...@gm...>
wrote:
> The final thing I need to be able to do is pass the app a parameter.
> Can you see an easy way to do that? Something like this... Note the
> "test" and "dummy" below. This fails with "No such file or directory:
> 'test'".
That'll be because the Application object expects the second parameter
passed to it to be a resource filename that already exists. You can
then specify something other than minimal.rsrc.py.
You could subclass again...
from PythonCard import model
class Minimal(model.Background):
def __init__(self, aParent, aBgRsrc):
aBgRsrc.style = ['wx.DEFAULT_FRAME_STYLE','wx.STAY_ON_TOP']
model.Background.__init__(self, aParent, aBgRsrc)
class MyApplication(model.Application):
def __init__(self, frameClass, param1):
print "This should go to console: %s" % (param1,)
model.Application.__init__(self, frameClass)
if __name__ == '__main__':
app = MyApplication(Minimal, "test")
app.MainLoop()
The problem is, if you want to pass "test" into Minimal through the
__init__ methods you're probably going to have to hack model.py. You
could be lazy and set up a global variable. Pythoncard doesn't really
expect you to be passing in parameters from the command line, for
example, and really expects stuff to arrive either via the resource
file or via the on_initialize() method in the Minimal object. Again
though, whenever I've done that, it's tended to be via a configuration
file, e.g. to switch on debugging via a .INI file.
--
XXXXXXXXXXX
|