f



Tcl/Tk problems on Mac OS X

The program I asked about is rather long, but here is a stripped down version
consisting of just the GUI. Under GNU/Linux it creates the non-popup windows,
and sets up the menus. With the exception of "Quit", the commands have been
removed. My friend with the Mac says that when he tries to run it it fails
in exactly the same way as the full program, that is, he sees some pastel-colored
rectangles and then it hangs.

encoding system utf-8
package require msgcat
proc _ {s} {return [::msgcat::mc $s]};	# Define shorthand for gettext

# Use a virtual event for the right mouse button and
# define it differently on the Mac. 
switch $tcl_platform(platform) {
    unix - windows {
	event add <<B3>> <ButtonPress-3>
    } 
    macintosh {
	event add <<B3>> <Control-ButtonPress-1>
    }
}

set MainFontSize 12;
set MainFontFamily Courier;
font create MainFont -family $MainFontFamily -size $MainFontSize;
font create BalloonHelpFont  -family lucida -size 13 -weight normal;

set ColorSpecs(cdb,-bg)	 		"\#DDDDFF";
set ColorSpecs(cdt,-bg)	 		"\#e9c4dc";
set ColorSpecs(cdx,-bg)	 		"\#e9c4dc";
set ColorSpecs(gen,-bg)	 		"\#c36176";
set ColorSpecs(.menubar,-bg)	 	"\#c36176";
set ColorSpecs(.menubar,-fg)		"\#fee4a9";
set ColorSpecs(.msg,-bg) 		"\#e9c4dc";
set ColorSpecs(.msg,-fg) 		"\#000000";
set ColorSpecs(txt,-bg)	 		"\#FFDDDD";
set ColorSpecs(tr,-bg)	 		"\#DDDDFF";
set ColorSpecs(.ipaentry,-bg)		"\#FFFFFF";
set ColorSpecs(.ipaentry,-fg)		"\#000000";
set ColorSpecs(ipaheadings,-bg)		"\#09ffb2";

proc ShutDown {} {
    exit 0;
}

proc SetBoth {a b} {
    .cf.sbarleft  set $a $b;
    .cf.sbarright set $a $b;
}

proc YViewBoth {args} {
    set ac [llength $args];
    set a  [lindex $args 0]
    set b  [lindex $args 1]
    if {$ac == 3} {
	set c  [lindex $args 2]
	.cf.inp yview $a $b $c;
	.cf.out yview $a $b $c;
    } else {
	.cf.inp yview $a $b;
	.cf.out yview $a $b;
    }
}

set MainWidth 30;
set MainHeight 10;
frame .top
set m [menu .menubar -tearoff 0  -bg $ColorSpecs(.menubar,-bg)\
	   -fg $ColorSpecs(.menubar,-fg) -font MainFont]
$m add cascade -label [_ "File"]   -menu [menu $m.file];
$m.file add command -label [_ "Load Input Text"] -command LoadInputText
$m.file add command -label [_ "Save Output Text"] -command SaveOutput
$m.file add separator
$m.file add command -label [_ "Read Transliteration"] -command ReadTransliterationFile;
$m.file add command -label [_ "Save Transliteration"] -command SaveTransliteration
$m.file add separator
$m.file add command -label [_ "Quit"]  -command ShutDown
$m add command -label [_ "Transliterate"]  -command Transliterate;
$m add command -label [_ "Clear Input"]  -command ClearInputText;
$m add command -label [_ "Clear Transliteration"]  -command ClearTransliteration;
$m add cascade -label [_ "Configure"]   -menu [menu $m.configure];
$m.configure add command -label [_ "Disable Irritating Balloon Help"] -command ToggleBalloonHelp;
$m add cascade -label [_ "Help"]   -menu [menu $m.help];
$m.help add command -label [_ "Bug Reports"] -command BugReports;
$m.help add command -label [_ "How To Use This Program"] -command HowTo;
$m.help add command -label [_ "Key Bindings"] -command DescribeKeyBindings;
$m.help add command -label [_ "License"] -command ShowGPL;
.. configure -menu .menubar

text .msg -bg $ColorSpecs(.msg,-bg) -fg $ColorSpecs(.msg,-fg) -height 2\
    -relief sunken -font MainFont
pack .msg -side top -expand 0 -fill x;

frame .cf
scrollbar .cf.sbarleft  -command {YViewBoth} -troughcolor $ColorSpecs(tr,-bg) -bg $ColorSpecs(tr,-bg) -activebackground $ColorSpecs(tr,-bg);
scrollbar .cf.sbarright -command {YViewBoth} -troughcolor $ColorSpecs(tr,-bg) -bg $ColorSpecs(tr,-bg) -activebackground $ColorSpecs(tr,-bg);
text .cf.inp  -yscrollcommand {SetBoth} -width $MainWidth -height $MainHeight  -bg $ColorSpecs(tr,-bg);
text .cf.out  -yscrollcommand {SetBoth} -width $MainWidth -height $MainHeight -bg $ColorSpecs(tr,-bg);
pack .cf -expand 1 -fill both
pack .cf.sbarleft  -side left    -expand 0 -fill y
pack .cf.sbarright -side right   -expand 0 -fill y
pack .cf.inp     -side left    -expand 1 -fill both
pack .cf.out    -side right   -expand 1 -fill both

frame .tif 
frame .tof 
text .tif.inp -yscrollcommand {.tif.isbar set}  -height 10 -bg $ColorSpecs(txt,-bg);
text .tof.out -yscrollcommand {.tof.osbar set}  -height 10 -bg $ColorSpecs(txt,-bg);
scrollbar .tif.isbar -command {.tif.inp yview}  -troughcolor $ColorSpecs(txt,-bg) -bg $ColorSpecs(txt,-bg)  -activebackground $ColorSpecs(txt,-bg);
scrollbar .tof.osbar -command {.tof.out yview}  -troughcolor $ColorSpecs(txt,-bg) -bg $ColorSpecs(txt,-bg)  -activebackground $ColorSpecs(txt,-bg);
pack .tif.isbar -side right  -expand 0 -fill y
pack .tif.inp -side left -expand 1 -fill both
pack .tof.osbar -side right -expand 0 -fill y
pack .tof.out -side left -expand 1 -fill both

pack .cf  -in .top -side top
pack .tof -in .top -side bottom -expand 1 -fill both;
pack .tif -in .top -side bottom -expand 1 -fill both;
pack .top -expand 1 -fill both

..cf.inp configure -state normal
..cf.out configure -state normal
..tif.inp configure -state disabled
..tof.out configure -state disabled

after idle {
    update idletasks
    set w [winfo reqwidth  .]
    set h [winfo reqheight .]
    wm minsize  . $w $h
}
-- 
Bill Poser, Linguistics, University of Pennsylvania
http://www.ling.upenn.edu/~wjposer/ billposer@alum.mit.edu
0
wjposer (71)
4/17/2005 10:29:36 PM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

6 Replies
747 Views

Similar Articles

[PageSpeed] 32

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

William J Poser wrote:
| The program I asked about is rather long, but here is a stripped down
version
| consisting of just the GUI. Under GNU/Linux it creates the non-popup
windows,
| and sets up the menus. With the exception of "Quit", the commands have
been
| removed. My friend with the Mac says that when he tries to run it it fails
| in exactly the same way as the full program, that is, he sees some
pastel-colored
| rectangles and then it hangs.
|

Yes, that's what I see too. What am I supposed to see? Is there a screen
shot that you can point me to on the web? What's the name of this
application and what does it do?

Looking on the code, I don't see a top-level window defined anywhere.
Are each of these frames supposed to be individual windows? Wish is
lumping all of these things together into a single window.

I did try typing into a couple of the frames--that seems to work.

Basically, from what I can tell of the code, it defines a bunch of
frames with different colors, plus a menubar. That's also what we seem
to be getting. So, an explanation of what this application is trying to
do would be helpful.


- --
Cheers,

