| | |
Fix Tkinter Widget Location
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
•
•
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?
python Syntax (Toggle Plain Text)
# 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) root.mainloop()
Last edited by vegaseat; Dec 10th, 2006 at 1:19 pm. Reason: goofy tags
May 'the Google' be with you!
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]
[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
![]() |
Similar Threads
- Tkinter GUI Issues: (Python)
- Updating a Tkinter Widget: (Python)
Other Threads in the Python Forum
- Previous Thread: Stockroom Program
- Next Thread: Refreshing a Tkinter Canvas Multiple Times:
| Thread Tools | Search this Thread |
accessdenied advanced application argv beginner change color command convert csv cursor def dictionary digital dynamic dynamically edit editing enter event examples excel file float format frange function google gui homework i/o import input jaunty java keyboard lapse line linux list lists loop microphone mouse movingimageswithpygame newb number numbers numeric obexftp output parameters parsing path port prime programming projects py2exe pygame pygtk pyopengl python random recursion remote return reverse scrolledtext session simple skinning smtp sprite stderr string strings subprocess syntax table tennis terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode unit urllib urllib2 variable voip web-scrape windows wxpython






