[Tkinter-discuss] having trouble, newbie

Cam Farnell msa01 at bitflipper.ca
Wed Mar 19 03:33:25 CET 2008

1) Use grid_columnconfigure and grid_rowconfigure to create a "dummy" extra row and column beyond 
the columns and rows you actually use and set weight to 1. The dummy row and column then soak up any 
extra space and the actual widgets float up the the top left. It took me a while to figure this out. 
Any column/row index greater than what you actually use will do.

2) Use geometry to set the window size.

3) use focus_set.

There is good tkinter documentation at this URL:


although it doesn't tell you about the columnconfigure trick.

Here's a simple example:

from Tkinter import *
Root = Tk()
BB = Button(text='HelloWorld')

Cam Farnell

inhahe wrote:
> I'm trying to make a simple app in tkinter and am having two problems
> 1, i can't figure out how to put widgets in the top left of the main 
> window.  no matter what i try with row, column and sticky parameters it 
> puts my buttons in the middle of the window.
> 2, i pass width=800 and height=600 to Frame.__init__ and my window still 
> comes up tiny, just barely big enough for two buttons. 
> oh, while i'm at it--how do I make it so when the the window is created 
> it gets focus, like a ... real app?
> ------------------------------------------------------------------------
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss

More information about the Tkinter-discuss mailing list