tk the python way

Gabriel Cosentino de Barros aut_gbarros at
Wed Jan 5 11:18:51 EST 2005

I'm strugling a little with TK, and the docs on the web aren't helping much.

I've already rewritten about twelve times a basic class that was supposed to
simply draw a window. It's not even close the final draft, but i tought
"well, let's start with something easy that can be done in less than an
hour"... silly me. But keep reading, it's not just to vent my frustations :)

The main issue here is: How to use TK eficiently.

I'm already planing another post about the pack/grid/place-power-trio but
for now: what's the better, most scalable and less cumbersome way to use Tk?

1. Windows
a) hide Tkroot in __main__ and call the class, whom willcreate it's own
b) let __main__ pass the root window and make the class always require a
c) what's the "industry standandard" for a single or dual window small app?
(no, it's not java, wrong topic)

2. Buttons
What's the nicer way to pass arguments directly in a button action?
I don't know if this one is me just being dumb. but `Button(...,
command=doit(1) )` doesn't work for me and i haven't seen it in any doc... I
came to the point of writing:
  btnHd = Button(..., command=self.__fileBrowseH)
  btnCd = Button(..., command=self.__fileBrowseC)
  btnFd = Button(..., command=self.__fileBrowseF)
and self.__fileBrowse/[CHF]/() being just a wraper for

...And don't miss on this same channel: my indignation with Tk's positioning
systems :P

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list