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:

http://infohost.nmt.edu/tcc/help/pubs/tkinter/

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

Here's a simple example:

from Tkinter import *
Root = Tk()
Root.geometry('640x480')
Root.grid_rowconfigure(index=10,weight=1)
Root.grid_columnconfigure(index=10,weight=1)
BB = Button(text='HelloWorld')
BB.focus_set()
BB.grid()
Root.mainloop()

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@python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to