Setting Window Size using Pack Under Tkinter

F

Fuzzyman

I'm having trouble implementing my GUI using Tkinter......
I've been working through the Tkinter tutorials from 'Programming
Python' and am generally happy enough with the functionality and feel
of the results *but* - I can't see how to set the size of the root
window (or any top level window) and to stop it being resized........

Thanks for any help.

Fuzzyman


--

YAPLP
Yet Another Python Links Page
http://www.voidspace.org.uk/coollinks/python_links.shtml

Python Utils
http://www.voidspace.org.uk/atlantibots/pythonutils.html

--

http://www.Voidspace.org.uk
The Place where headspace meets cyberspace. Online resource site -
covering science, technology, computing, cyberpunk, psychology,
spirituality, fiction and more.

---
http://www.atlantibots.org.uk
http://groups.yahoo.com/group/atlantis_talk/
Atlantibots - stomping across the worlds of Atlantis.
---
http://www.fuchsiashockz.co.uk
http://groups.yahoo.com/group/void-shockz
---

Everyone has talent. What is rare is the courage to follow talent
to the dark place where it leads. -Erica Jong
Ambition is a poor excuse for not having sense enough to be lazy.
-Milan Kundera
 
D

duikboot

from Tkinter import *
gui=Tk()

####code####
gui.geometry("+%d+%d" %(300, 100))
gui.resizable(0,0)

if __name__=='__main__':
gui.mainloop()
 
D

duikboot

from Tkinter import *
gui=Tk()

####code####
gui.geometry("+%d+%d" %(300, 100))
gui.resizable(0,0)
gui.mainloop()

Will work offcourse too.. :)

cheers,

Arjen
 
F

Fuzzyman

Short of actually trying it...... (when I get home I *will* try it)

Would the following work :

from Tkinter import *
gui=Tk()
Button(gui, text='A button', command=a_function).pack()

####code####
gui.geometry("+%d+%d" %(300, 100))
gui.resizable(0,0)
gui.mainloop()

??

If I recall correctly it ought to.... (mixing the pack and geometry
methods in the same GUI)...

Anyway - thanks.

Fuzzy
 
E

Eric Brunel

Fuzzyman said:
Short of actually trying it...... (when I get home I *will* try it)

Would the following work :

from Tkinter import *
gui=Tk()
Button(gui, text='A button', command=a_function).pack()

####code####
gui.geometry("+%d+%d" %(300, 100))
gui.resizable(0,0)
gui.mainloop()

??

Yes it will. Note however that doing gui.geometry("+300+100") will actually move
the window, not resize it. To resize the window, use gui.geometry("300x100")

More generally, the syntax for the geometry is "WxH+X+Y" where W and H are the
window's width and height resp. and X & Y the coordinates of its top-left corner
from the top-left corner of the screen.
 

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

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top