Tkinter Frame Size

T

Tuvas

I'm tyring to set the size of the window that is opened when you open a
Tkinter window, without much sucess. I have tried changing the heigth
and width atributes, but it doesn't do anything. I tried using the
grid_propagate command that I saw to use, but made the window even
smaller... What can I do? Thanks!
 
J

James Stroud

I'm tyring to set the size of the window that is opened when you open a
Tkinter window, without much sucess. I have tried changing the heigth
and width atributes, but it doesn't do anything. I tried using the
grid_propagate command that I saw to use, but made the window even
smaller... What can I do? Thanks!

Here is a very simple way:

from Tkinter import *
app = Tk()
app.geometry("%dx%d%+d%+d" % (600, 400, 0, 0))
f = Frame(app)
f.pack()
app.mainloop()


--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 
T

Tuvas

Okay. I have alot of items that are put on the basic frame already,
using a grid method. Will this change anything?
 
J

James Stroud

Okay. I have alot of items that are put on the basic frame already,
using a grid method. Will this change anything?

It shouldn't. For example

from Tkinter import *
app = Tk()
app.geometry("%dx%d%+d%+d" % (600, 400, 0, 0))
f = Frame(app)
f.pack()
L1 = Label(f, text="Bob & Carol & Ted & Alice")
L1.grid(row=0, column=0, columnspan=2)
L2 = Label(f, text="Barney")
L2.grid(row=1, column=0)
L3 = Label(f, text="Betty")
L3.grid(row=1, column=1)
app.mainloop()

Just grid everything in the frame then pack the frame in the Tk(). However do
not mix grid and pack in the same frame or it will lock up your app. E.g.
*dont* do this:

L1 = Label(f, text="Bob & Carol & Ted & Alice")
L1.grid(row=0, column=0, columnspan=2)
L2 = Label(f, text="Barney")
L2.pack()

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,179
Latest member
pkhumanis73
Top