Google Answers Logo
View Question
 
Q: Help with a simple tcl/tk graphical widget question ( No Answer,   7 Comments )
Question  
Subject: Help with a simple tcl/tk graphical widget question
Category: Computers
Asked by: blackrock-ga
List Price: $5.00
Posted: 04 Feb 2005 08:04 PST
Expires: 06 Mar 2005 08:04 PST
Question ID: 468719
This question is asking for help making graphical widgets appear in
tcl/tk, without using the wish shell.

I am brand-new to Tcl/Tk and am attempting to create a very simple GUI
application.  I've been able to start my scripts with #!/usr/bin/wish
to write simple applications that use the Tk widgets.  However, for my
"real" application I will be running inside an EDA tool's tcl shell,
not within wish.

For debugging, I switched from #!/usr/bin/wish to #!/usr/bin/tcl,
because this environment is more similar to my final environment.  I
manually load the libtk8.3.so, but I have been unable to make any
graphical elements appear.  My sample code is attached below.

The successful answer to my question will let me know what is missing
from the below, and provide sample code, that will cause the widgets
to appear from within tcl.

#!/usr/bin/tcl -f

load libtk8.3.so
package require Tk

toplevel .buttons
wm title .buttons "Buttons"

# just a single button
button .buttons.1 -text "Hello World" -command null
pack .buttons.1 -side top -pady 1 -padx 1 -fill x

# this procedure does nothing useful
proc null {} {
  set tmp 1
}
Answer  
There is no answer at this time.

Comments  
Subject: Re: Help with a simple tcl/tk graphical widget question
From: ldavinci-ga on 04 Feb 2005 09:07 PST
 
Hi blackrock-ga,

  Seems like using the "-f" flag on the first line of your script
puts tcl in the interactive mode (confirm by checking the $tcl_interactive
variable). Removing the "-f" should make it work fine.

Regards
ldavinci-ga
Subject: Re: Help with a simple tcl/tk graphical widget question
From: blackrock-ga on 04 Feb 2005 10:18 PST
 
Hi ldavinci-ga,

I removed the "-f" flag and reran the script, but nothing seems to
have changed.  Execution immediately terminates and I am returned back
to the shell.

Thanks for the tip though,
blackrock-ga
Subject: Re: Help with a simple tcl/tk graphical widget question
From: ldavinci-ga on 04 Feb 2005 12:54 PST
 
Hi blackrock-ga,

   The above mentioned modification did work for me.
You could also post your question to tcl language usenet discussion:
tcl usenet group:
comp.lang.tcl
(Under http://groups.google.com, type search groups as comp.lang.tcl)

Regards
ldavinci-ga
Subject: Re: Help with a simple tcl/tk graphical widget question
From: blackrock-ga on 04 Feb 2005 14:03 PST
 
Based on your comment that it worked when you tested it, I ran the
same tcl script in two enviroments.  It works for me under RHEL3, it
doesn't work under RH 7.2

It looks like the root cause of my problem was that I was developing
under an environment (our 7.2 installation) where something is
broken...

Thanks so much for the help so far.
Subject: Re: Help with a simple tcl/tk graphical widget question
From: jgw-ga on 11 Feb 2005 13:55 PST
 
HI!
The only comment that I can write is I would pay 200$ to get a very
complete answer to your question.
I'll watch if someone answer it !
cheers,

jgw
Subject: Re: Help with a simple tcl/tk graphical widget question
From: blackrock-ga on 11 Feb 2005 18:10 PST
 
Well, I have discovered that it works on some of our 7.2 boxes, but
not on all of them.  I'm stymied for now, but it doesn't look like it
was really a tcl/tk language question...
Subject: Re: Help with a simple tcl/tk graphical widget question
From: asteriskman-ga on 19 Jul 2005 11:26 PDT
 
blackrock-ga,

Looks to me like you're missing one command which is implicit to
programs started with wish but not with tcl. This command is "vwait".
vwait starts the "event loop" which processes events such as window
manager events and allows the Tk widgets to function properly. The
syntax for vwait is:
vwait varName
please visit http://wiki.tcl.tk/1302 for more detailed information and
discussion on the vwait command. But, to make a long story short, if
you add the following line to your code things should work as you
expect:
vwait forever

Hope that helps even if it is a bit late!
asteriskman-ga

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy