[Pythonmac-SIG] Using custom DLOGs with EasyDialogs

Jack Jansen Jack.Jansen@oratrix.com
Sun, 10 Nov 2002 21:08:41 +0100


On vrijdag, nov 8, 2002, at 16:46 Europe/Amsterdam, ang blank wrote:

> I would like to know where I am supposed to put custom
> DLOG resources so they can be called by EasyDialogs.
> I would also like to know where I can find the correct
> item numbers for the items within the DLOG.
>
> I would imagine that I could copy the appropriate DLOG
> from the Python Core and modify it and give it a
> different ID number.  My only problem, I think, is
> that I don't know where to put my modified DLOG
> resource.

That should work, but don't forget the copy the DITL as well.

> I have tried putting it into an applet, but it will
> just throw this error:
>
> Traceback (most recent call last):
>   File "Macintosh HD:Desktop Folder:EasyDialogs", line
> 5, in ?
>     EasyDialogs.Message('EasyDialogs.Message in
> action', id=512, ok='OK!')
>   File "Macintosh HD:Applications (Mac OS 9):Python
> 2.2.1:Mac:Lib:EasyDialogs.py", line 55, in Message
>     h = d.GetDialogItemAsControl(2)
> MacOS.Error: (-30596, 'errItemNotControl')

Either you forgot the DITL (or didn't renumber it correctly, it's hell 
to get these resources that refer to each other right manually), or 
you've changed the order of the items in the dialog so item 2 is indeed 
no longer a control.
>
> If I try putting the DLOG into a script file, the
> output window will say
>
> Can't get DLOG resource with id = 512

That won't work, at least not automatically. What you could do is put 
the resource into a resource file and manually open that with 
macresource.need(). Or even completely manually with OpenResFile() or 
one of it's friends. If your module is called foo.py, you call your 
resource file foo.rsrc and use macresource.need() then everything will 
automagically work for applets (i.e. foo.rsrc will be copied to the 
applet resource fork, and macresource.need will detect this and not try 
to open the .rsrc file anymore).

You could put the resource into the resource fork of the .py file, but 
I wouldn't advice it. There's all sorts of tools that think .py files 
are data-fork-only, so there's a good chance of losing your resources 
when you transfer your file over the internet or something.
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma 
Goldman -