Kevin Walzer, PhD
WordTech Software--Open Source Applications and Packages for OS X
http://www.wordtech-software.com
http://www.smallbizmac.com
http://www.kevin-walzer.com
mailto:sw@wordtech-software.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCYvHTJmdQs+6YVcoRAuZjAJwLACzwDyXE7D/U/YIopOhSUnc1/gCfRbZ/
tchIH9nc+7WiBOjrHrZ2484=
=9dMO
-----END PGP SIGNATURE-----
0
sw3259 (273)
4/17/2005 11:31:32 PM
Right, the code I included just sets up a bunch of windows and a menu.
The functionality all results from entering text in the top two windows
and executing commands, and I omitted all that stuff. The problem that
my friend is having on the Mac is that, after a long time and a lot of 
CPU activity, he just gets a sort of coarse representation of the windows.
You can't see the menu buttons, much less invoke them, and you can't
enter text where you should be able to. I've put the screenshot he sent me
(for some reason as a PDF - only 30K so don't be shy) at:

http://www.cis.upenn.edu/~wjposer/xl00.pdf

It now appears that the problem is that he hasn't got X11 installed.
Another friend, who has X11 running under Mac OS 10.3, is having no problem
running my tcl/tk programs. I am curious, though, why one gets just
this much functionality without X11.


Bill

-- 
Bill Poser, Linguistics, University of Pennsylvania
http://www.ling.upenn.edu/~wjposer/ billposer@alum.mit.edu
0
wjposer (71)
4/18/2005 3:11:43 AM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

William J Poser wrote:
| Right, the code I included just sets up a bunch of windows and a menu.
| The functionality all results from entering text in the top two windows
| and executing commands, and I omitted all that stuff. The problem that
| my friend is having on the Mac is that, after a long time and a lot of
| CPU activity, he just gets a sort of coarse representation of the windows.
| You can't see the menu buttons, much less invoke them, and you can't
| enter text where you should be able to. I've put the screenshot he sent me
| (for some reason as a PDF - only 30K so don't be shy) at:
|
| http://www.cis.upenn.edu/~wjposer/xl00.pdf
|
| It now appears that the problem is that he hasn't got X11 installed.
| Another friend, who has X11 running under Mac OS 10.3, is having no
problem
| running my tcl/tk programs. I am curious, though, why one gets just
| this much functionality without X11.
|
|
| Bill
|
Bill,

Your description wasn't very helpful--sorry about that--so I just
tracked down the program in question via Google and downloaded the whole
thing. It seems to run fine in the Aqua environment. I don't know what
trouble your friend was having, nor do I know why the GUI code you sent
me yielded the funny-looking color pastiche. Caveat: I ran the program
by cd'ing to the  folder where it was untarred and just typed "wish
redet.tcl" in the console.

Here's a screen shot:

http://www.wordtech-software.com/redet.jpg

Basically, if users run "wish /path/to/redet.tcl," I think they should
be fine.

A couple of other suggestions: since this is pure Tcl, have you thought
about wrapping it as a starkit? Those run fine on the Mac and they can
be double-clicked.

Finally, I've put together a tutorial on packaging Tcl apps on the Mac
with a shiny icon:

http://www.wordtech-software.com/tcl-bundle-tutorial.html

Hope this helps.

- --
Cheers,

Kevin Walzer, PhD
WordTech Software--Open Source Applications and Packages for OS X
http://www.wordtech-software.com
http://www.smallbizmac.com
http://www.kevin-walzer.com
mailto:sw@wordtech-software.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCYy9nJmdQs+6YVcoRAijOAJ9hp6JLkLGmJASgOBUmuo5aEp2jHQCdF4yw
t5JFkwIO/NwvhxQcmZ9UPNc=
=k29t
-----END PGP SIGNATURE-----
0
sw3259 (273)
4/18/2005 3:54:16 AM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

William J Poser wrote:
| Right, the code I included just sets up a bunch of windows and a menu.
| The functionality all results from entering text in the top two windows
| and executing commands, and I omitted all that stuff. The problem that
| my friend is having on the Mac is that, after a long time and a lot of
| CPU activity, he just gets a sort of coarse representation of the windows.
| You can't see the menu buttons, much less invoke them, and you can't
| enter text where you should be able to. I've put the screenshot he sent me
| (for some reason as a PDF - only 30K so don't be shy) at:
|
| http://www.cis.upenn.edu/~wjposer/xl00.pdf
|
| It now appears that the problem is that he hasn't got X11 installed.
| Another friend, who has X11 running under Mac OS 10.3, is having no
problem
| running my tcl/tk programs. I am curious, though, why one gets just
| this much functionality without X11.
|
|
| Bill
|
PS: I noted that you can't browse the HTML help as "dillo" is available
only under X11. The Mac-native command for launching a browser is
"open," which will launch the user's default browser.


- --
Cheers,

Kevin Walzer, PhD
WordTech Software--Open Source Applications and Packages for OS X
http://www.wordtech-software.com
http://www.smallbizmac.com
http://www.kevin-walzer.com
mailto:sw@wordtech-software.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCYzRvJmdQs+6YVcoRAv2TAJ41VbsiVIt7M0iTzAwJZ8QqU+X8PwCfZBad
IPeWS0CcbaOZE8fcdxrxqZQ=
=CDYR
-----END PGP SIGNATURE-----
0
sw3259 (273)
4/18/2005 4:15:44 AM
Many thanks for the various pointers. I have heard of Starkits and in fact
downloaded the necessary files a couple days ago but haven't yet learned
how to make them. 

 Actually, the program I was asking about
is not redet. That is, a similar issue arises with redet, in that some people
have had trouble getting it to work on Macs, but the  code I gave is from something
else that I haven't distributed. It is something that I wrote yesterday in response to a
friend's request. When I sent it to him, he encountered the problem I described. 

What seems to be going on is that my tcl/tk programs run on the Mac if X11 is installed,
but do not run properly using the native Aqua implementation.  Did you (Kevin Walzer)
run redet successfully without X11?

Bill

-- 
Bill Poser, Linguistics, University of Pennsylvania
http://www.ling.upenn.edu/~wjposer/ billposer@alum.mit.edu
0
wjposer (71)
4/18/2005 5:41:37 AM
Hello Bill, Kevin, et al.

I have run the script Bill posted at the start of this thread on my MacOS X 
10.2.8 system (without X11), using Tcl/Tk 8.4.9, about which I can make the 
following observations.

I double-click the Wish Shell icon and use the "Source" menu command to 
source the script: the script appears to hang, as described by Bill's 
friend.

I launch the script and Wish together by typing "wish filename" in the 
Terminal application: the script appears to run OK, after a hiccough.  When 
it first appears, the main window shimmers, as if it is constantly re-sizing 
itself.  If I manually catch hold of the re-size handle and adjust its size 
slightly, the shimmer ceases.

In the first case, it is noticeable that the main window is also shimmering, 
but it is not possible to adjust the size manually, hence the application 
remains hung.

Running the script on Windows XP, I can see that the scrollbars are arranged 
differently, and that some extra menu items are present.

I will send these observations to mac-tcl list, in the hope of obtaining 
further insight.

If I get more time to investigate, I will look more closely at the packing 
of the scrollbars.

Best wishes,
Alastair Davies


0
4/18/2005 7:59:51 AM
Reply: