Forum: Poser Python Scripting


Subject: Python hook for Text Editor in General Preferences query

an0malaus opened this issue on Dec 19, 2004 ยท 6 posts


an0malaus posted Sun, 19 December 2004 at 3:48 AM

I'm trying to create a simplistic workaround for a part of the Poser CFM/Python Tkinter MachO brokeness. I need to be able to edit some parameters stored in a text file. I can already do this if I bind the text file to a Python script button and Ctrl-click the button, but I'd like to find a way to determine the path to the Text Editor defined in the Poser 5 General Preferences. I haven't found a hook for this in the Python Manual on Mac OS X (If it's there, I must be truly blind ;-) ). I've looked at the script which launches the text editor, but it appears poser is probably passing in the file to edit in the command line parameters (argv) or something, as I can't see a separate parameter for which file to open. Can anyone help? (Ockham, stewer)?



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


ockham posted Sun, 19 December 2004 at 11:10 AM

On PC: The path itself is the same in both 4 and 5: it's a line in Poser.ini under runtime/prefs. I don't know if Mac would have the same. PYTHON_EDITOR_PATH "C:KEDITWkeditw32.exe" To catch the line: EdPath='' FileName=os.path.normpath('runtime/prefs/poser.ini') fp=open(FileName,'rt') while 1: ~st=fp.readline() ~if not st: break ~Parts=string.split(st) ~if (len(Parts)>1): ~~if string.count(Parts[0],'PYTHON_EDITOR_PATH'): ~~~EdPath=Parts[1] ~~~break fp.close()

My python page
My ShareCG freebies


an0malaus posted Sun, 19 December 2004 at 11:27 AM

Great! Thanks for the hint ockham. P5 on Mac uses ":Runtime:prefs:Poser Prefs" rather than poser.ini, but it looks like it has the same contents. Mine has PYTHON_EDITOR_PATH "Sirius:Applications:BBEdit Lite 6.1:BBEdit Lite 6.1" Your code fragment is exactly what I need to extract this file path. Cheers!



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


ockham posted Sun, 19 December 2004 at 11:36 AM

Incidentally, I've also used the trick of ctrl-click to edit non-Python files like CR2's. It's a nice little hidden feature of Poser!

My python page
My ShareCG freebies


an0malaus posted Sun, 19 December 2004 at 12:05 PM

Ockham, thought you should know that given Mac file names often (and in my case do) contain spaces, I've had to amend the line ~~~EdPath=Parts[1] to read ~~~EdPath=" ".join(Parts[1:]) which puts the remainder of the list of space-separated substrings back into a single file path. Other than that, it works, provided I remember to put a colon in front of Runtime:prefs:Poser Prefs in the normpath line ;-)



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


ockham posted Sun, 19 December 2004 at 12:13 PM

Spaces can be messy. I wish Python had scanf-type formatting for reading strings. It's easier to handle than split and join. Printf-type formatting is already present for forming strings, so why didn't they use it for reading as well? Mysteries of the universe.

My python page
My ShareCG freebies