Wednesday, 7 August 2013

tk: do I need to mention the widget master?

tk: do I need to mention the widget master?

I want to rearrange frames in PanedWindows at runtime based upon user
request. Previously I specified the master for each frame (here pw1). Ex:
import Tkinter as tk
root = tk.Tk()
pw1 = tk.PanedWindow(orient=tk.HORIZONTAL, sashpad=2,
sashwidth=4, sashrelief=tk.RAISED)
pw1.pack(fill=tk.BOTH, expand=1)
frame1 = tk.Frame(pw1, bg='red',width=100, height=100)
frame2 = tk.Frame(pw1, bg ='yellow',width=100,height=100)
# This seems to do the same thing:
# frame1 = tk.Frame(bg='red',width=100, height=100) # vs. tk.Frame()
# frame2 = tk.Frame(bg ='yellow',width=100,height=100)
pw1.add(frame1, sticky=tk.NSEW)
pw1.add(frame2, sticky=tk.NSEW)
root.mainloop()
What is the advantage of specifying the master?

No comments:

Post a Comment