|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Making a Tk app scriptable via AppleScriptI'm investigating options for making a Tk/Mac application scriptable via
AppleScript and/or Apple Events. Looking around, I see the TclAE extension, and I also see the tkMacOSXHLEvents.c in the Tk-Aqua core. Both appear to support a command called "do script" which, if I'm reading the code and /or docs correctly, allows a user to send a Wish-based application an AppleScript command called "do script" followed by Tcl commands or script. There are also various Apple event handlers defined in tkMacOSXHLEvents.c, such as ::tk::mac::OpenDocument and ::tk::mac::PrintDocument. If these procedures are defined, does this mean that a Tk application would respond to standard AppleScript commands as "launch," "open document," "print document," etc? Is there anything else that one needs to do, i.e. set the "scriptable" setting in Info.plist, to allow it to respond to external AppleScript commands? Also, is there a way to expand more of an app's functionality to AppleScript (perhaps by mapping an AppleScript dictionary of commands onto Tk commands)? Thanks for any advice, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 2009-08-08, at 12:07:55, Kevin Walzer wrote:
> There are also various Apple event handlers defined in > tkMacOSXHLEvents.c, such as ::tk::mac::OpenDocument > and ::tk::mac::PrintDocument. If these procedures are defined, does > this mean that a Tk application would respond to standard > AppleScript commands as "launch," "open document," "print document," > etc? I believe so. > Is there anything else that one needs to do, i.e. set the > "scriptable" setting in Info.plist, to allow it to respond to > external AppleScript commands? This would be: <key>NSAppleScriptEnabled</key> <string>YES</string> You must, at minimum, have an 'aete' resource describing your commands. > Also, is there a way to expand more of an app's functionality to > AppleScript (perhaps by mapping an AppleScript dictionary of > commands onto Tk commands)? The standard thing to have these days is an sdef defined scripting dictionary <x-man-page://5/sdef>. For strictly command based scripting you could use one to support a minimal dictionary. If you have 10.4 users, you must go through an extra step with the <x-man-page://sdp> tool to generate an 'aete' resource file from your sdef and add it to your project. For Carbon applications, it's a substantial amount of work to integrate full object support via strictly Carbon techniques (think coding an object oriented hierarchy and query mechanism in C). If you are able to integrate some Cocoa into your application, there is an example at http://developer.apple.com/samplecode/SimpleCarbonAppleScript/ > which will give you some minimal scriptability (application properties and commands) and the techniques used would be adaptable to a Tk-Cocoa based app in the future. The 'do script' command is obviously very powerful for a Tcl/Tk based app. If you set that up properly, you should be able to get a lot of mileage out of it. If you open up Terminal's dictionary in Script Editor, you'll see it described. You can generate an sdef representation of Terminal's scripting dictionary with the <x-man-page://1/sdef > tool. Philip Aker echo astwta@...@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 2009-08-08, at 13:53:59, Philip Aker wrote:
> On 2009-08-08, at 12:07:55, Kevin Walzer wrote: >> There are also various Apple event handlers defined in >> tkMacOSXHLEvents.c, such as ::tk::mac::OpenDocument >> and ::tk::mac::PrintDocument. If these procedures are defined, does >> this mean that a Tk application would respond to standard >> AppleScript commands as "launch," "open document," "print >> document," etc? > I believe so. Well, due to an off-list post, I see that much has changed since the last time I looked at the code in tkMacOSXHLEvents.c and was using a 10.3/PPC system. It needs to be upgraded to be usable. I have made the required changes in that file but need to test. As I've mentioned previously, I mostly work with Tcl directly and do my own UI. If you would be able to send me a do-little Tk app which links against the Tcl.framework and Tk.framework located in /Library/Frameworks and has stub procs for the AppleEvents, I should be able to test and debug the changes and then send the altered file to whoever can make use of it. The changes should be compatible back to at least 10.3 and forward looking to some extent. I will also create the sdef and 'aete' resource. I'm working with the 8.5.7 projects (10.5 SDK). Philip Aker echo astwta@...@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 8/9/09 12:18 PM, Philip Aker wrote:
> On 2009-08-08, at 13:53:59, Philip Aker wrote: > >> On 2009-08-08, at 12:07:55, Kevin Walzer wrote: > >>> There are also various Apple event handlers defined in >>> tkMacOSXHLEvents.c, such as ::tk::mac::OpenDocument and >>> ::tk::mac::PrintDocument. If these procedures are defined, does this >>> mean that a Tk application would respond to standard AppleScript >>> commands as "launch," "open document," "print document," etc? > >> I believe so. > > Well, due to an off-list post, I see that much has changed since the > last time I looked at the code in tkMacOSXHLEvents.c and was using a > 10.3/PPC system. It needs to be upgraded to be usable. I have made the > required changes in that file but need to test. As I've mentioned > previously, I mostly work with Tcl directly and do my own UI. If you > would be able to send me a do-little Tk app which links against the > Tcl.framework and Tk.framework located in /Library/Frameworks and has > stub procs for the AppleEvents, I should be able to test and debug the > changes and then send the altered file to whoever can make use of it. > The changes should be compatible back to at least 10.3 and forward > looking to some extent. I will also create the sdef and 'aete' resource. > > I'm working with the 8.5.7 projects (10.5 SDK). Unfortunately, I'm not in a position to send you the right kind of app right now--my questions about Apple events were preliminary in nature and I have done nothing to implement this functionality as yet. Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 2009-08-09, at 09:53:16, Kevin Walzer wrote:
>> Well, due to an off-list post, I see that much has changed since the >> last time I looked at the code in tkMacOSXHLEvents.c and was using a >> 10.3/PPC system. It needs to be upgraded to be usable. I have made >> the >> required changes in that file but need to test. As I've mentioned >> previously, I mostly work with Tcl directly and do my own UI. If you >> would be able to send me a do-little Tk app which links against the >> Tcl.framework and Tk.framework located in /Library/Frameworks and has >> stub procs for the AppleEvents, I should be able to test and debug >> the >> changes and then send the altered file to whoever can make use of it. >> The changes should be compatible back to at least 10.3 and forward >> looking to some extent. I will also create the sdef and 'aete' >> resource. >> >> I'm working with the 8.5.7 projects (10.5 SDK). > Unfortunately, I'm not in a position to send you the right kind of > app right now--my questions about Apple events were preliminary in > nature and I have done nothing to implement this functionality as yet. That's ok -- I've now figured things out enough to be able to write to a file on receiving the commands and put up a dialog box. I should have the update available tomorrow sometime. Philip Aker echo astwta@...@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptahhh.. I should really get used to Reply all instead of just Reply... Kevin, here's my previous answer to you which went to Philip instead of the mailing list... (the offlist talk he mentioned) :
Hi, aMSN supports AppleScript events, but it looks like Tk itself doesn't support it correctly, it gives an error : 27:53: execution error: aMSN got an error: AEDoScriptHandler: invalid script type 'txtu', must be 'alis' or 'TEXT' (-1770) You can read more info on how we fixed it here : http://www.amsn-project.net/forums/viewtopic.php?t=6828 Basically, we use tclAE which seems to work fine.. however, all the available binaries for tclAE are version 2.0, which crashes with tcl/tk 8.5.. but the SVN version of tclAE has a fix for that.. I've compiled a universal binary for tclAE, you can find it here : http://amsn.svn.sourceforge.net/viewvc/amsn/trunk/amsn/utils/macosx/tclAE2.0.4/ and we use this script here : http://amsn.svn.sourceforge.net/viewvc/amsn/trunk/amsn/utils/macosx/applescript/ in order to make it work correctly... aMSN uses the default standalone Wish shell bundle and we didn't modify anything in the Info.plist for it to work... Hope that helps. KaKaRoTo On Sun, Aug 9, 2009 at 12:53 PM, Kevin Walzer <kw@...> wrote:
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 8/9/09 6:30 PM, Youness Alaoui wrote:
> ahhh.. I should really get used to Reply all instead of just Reply... > Kevin, here's my previous answer to you which went to Philip instead of > the mailing list... (the offlist talk he mentioned) : > Hi, > > aMSN supports AppleScript events, but it looks like Tk itself doesn't > support it correctly, it gives an error : 27:53: execution error: aMSN > got an error: AEDoScriptHandler: invalid script type 'txtu', must be > 'alis' or 'TEXT' (-1770) > You can read more info on how we fixed it here : > http://www.amsn-project.net/forums/viewtopic.php?t=6828 > Basically, we use tclAE which seems to work fine.. however, all the > available binaries for tclAE are version 2.0, which crashes with tcl/tk > 8.5.. but the SVN version of tclAE has a fix for that.. I've compiled a > universal binary for tclAE, you can find it here : > http://amsn.svn.sourceforge.net/viewvc/amsn/trunk/amsn/utils/macosx/tclAE2.0.4/ > and we use this script here : > http://amsn.svn.sourceforge.net/viewvc/amsn/trunk/amsn/utils/macosx/applescript/ > in order to make it work correctly... aMSN uses the default standalone > Wish shell bundle and we didn't modify anything in the Info.plist for it > to work... > Hope that helps. > KaKaRoTo > Thanks for the suggestion...I'll check these out. -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 2009-08-09, at 13:59:20, Philip Aker wrote:
>> Unfortunately, I'm not in a position to send you the right kind of >> app right now--my questions about Apple events were preliminary in >> nature and I have done nothing to implement this functionality as >> yet. > That's ok -- I've now figured things out enough to be able to write > to a file on receiving the commands and put up a dialog box. I > should have the update available tomorrow sometime. Well, I couldn't find the time to complete that "tomorrow sometime" last week but it's largely done now. It is implemented in this example <http://www.vcn.bc.ca/~philip/Wishbone.zip >. It includes the frameworks necessary for the test application to run and example scripts. The new implementation also includes a means to create custom commands and instructions on how to do so. There will be a detailed discussion about the implementation in my next post. Philip Aker echo astwta@...@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 8/15/09 7:24 AM, Philip Aker wrote:
> Well, I couldn't find the time to complete that "tomorrow sometime" last > week but it's largely done now. > > It is implemented in this example > <http://www.vcn.bc.ca/~philip/Wishbone.zip>. It includes the frameworks > necessary for the test application to run and example scripts. The new > implementation also includes a means to create custom commands and > instructions on how to do so. > > Phillip, Thank you for this. I will take a closer look at it this weekend. I had three quick questions: 1. Were your changes built/tested against Tk CVS HEAD, i.e. the Cocoa-based build? 2. Are these changes compatible with 64-bit? 3. FInally, is the source code of your changes posted somewhere or bundled in the zip file, and will you submit these for inclusion in Tk 8.6 if everything works as expected? Thanks, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 2009-08-15, at 07:01:53, Kevin Walzer wrote:
>> ... It is implemented in this example >> <http://www.vcn.bc.ca/~philip/Wishbone.zip>. It includes the >> frameworks >> necessary for the test application to run and example scripts. The >> new >> implementation also includes a means to create custom commands and >> instructions on how to do so. > I had three quick questions: > 1. Were your changes built/tested against Tk CVS HEAD, i.e. the > Cocoa-based build? I compiled them against the 8.7.5 source release. I wouldn't know what a Tk CVS HEAD looks like even if it was sitting next to me at lunch. My plan is first to submit an update to the tkMacOSXHLEvents.c file that will take care of the problems noted. In that update, I will re- arrange things so that the two exported functions will be moved to the end of the file. Then in a second submission, I will simply append the new implementation to the end of tkMacOSXHLEvents.c. It will replace the two exported functions and work such that if the new proc names in the ::AppleEvent namespace can't be found, then the old ones will be used. Hopefully, the appending approach will be the easiest way for anyone using a 'diff' utility to avoid a spaghetti type of changes readout. > 2. Are these changes compatible with 64-bit? The new portions I will submit are. Whether or not they would have to be further adapted to be usable in TkCocoa I'm not sure. While there is a Cocoa means to use the traditional AppleEvent style handlers, I don't know if it's been implemented. I'm not able to compile the TkCocoa project because it requires a 10.6 Xcode. > 3. FInally, is the source code of your changes posted somewhere or > bundled in the zip file, and will you submit these for inclusion in > Tk 8.6 if everything works as expected? The source file is not currently included because it's not quite ready for prime time (illustrated the problem with 'aevt/pref', and doesn't have the fallback to the old handlers implemented yet. As soon as these are fixed up, I will submit the file and make it available to anyone who wants to recompile it in an older version of their source. I believe it's backwards compatible to at least 10.3 systems and possibly 10.2. § I'd appreciate it if you can tell me the formal channel where these kinds of submissions are supposed to go. Although I've done a lot of work with AppleEvents and Tcl in my OSA Components since 2002, I haven't really had the need to ask/submit changes because I only use a customized tclAppInit.c and Tcl_Main() to interface with Tcl at that level. Philip Aker echo astwta@...@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 8/15/09 2:08 PM, Philip Aker wrote:
> On 2009-08-15, at 07:01:53, Kevin Walzer wrote: > >>> ... It is implemented in this example >>> <http://www.vcn.bc.ca/~philip/Wishbone.zip>. It includes the frameworks >>> necessary for the test application to run and example scripts. The new >>> implementation also includes a means to create custom commands and >>> instructions on how to do so. > >> I had three quick questions: > >> 1. Were your changes built/tested against Tk CVS HEAD, i.e. the >> Cocoa-based build? > > I compiled them against the 8.7.5 source release. I wouldn't know what a > Tk CVS HEAD looks like even if it was sitting next to me at lunch. My > plan is first to submit an update to the tkMacOSXHLEvents.c file that > will take care of the problems noted. In that update, I will re-arrange > things so that the two exported functions will be moved to the end of > the file. Then in a second submission, I will simply append the new > implementation to the end of tkMacOSXHLEvents.c. It will replace the two > exported functions and work such that if the new proc names in the > ::AppleEvent namespace can't be found, then the old ones will be used. > Hopefully, the appending approach will be the easiest way for anyone > using a 'diff' utility to avoid a spaghetti type of changes readout. To build CVS head (which is the bleeding edge of development), see the instructions at http://tcl.sourceforge.net/. Check on "CVS Tree" for both Tcl and Tk. > > >> 2. Are these changes compatible with 64-bit? > > The new portions I will submit are. Whether or not they would have to be > further adapted to be usable in TkCocoa I'm not sure. While there is a > Cocoa means to use the traditional AppleEvent style handlers, I don't > know if it's been implemented. I'm not able to compile the TkCocoa > project because it requires a 10.6 Xcode. Do you mean 10.5? 10.6 isn't out yet... > I'd appreciate it if you can tell me the formal channel where these > kinds of submissions are supposed to go. Although I've done a lot of > work with AppleEvents and Tcl in my OSA Components since 2002, I haven't > really had the need to ask/submit changes because I only use a > customized tclAppInit.c and Tcl_Main() to interface with Tcl at that level. See https://sourceforge.net/tracker/?group_id=12997... -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 2009-08-16, at 16:20:59, Kevin Walzer wrote:
> To build CVS head (which is the bleeding edge of development), see > the instructions at http://tcl.sourceforge.net/. Check on "CVS Tree" > for both Tcl and Tk. Thanks! I wish I had known about that link before. That changes the picture considerably. I'm able to compile and run the SDK10.5 version. But just to make sure we're on the same page, I used these commands: cvs -d:pserver:anonymous@...:/cvsroot/tcl login cvs -z3 -d:pserver:anonymous@...:/cvsroot/tcl co - P tcl cvs -d:pserver:anonymous@...:/cvsroot/ tktoolkit login cvs -z3 -d:pserver:anonymous@...:/cvsroot/ tktoolkit co -P tk I hope that's what you are using. With the stock 8.6 version as I compiled it, I was able to run a few standard AppleScript commands like "properties of every window" but not "do script". So I have tried one method to get "do script" to work. It does so but at the expense of foregoing the standard Cocoa behaviors. I'm not sure if I can overcome this limitation but I have another option I know about to try to have both the standard and custom areas working. Failing that, I think another choice would be to implement the standard application and window properties in the Tk code itself. This could be good because with the stock behavior, the dictionary lies about Wish having document elements (I couldn't find a single occurrence of NSDocument doing a search in Xcode -- although it's a well known thing that Xcode fails to find stuff on a regular basis). With the test method I implemented, I also was able to get the 'doit with parameter…' command to work in C code directly, so at least it seems it will good for other arbitrary commands as well. This would seem to mean that if followed through, the standard Wish dictionary could look very similar to the one I put in the Wishbone example and be extensible. While that's not exactly plush, it would be an accurate representation of what a basic Tk application can do, and I think (still need to do some more testing) that it would enable a theoretical 14,000,000+ of each of several varieties of custom commands and also have a print settings record available. I did not have enough time to test my namespaced proc handler style in AppMain.tcl but I'm reasonably sure that it will work in 8.6. Anyway, that's all the time I had this weekend. I hope to have some more news near the end of the week. > Do you mean 10.5? 10.6 isn't out yet... No I mean that the Xcode project I got previously called "das-tcltk- bb1f166a1261722f693b9a8d3c13fa47420e09a4" (I forget which link I snagged) requires a 10.6 Xcode. I guess Daniel has to account for possible changes in Snow Leopard… >> I'd appreciate it if you can tell me the formal channel… > See https://sourceforge.net/tracker/?group_id=12997... Thanks for that as well. Philip Aker echo astwta@...@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptHi Philip,
On 8/17/09 8:32 AM, Philip Aker wrote: > > I hope that's what you are using. For CVS HEAD, yes. I'm back to using Daniel Steffen's backport of Tk-Cocoa to 8.5, hosted at Github. For the Cocoa bits, it's identical to 8.6 for testing purposes. > > With the stock 8.6 version as I compiled it, I was able to run a few > standard AppleScript commands like "properties of every window" but not > "do script". So I have tried one method to get "do script" to work. It > does so but at the expense of foregoing the standard Cocoa behaviors. > I'm not sure if I can overcome this limitation but I have another option > I know about to try to have both the standard and custom areas working. > Failing that, I think another choice would be to implement the standard > application and window properties in the Tk code itself. This could be > good because with the stock behavior, the dictionary lies about Wish > having document elements (I couldn't find a single occurrence of > NSDocument doing a search in Xcode -- although it's a well known thing > that Xcode fails to find stuff on a regular basis). > > With the test method I implemented, I also was able to get the 'doit > with parameter…' command to work in C code directly, so at least it > seems it will good for other arbitrary commands as well. This would seem > to mean that if followed through, the standard Wish dictionary could > look very similar to the one I put in the Wishbone example and be > extensible. While that's not exactly plush, it would be an accurate > representation of what a basic Tk application can do, and I think (still > need to do some more testing) that it would enable a theoretical > 14,000,000+ of each of several varieties of custom commands and also > have a print settings record available. I did not have enough time to > test my namespaced proc handler style in AppMain.tcl but I'm reasonably > sure that it will work in 8.6. That's good that you've made progress with this. I've done some further testing myself and found that the "do script" command defined in tkMacOSXHLEvents.c appears to be broken in Tk-Cocoa. Opening the AppleScript dictionary for a standalone build of Wish from Tk-Cocoa yields what I guess is the standard Cocoa AppleScript dictionary, but not the "do script" command. I think one reason for this is that there is no .rsrc file in Tk-Cocoa with the aevt for "do script" contained therein. I don't know how to address this for Tk-Cocoa. I did a quick test of ::tk::mac::OpenDocument (the odoc event), and that works, so my guess is that the events mapped to hard-coded Tcl procedures should continue to work fine. It will be helpful to get the "do script" issue solved for Tk-Cocoa for another reason. The basic Apple events defined in tkMacOSXHLEvents.c duplicate some of what's available in the TclAE extension (Tcl Apple Events); TclAE also allows a much lower-level interface to Apple events. However, I'm not able to compile TclAE to run in 64-bit mode; my guess is that it hooks too deeply into Carbon to work in 64-bit mode as is. So unless TclAE is updated, it won't be a viable solution moving forward. I had one more question. When trying to run a very basic example of "do script" against an AppleScript-enabled version of Wish (Tk-Carbon-based) like so: tell app "Wish" do script "puts foo" end tell I get this cryptic error: Wish got an error: AEDoScriptHandler: invalid script type 'txtu', must be 'alis' or 'TEXT' Any idea what this means? I'm not familiar with the old-school Carbon type-and-creator codes. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptHi Kevin,
On Mon, Aug 17, 2009 at 16:20, Kevin Walzer<kw@...> wrote: > I had one more question. When trying to run a very basic example of "do > script" against an AppleScript-enabled version of Wish > (Tk-Carbon-based) like so: > > tell app "Wish" > do script "puts foo" > end tell > > I get this cryptic error: > > Wish got an error: AEDoScriptHandler: invalid script type 'txtu', must > be 'alis' or 'TEXT' don't have time to look into the various other AS issues/questions ATM unfortunately but I do know how to fix this one, it is caused by AppleScript 2.0 switching to unicode text (in Leopard IIRC), and because tkMacOSXHLEvents.c is checking specifically if 'TEXT' (i.e. text in the carbon system encoding, usually mac roman) was passed in, the automatic coercion handlers between unicode text 'txtu' and system encoding do not kick in. This is easy to fix, will try to get this committed soon. as far as a replacement for 'aete' is concerned, we will definitely need a .sdef for TkAqua Cocoa to replicate the old functionality, contributions by you or Philip much appreciated... Cheers, Daniel ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 8/17/09 10:30 AM, Daniel A. Steffen wrote:
> > don't have time to look into the various other AS issues/questions ATM > unfortunately but I do know how to fix this one, it is caused by > AppleScript 2.0 switching to unicode text (in Leopard IIRC), and > because tkMacOSXHLEvents.c is checking specifically if 'TEXT' (i.e. > text in the carbon system encoding, usually mac roman) was passed in, > the automatic coercion handlers between unicode text 'txtu' and system > encoding do not kick in. This is easy to fix, will try to get this > committed soon. OK, thanks! > > as far as a replacement for 'aete' is concerned, we will definitely > need a .sdef for TkAqua Cocoa to replicate the old functionality, > contributions by you or Philip much appreciated... I was just playing around with this today, using SDEF Editor--I just extracted the .rsrc file from an older build of Wish and converted it. Would the attached work? I'm also quite happy to modify it if necessary. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd"> <dictionary title="Wish"> <suite name="Required Suite" code="reqd" description="Events that every application should support"/> <suite name="Wish Suite" code="WIsH" description="Events for the Wish application"> <command name="do script" code="miscdosc" description="Execute a Tcl script"> <direct-parameter description="Script to execute" type="text"/> <result description="Result" type="text"/> </command> </suite> </dictionary> ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn Mon, Aug 17, 2009 at 16:35, Kevin Walzer<kw@...> wrote:
> On 8/17/09 10:30 AM, Daniel A. Steffen wrote: >> don't have time to look into the various other AS issues/questions ATM >> unfortunately but I do know how to fix this one, it is caused by >> AppleScript 2.0 switching to unicode text (in Leopard IIRC), and >> because tkMacOSXHLEvents.c is checking specifically if 'TEXT' (i.e. >> text in the carbon system encoding, usually mac roman) was passed in, >> the automatic coercion handlers between unicode text 'txtu' and system >> encoding do not kick in. This is easy to fix, will try to get this >> committed soon. patch attached that fixes this for me and also fixes the other option of passing an alias to a script file, i.e. tell application "Wish" do script ("HD:some:path:to:x.tcl" as alias) end tell please verify >> as far as a replacement for 'aete' is concerned, we will definitely >> need a .sdef for TkAqua Cocoa to replicate the old functionality, >> contributions by you or Philip much appreciated... > > I was just playing around with this today, using SDEF Editor--I just > extracted the .rsrc file from an older build of Wish and converted it. Would > the attached work? yup, seems to work fine, thanks, integrated in patch Cheers, Daniel ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptHi Daniel,
On 8/17/09 12:48 PM, Daniel A. Steffen wrote: > patch attached that fixes this for me and also fixes the other option > of passing an alias to a script file, i.e. > tell application "Wish" > do script ("HD:some:path:to:x.tcl" as alias) > end tell > > please verify Patch applied OK and Tk builds fine, I see the sdef in the app bundle. Not sure about the output of this script: tell application "/Users/kevin/tcl-tk-86/embedded/Applications/Utilities/Wish.app" activate do script "info patchlevel" quit end tell The output of this is "missing value." Not what I expected. Am I doing something wrong in sending the Tcl command? > >>> as far as a replacement for 'aete' is concerned, we will definitely >>> need a .sdef for TkAqua Cocoa to replicate the old functionality, >>> contributions by you or Philip much appreciated... >> I was just playing around with this today, using SDEF Editor--I just >> extracted the .rsrc file from an older build of Wish and converted it. Would >> the attached work? > > yup, seems to work fine, thanks, integrated in patch > I see the sdef in the app bundle, thanks. I do notice this blows away the previous Cocoa-standard dictionary (standard suite and text suite)--is this a problem? Not sure how relevant these things are to a Tk app, especially since basic Apple events are supported in TkMacOSXHLEvents.c. Once this is final, can you please commit this to de-carbon-85 as well? Thanks, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptHi Kevin,
On Tue, Aug 18, 2009 at 00:56, Kevin Walzer<kw@...> wrote: > Patch applied OK and Tk builds fine, I see the sdef in the app bundle. Not > sure about the output of this script: > > tell application > "/Users/kevin/tcl-tk-86/embedded/Applications/Utilities/Wish.app" > activate > do script "info patchlevel" > quit > end tell > > The output of this is "missing value." Not what I expected. Am I doing > something wrong in sending the Tcl command? works fine for me with HEAD. You won't get any output this way BTW, but the following does return the correct patchlevel string for me in Script Editor tell application "/path/to/embedded/Wish.app" do script "info patchlevel" end tell > I see the sdef in the app bundle, thanks. I do notice this blows away the > previous Cocoa-standard dictionary (standard suite and text suite)--is this > a problem? Not sure how relevant these things are to a Tk app, especially > since basic Apple events are supported in TkMacOSXHLEvents.c. right, the 'reqd' doesn't seem to pull in the required suite description by itself like it used to in an 'aete' :-( Attached an updated .sdef that adapts the only three relevant commands (odoc, pdoc & quit) from the standard sdef /System/Library/ScriptingDefinitions/CocoaStandard.sdef to have the params/results that Wish understands. the other AppleEvents Wish understands (oapp, rapp, pref) don't have entries in the standard sdef so presumably aren't usually listed in the standard AS dictionaries... It is in fact desirable that the default Cocoa standard suite and text suite commands no longer appear, Wish doesn't understand any of these anyway, there is no standard NSDocument or NSText-based structure in Tk that would allow Cocoa Scripting to do its magic... > Once this is final, can you please commit this to de-carbon-85 as well? already done in fact (for ease of testing) along with the other recent changes to notifier and NSView drawing, c.f. git log. Will commit to CVS HEAD once I get confirmation that all this fixes the aMSN issues and doesn't introduce any new breakage. Cheers, Daniel ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptHi Daniel,
On 8/17/09 7:49 PM, Daniel A. Steffen wrote: > > are you sure ScriptEditor is talking to the right app? that script > works fine for me with HEAD. > You won't get any output this way BTW, but the following does return > the correct patchlevel string for me in Script Editor > > tell application "/path/to/embedded/Wish.app" > do script "info patchlevel" > end tell Not sure what I was doing wrong before, but a fresh build of Wish using the latest commits to de-carbon-85 works great. Thanks. > >> I see the sdef in the app bundle, thanks. I do notice this blows away the >> previous Cocoa-standard dictionary (standard suite and text suite)--is this >> a problem? Not sure how relevant these things are to a Tk app, especially >> since basic Apple events are supported in TkMacOSXHLEvents.c. > > right, the 'reqd' doesn't seem to pull in the required suite > description by itself like it used to in an 'aete' :-( > Attached an updated .sdef that adapts the only three relevant commands > (odoc, pdoc& quit) from the standard sdef > /System/Library/ScriptingDefinitions/CocoaStandard.sdef > to have the params/results that Wish understands. > > the other AppleEvents Wish understands (oapp, rapp, pref) don't have > entries in the standard sdef so presumably aren't usually listed in > the standard AS dictionaries... > > It is in fact desirable that the default Cocoa standard suite and text > suite commands no longer appear, Wish doesn't understand any of these > anyway, there is no standard NSDocument or NSText-based structure in > Tk that would allow Cocoa Scripting to do its magic... > >> Once this is final, can you please commit this to de-carbon-85 as well? > > already done in fact (for ease of testing) along with the other recent > changes to notifier and NSView drawing, c.f. git log. > Will commit to CVS HEAD once I get confirmation that all this fixes > the aMSN issues and doesn't introduce any new breakage. > Thanks, Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
|
|
Re: Making a Tk app scriptable via AppleScriptOn 2009-08-17, at 07:20:40, Kevin Walzer wrote:
>> I hope that's what you are using. > For CVS HEAD, yes. I'm back to using Daniel Steffen's backport of Tk- > Cocoa to 8.5, hosted at Github. For the Cocoa bits, it's identical > to 8.6 for testing purposes. Ok and thanks again, it's a lot more fun. > I had one more question. When trying to run a very basic example of > "do script" against an AppleScript-enabled version of Wish (Tk- > Carbon-based) like so: > > tell app "Wish" > do script "puts foo" > end tell > > I get this cryptic error: > > Wish got an error: AEDoScriptHandler: invalid script type 'txtu', > must be 'alis' or 'TEXT' > > Any idea what this means? I'm not familiar with the old-school > Carbon type-and-creator codes. I see from following discussions that the basic problem has been solved. Philip Aker echo astwta@...@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tcl-mac mailing list tcl-mac@... https://lists.sourceforge.net/lists/listinfo/tcl-mac |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |