Fix Tkinter Widget Location

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2006
Posts: 2,279
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 176
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Fix Tkinter Widget Location

 
0
  #1
Dec 9th, 2006
As you can see, I am playing around with the Tkinter GUI toolkit. How can I keep a number of widgets fixed in a location even when the user expands the window?
No one died when Clinton lied.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,065
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 936
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: Fix Tkinter Widget Location

 
0
  #2
Dec 10th, 2006
Originally Posted by sneekula View Post
As you can see, I am playing around with the Tkinter GUI toolkit. How can I keep a number of widgets fixed in a location even when the user expands the window?
Well, this is one way to accomplish this ...
  1. # let user resize the Tkinter window, but do not move widgets
  2.  
  3. from Tkinter import *
  4.  
  5. root = Tk()
  6.  
  7. b1 = Button(root, text='Button 1')
  8. # tells the widget not to expand into the packing cell
  9. # and to anchor itself to the NW (upper left) corner
  10. b1.pack(expand=NO, anchor=NW)
  11.  
  12. root.mainloop()
Last edited by vegaseat; Dec 10th, 2006 at 1:19 pm. Reason: goofy tags
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,279
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 176
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Re: Fix Tkinter Widget Location

 
0
  #3
Dec 11th, 2006
What do I do if I want two buttons and the NW corner is already taken by the first button?
No one died when Clinton lied.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 1,546
Reputation: Ene Uran has a spectacular aura about Ene Uran has a spectacular aura about 
Solved Threads: 174
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Posting Virtuoso

Re: Fix Tkinter Widget Location

 
0
  #4
Dec 12th, 2006
You need to learn to experiment a little with the code, its fun!
[php]# let user resize the Tkinter window, but do not move widgets

from Tkinter import *

root = Tk()

b1 = Button(root, text='Button 1')
# tells the widget not to expand into the packing cell
# and to anchor itself to the NW (upper left) corner
b1.pack(expand=NO, anchor=NW)

b2 = Button(root, text='Button 2')
# tells the widget not to expand into the packing cell
# and to anchor itself to the next free NW (upper left) corner
b2.pack(expand=NO, anchor=NW)

root.mainloop()
[/php]
drink her pretty
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,279
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 176
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Re: Fix Tkinter Widget Location

 
0
  #5
Dec 13th, 2006
Thanks for the advice, I will try to discover the fun of experimenting with the code. After all, it can't do more than melt down my computer!?
No one died when Clinton lied.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC