Motherboard Forums


Reply
Thread Tools Display Modes

Tk/OSX question

 
 





















Greg Shenaut
Guest
Posts: n/a

 
      06-21-2004, 12:16 AM


I'm trying to make a Tk script on OS/X, and I've noticed that when I
start the script from a terminal window, it starts up but its windows all
stay behind the terminal window unless you click on them.

I decided to add the lines

catch {exec osascript -e {tell app "Wish Shell" to activate} &}
sleep 2000

where "sleep" is a delay using vwait.

This works, but it seems pretty kludgy. Is there a more reasonable
way to do this?

TIA

Greg Shenaut

PS If I start the Tk script from an xterm window, it starts in front
even without the "activate" command.
 
Reply With Quote
 
SM Ryan
Guest
Posts: n/a

 
      06-21-2004, 01:03 AM
(Greg Shenaut) wrote:
# I'm trying to make a Tk script on OS/X, and I've noticed that when I
# start the script from a terminal window, it starts up but its windows all
# stay behind the terminal window unless you click on them.

All it needs is to convince the powers-that-be to add a SetFrontProcess
call to oappHandler and rappHandler. Good luck trying to get them their
butts moving.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
The whole world's against us.
 
Reply With Quote
 
lusol
Guest
Posts: n/a

 
      06-21-2004, 02:18 PM
In comp.sys.mac.system Greg Shenaut <> wrote:
> I'm trying to make a Tk script on OS/X, and I've noticed that when I
> start the script from a terminal window, it starts up but its windows all
> stay behind the terminal window unless you click on them.


> I decided to add the lines


> catch {exec osascript -e {tell app "Wish Shell" to activate} &}
> sleep 2000


> where "sleep" is a delay using vwait.


> This works, but it seems pretty kludgy. Is there a more reasonable
> way to do this?


> TIA


> Greg Shenaut


> PS If I start the Tk script from an xterm window, it starts in front
> even without the "activate" command.


Would you please send me your program (or stripped down version of said) and
any invoking script? I cannot seem to reproduce your problem .... then maybe
I can be of assistance.

Steve

--
@_=map{eval"100${_}"}split/!/,'/5!*2!+$]!/10+$]';use Tk;$m=tkinit;$t='just an'.
'other perl hacker';$z='createText';$c=$m->Canvas(-wi,$_[1],-he,25)->grid;$c->$
z(@_[2,3],-te,$t,-fi,'gray50');$c->$z($_[2]-$],$_[3]-$],-te,$t);$m->bind('<En'.
'ter>',sub{$y=int(rand($m->screenheight));$m->geometry("+$y+$y")});MainLoop;
 
Reply With Quote
 
Greg Shenaut
Guest
Posts: n/a

 
      06-21-2004, 09:55 PM
lusol <> exponit:
> Would you please send me your program (or stripped down version of said) and
> any invoking script? I cannot seem to reproduce your problem .... then maybe
> I can be of assistance.


Well, the easiest way to reproduce it is to move your Terminal window to the
upper-left corner of your screen and type "wish<RETURN>". The default Tk windows
will be underneath.

However, if you want more, I have been playing with this using the script below.
Please excuse the naivete of the Tk code, as I said, I am just learning. (This
version has the osascript call in it, so comment it out to see the effect.)

Greg Shenaut

#!/bin/sh
# \
exec wish "$0" "$*"

# length of time a warning pop-up stays up
set wpoptime 2000

# delay while vwaiting so program can respond to events
proc sleep ms {
global sleeping
set sleeping 1
after $ms {unset sleeping}
vwait sleeping
}

# generate a symbol to use for pop-up warning windows
set genwcnt -1
proc genw {} {
global genwcnt
incr genwcnt
return "genw$genwcnt"
}

# popup a warning message
proc wpopup x {
global genwcnt wpoptime
if { $genwcnt < 0 } {
set prev ""
} else {
set prev "genw$genwcnt"
}
set w [genw]
toplevel .$w
wm geometry .$w 200x100
wm title .$w "WARNING"
text .$w.t -wrap word -bg yellow -fg red -highlightbackground red -highlightcolor green
.$w.t insert end "$x"
pack .$w.t
raise .$w .$prev
after $wpoptime "destroy .$w; incr genwcnt -1"
}

# wait for all popups to close
proc genwait {} {
global genwcnt
while {$genwcnt >= 0} { vwait genwcnt }
}

set test_msg {
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
Now is the time for all good men to come to the aid of the party.
The quick brown fox jumped over the lazy rabbit.
}

# set up the main window
wm geometry . 400x400
wm title . "Trying to get in front via applescript"
text .t -wrap word -yscrollcommand ".s set"
scrollbar .s -command ".t yview"
..t insert end [exec fmt -30 <<$test_msg]
..t insert end $test_msg
pack .s -side right -fill y
pack .t -side left
raise .
# focus -force .

# put me in the foreground
catch {exec osascript -e {tell app "Wish Shell" to activate} &}
sleep 2000

wpopup "this is a test"
sleep 1000
wpopup "this is the second test"
genwait

wpopup "second time: this is a test"
sleep 1000
wpopup "second time: this is the second test"
genwait

sleep 4000
exit
 
Reply With Quote
 
