f



tk::mac::ShowPreferences in Tcl/Tk Linux version?

When I define a procedure tk::mac::ShowPreferences working on a Mac 
Leopard Snow with the Mac version of  ActiveState Tcl/Tk I can use the 
Mac Preference menu without problems. Great work!

But normally I work on a Unix platform compiling my program with 
tclkit-darwin-aqua for a Mac Platform. And defining a procedure

proc ::tk::mac::ShowPreferences {} {
	tk_messageBox -type ok -icon info -default ok \
	-title "Preferences" \
	-message "Here will be a Preference Dialog!"	
}

and compiling it for aqua will fail on the Mac.

Probably I have to add the tk::mac namespace to my Linux Tcl/Tk. But the 
package tclAE depends on a Mac TK, true? Is there any other way to add a 
library which will be enabling tk::mac::ShowPreferences on my Linux host?



0
Zbigniew
2/26/2010 8:38:15 AM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

3 Replies
846 Views

Similar Articles

[PageSpeed] 42

On 2/26/10 3:38 AM, Zbigniew Diaczyszyn wrote:
> When I define a procedure tk::mac::ShowPreferences working on a Mac
> Leopard Snow with the Mac version of ActiveState Tcl/Tk I can use the
> Mac Preference menu without problems. Great work!
>
> But normally I work on a Unix platform compiling my program with
> tclkit-darwin-aqua for a Mac Platform. And defining a procedure
>
> proc ::tk::mac::ShowPreferences {} {
> tk_messageBox -type ok -icon info -default ok \
> -title "Preferences" \
> -message "Here will be a Preference Dialog!"
> }
>
> and compiling it for aqua will fail on the Mac.
>
> Probably I have to add the tk::mac namespace to my Linux Tcl/Tk. But the
> package tclAE depends on a Mac TK, true? Is there any other way to add a
> library which will be enabling tk::mac::ShowPreferences on my Linux host?
>
>
>
The preferences menu is a system-provided menu on the Mac. The 
::tk::mac::ShowPreferences procedure is Mac-only, as it hooks into Apple 
Events. Your best bet is probably to wrap the procedure in a Tk 
windowing system call to avoid errors on non-Mac platforms, i.e.

if [tk windowingsystem] == "aqua"] {

	 proc ::tk::mac::ShowPreferences {} {

.....
}

}


HTH, Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
0
Kevin
2/26/2010 3:21:13 PM
Kevin Walzer schrieb:

> The preferences menu is a system-provided menu on the Mac. The 
> ::tk::mac::ShowPreferences procedure is Mac-only, as it hooks into Apple 
> Events. [...]

So there is no other way then to compile my program with 
tclkit-darwin-aqua on a Mac? There aren't any libraries I could add to 
my linux hosted Tcl/Tk? For example like:

if [tk windowingsystem] == "aqua"] {

      package require mac_events

      proc ::tk::mac::ShowPreferences {} {

......
}

If you do often versioning it is much more convenient to sit before your 
    terminal and just do some bash scripting: make_aqua; make_win; 
make_linux


0
Zbigniew
2/26/2010 7:58:53 PM
I had not thought through the issue: The if condition tells the Linux 
Tcl/Tk at runtime not to compile this procedure and therefore the 
unknown namespace is no problem. And if the programm is executed on a 
Mac then the procedure will be successfully compiled because wish on the 
Mac knows the namespace.

Thank you, Kevin, for the hint. I compiled the program on a Linux host 
with tclkit-darwin-aqua ... and I've got the preferences in the menu :-)))

0
Zbigniew
2/26/2010 10:04:20 PM
Reply: