Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to learn Tk?

98 views
Skip to first unread message

Fritz Wuehler

unread,
Apr 5, 2012, 8:00:28 PM4/5/12
to
Started playing around with Tcl recently and found it quite nice. I've used
a few of the tk widgets like getOpenFile but I don't know how to write a
real GUI script that doesn't use any console i/o. I haven't written GUI in
other languages. I understand the concepts like event driven etc. Can anyone
recommend how to get started learning Tk? The books I saw seem to rehash the
Tcl doc and just give isolated examples of widgets. That doesn't help put it
all together.

Another question is if I call a long running non-Tcl script with exec or
catch exec how can I present a progress bar? I have no idea how long the
script will execute, I just have to wait until its done. The examples I
found on the Tcl wiki looked very involved and didn't show how to test
them. I'm sure this is shown somewhere but I'm just finding my way around
all the Tcl materials now. Thanks for your suggestions.

--
killfiling g00g0le groups since 2008
if you post from g00gole and i don't respond, it is not that i am ignoring
you, i am killfiling you. nothing personal, i just hate spam and most of
usenet spam comes from g00g3ole

Les Cargill

unread,
Apr 5, 2012, 10:02:44 PM4/5/12
to
get the Brent Welch book.

--
Les Cargill

tombert

unread,
Apr 6, 2012, 2:54:47 AM4/6/12
to
Did you have a look at Tcl tutorial? http://www.tcl.tk/man/tcl/tutorial/tcltutorial.html

and the Tcl Tutor: http://www.msen.com/~clif/TclTutor.html

An there is a nice e-book: TclTk-85-Programming-Cookbook


George Petasis

unread,
Apr 6, 2012, 5:08:58 AM4/6/12
to Fritz Wuehler
There is also a nice tutorial here:

http://www.tkdocs.com/tutorial/

George

Zbigniew Diaczyszyn

unread,
Apr 6, 2012, 1:30:09 PM4/6/12
to
Am 06.04.2012 02:00, schrieb Fritz Wuehler:
> Can anyone
> recommend how to get started learning Tk?

I would recommend:

Mark Harrison/Michael McLennan, Effective Tcl/Tk Programming: Writing
Better Programs with Tcl and Tk.

Published Dec 8, 1997 by Addison-Wesley Professional. Part of the
Addison-Wesley Professional Computing Series series. Copyright 1998

Chapters:
1) Design of a Tk application
2) pack, grid, place
3) Event handling
4) Canvas widget
5) Text widget
6) Toplevel windows
7) Sockets
8) Preparing applications for the market
9) Platform independence

Downloadable sample chapter:

https://www.informit.com/content/images/0201634740/samplechapter%5C04canvas.pdf

The German version is sold out:

Effektiv Tcl/Tk programmieren . [Broschiert]
M Harrison (Autor), McLennan (Autor)

I bought a new one for 44,95€, for a used German version you have to pay
now 78€ (!).

The book is based on Tcl/Tk 8.0 and developing a project: "The
electronic secretary". Despite the fact that Addison-Wesley recommends
it for professional programming the book can be gainful for beginners, too.

Nomen Nescio

unread,
Apr 9, 2012, 8:31:51 AM4/9/12
to
Thanks, is this the prior version of the Welch book? Is something so old
recommended and relevant?

Nomen Nescio

unread,
Apr 11, 2012, 7:29:21 AM4/11/12
to
Thanks alot!

Nomen Nescio

unread,
Apr 11, 2012, 7:59:54 AM4/11/12
to
Thanks.

Fritz Wuehler

unread,
Apr 11, 2012, 11:57:57 AM4/11/12
to
Thanks I guess this is the one that Welch later updated? Or am I
confused. Anyway is a book from 1998 still relevant?

tomas

unread,
Apr 11, 2012, 12:24:08 PM4/11/12
to
Fritz Wuehler <fr...@spamexpire-201204.rodent.frell.theremailer.net>
writes:

> Thanks I guess this is the one that Welch later updated? Or am I
> confused. Anyway is a book from 1998 still relevant?

Yes and no. The language itself (and the Tk programming interface, as
seen from Tcl) have kept fairly stable. That said, for more advanced
topics, things have changed:

- Many more "standard" libs. Don't miss on them, they are helpful
(Tcllib, Tklib).

- Canvas has learnt a few more tricks

- Widgets are implemented differently (when going for theming support,
fonts, etc, there are many new things).

- The C intreface changed quite a bit.

And <http://wiki.tcl.tk/> can't be overstated. Just keep clicking on
"random page". Hours of fun :-)

Regards
-- tomás

Kevin Walzer

unread,
Apr 12, 2012, 5:41:28 PM4/12/12
to
On 4/5/12 8:00 PM, Fritz Wuehler wrote:
> Started playing around with Tcl recently and found it quite nice. I've used
> a few of the tk widgets like getOpenFile but I don't know how to write a
> real GUI script that doesn't use any console i/o. I haven't written GUI in
> other languages. I understand the concepts like event driven etc. Can anyone
> recommend how to get started learning Tk? The books I saw seem to rehash the
> Tcl doc and just give isolated examples of widgets. That doesn't help put it
> all together.
>
> Another question is if I call a long running non-Tcl script with exec or
> catch exec how can I present a progress bar? I have no idea how long the
> script will execute, I just have to wait until its done. The examples I
> found on the Tcl wiki looked very involved and didn't show how to test
> them. I'm sure this is shown somewhere but I'm just finding my way around
> all the Tcl materials now. Thanks for your suggestions.
>


http://www.amazon.com/Tcl-Tk-Toolkit-John-Ousterhout/dp/020163337X is a
good book to look at.


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

Prof Craver

unread,
Apr 13, 2012, 12:20:47 PM4/13/12
to
The Tcl Wikibook (google "Tcl Wikibook") is, in my opinion, one of the best tutorials for any programming language ever written. It has extensive examples of Tk.

Nomen Nescio

unread,
Apr 15, 2012, 6:55:33 AM4/15/12
to
If I call a long running non-Tcl script with exec or catch exec how can I
present a progress bar? I have no idea how long the script will execute, I
just have to wait until its done. The examples I found on the Tcl wiki
looked very involved and didn't show how to test them. I'm sure this is
shown somewhere but I'm just finding my way around all the Tcl materials
now. Thanks for your suggestions.

tomás zerolo

unread,
Apr 15, 2012, 12:07:11 PM4/15/12
to
Nomen Nescio <nob...@dizum.com> writes:

> If I call a long running non-Tcl script with exec or catch exec how can I
> present a progress bar? I have no idea how long the script will execute, I
> just have to wait until its done. The examples I found on the Tcl wiki
> looked very involved and didn't show how to test them. I'm sure this is
> shown somewhere but I'm just finding my way around all the Tcl materials
> now. Thanks for your suggestions.

AFAIK exec will wait until the external script is done, so no chance to
show a "moving progress bar" during the process.

Try a combination of [open] (and set the file descriptor you get to
"non-blocking" and [fileevent] to get output from the command, roughly
like so:

------
set fh [open "$command 2>@stdout"]
fconfigure $fh -blocking none ;# optionally -buffering none
fileevent $fh readable recv

proc recv {chan} {
$progress configure -value [expr [$progress cget -value] + 10]
# or whatever is appropriate
}

# Since you don't know how much is 100 percent, you'll have to make do
# with a "cycling" progress bar:
set progress [ttk::progressbar .pro -mode indeterminate]
------

Warning: hopelessly untested code! This assumes that the process
produces some output to trigger our progress thingy. You'll have to add
some code to catch the end of things (the channel gets presumably
closed). Some error handling won't hurt either.

See
<http://wiki.tcl.tk/1039>
<http://wiki.tcl.tk/12704>
<http://wiki.tcl.tk/9691>

for some inspiration.

Regards
-- tomás

Fritz Wuehler

unread,
Apr 15, 2012, 9:33:13 PM4/15/12
to
Thanks very much Tomas. I will check and get back to you.

Zbigniew Diaczyszyn

unread,
Apr 17, 2012, 4:33:46 AM4/17/12
to
Am 11.04.2012 17:57, schrieb Fritz Wuehler:
> Thanks I guess this is the one that Welch later updated? Or am I
> confused.

No, it hasn't been updated by Welch e.a. It is not explaining all the Tk
commands nor any Tcl commands. It is explaining Tk's philosophy.

Anyway is a book from 1998 still relevant?

Hm, "Effective Programming" is not intended as a manual but as a
tutorial to effective programming so it can be useful today as well. You
will see how a master is using tools from a Tool-Kit.

Just read the sample chapter.
0 new messages