Mike Hall
Guest
Posts: n/a

 
      06-22-2004, 12:24 AM


Adding this in your Tk script doesn't work for you?

raise .



 
Reply With Quote
 
Greg Shenaut
Guest
Posts: n/a

 
      06-22-2004, 01:04 AM
Mike Hall <> exponit:
>
>
> Adding this in your Tk script doesn't work for you?
>
> raise .


No, nor does focus -force .

Greg Shenaut
 
Reply With Quote
 
Donal K. Fellows
Guest
Posts: n/a

 
      06-22-2004, 09:42 AM
Greg Shenaut wrote:
> I'm trying to make a Tk script on OS/X, and I've noticed that when I
> start the script from a terminal window, it starts up but its windows all
> stay behind the terminal window unless you click on them.


Does the [raise] command not help? For example:

raise .

Failing that, [focus] (possibly with the -force option) might help too.

Donal.
 
Reply With Quote
 
lusol
Guest
Posts: n/a

 
      06-23-2004, 04:53 PM
Greg Shenaut <> wrote:
> lusol <> exponit:
> > Would you please send me your program (or stripped down version of said) and
> > any invoking script? I cannot seem to reproduce your problem .... then maybe
> > I can be of assistance.


> Well, the easiest way to reproduce it is to move your Terminal window to the
> upper-left corner of your screen and type "wish<RETURN>". The default Tk windows
> will be underneath.


Hmm, still cannot reproduce this, using 3 different accounts on 2 different machines.

What OS version? What Tcl/Tk version? Why are you not using X11.app rather than Terminal.app?
How are you setting DISPLAY for Terminal.app to work?

 
Reply With Quote
 
Greg Shenaut
Guest
Posts: n/a

 
      06-23-2004, 10:51 PM
lusol <> exponit:
> Greg Shenaut <> wrote:
>> lusol <> exponit:
>> > Would you please send me your program (or stripped down version of said) and
>> > any invoking script? I cannot seem to reproduce your problem .... then maybe
>> > I can be of assistance.

>
>> Well, the easiest way to reproduce it is to move your Terminal window to the
>> upper-left corner of your screen and type "wish<RETURN>". The default Tk windows
>> will be underneath.

>
> Hmm, still cannot reproduce this, using 3 different accounts on 2 different machines.
>
> What OS version? What Tcl/Tk version? Why are you not using X11.app rather than Terminal.app?
> How are you setting DISPLAY for Terminal.app to work?


OS/X 10.3.4

Tcl/Tk 8.4

I do use X11.app, and I already stated that if I run my script from an xterm window, then
everything works normally.

I am testing under Terminal because I want the program to work for people who don't use X11.

DISPLAY gets set to :0.0 in /etc/profile if it isn't already set, but it doesn't matter
whether it is set or not: wish operates the same.

BTW, I have come to suspect this is an OS/X problem more than a TclTk problem, because if
I run (native) mozilla-bin from a terminal window, it stays behind the terminal window too.

Greg Shenaut
 
Reply With Quote
 
Steve Lidie
Guest
Posts: n/a

 
      06-24-2004, 12:45 AM
Greg Shenaut <> wrote:
> lusol <> exponit:
>> Greg Shenaut <> wrote:
>>> lusol <> exponit:
>>> > Would you please send me your program (or stripped down version of said) and
>>> > any invoking script? I cannot seem to reproduce your problem .... then maybe
>>> > I can be of assistance.

>>
>>> Well, the easiest way to reproduce it is to move your Terminal window to the
>>> upper-left corner of your screen and type "wish<RETURN>". The default Tk windows
>>> will be underneath.

>>
>> Hmm, still cannot reproduce this, using 3 different accounts on 2 different machines.
>>
>> What OS version? What Tcl/Tk version? Why are you not using X11.app rather than Terminal.app?
>> How are you setting DISPLAY for Terminal.app to work?

>
> OS/X 10.3.4

ditto

>
> Tcl/Tk 8.4

will verify my version

>
> I do use X11.app, and I already stated that if I run my script from an xterm window, then
> everything works normally.

yes, i heard - your code works for me in xterm or Terminal!

>
> I am testing under Terminal because I want the program to work for people who don't use X11.
>
> DISPLAY gets set to :0.0 in /etc/profile if it isn't already set, but it doesn't matter
> whether it is set or not: wish operates the same.

but you cannot "do X11" from Terminal.app w/o some X11 server running. What X server and window manager are you using?


>
> BTW, I have come to suspect this is an OS/X problem more than a TclTk problem, because if
> I run (native) mozilla-bin from a terminal window, it stays behind the terminal window too.
>
> Greg Shenaut

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: NIC question & troubleshooting ps56k Dell 0 01-30-2009 04:09 PM
K7S5A: Yellow question marks in XP SP2 rhino Elitegroup 1 02-21-2007 06:40 PM
ipfw question & portscan question Tim McNamara Apple 2 01-27-2004 07:20 PM
Possibly *STOOOOPID* threads question (9.1/Classic/Pre-X) Don Bruder Apple 16 01-12-2004 08:56 AM
Re: File Sharing [over internet] Question Michelle Steiner Apple 1 10-30-2003 07:41 PM


All times are GMT. The time now is 10:22 AM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43