Reputation: 470
textFrame1 = Frame(mainFrame,bd=5,width=100)
textFrame1.pack(fill=BOTH,side=LEFT,expand=YES)
self.textFile1 = Text(textFrame1,wrap=None)
sbVer1 = Scrollbar(textFrame1,orient=VERTICAL,command=self.textFile1.yview)
sbHor1 = Scrollbar(textFrame1,orient=HORIZONTAL,command=self.textFile1.xview)
sbVer1.pack(side=RIGHT,fill=Y)
sbHor1.pack(side=BOTTOM,fill=X)
self.textFile1.config(yscrollcommand=sbVer1.set,xscrollcommand=sbHor1.set)
self.textFile1.pack()
# --------------------------------------------
textFrame2 = Frame(mainFrame,bd=5,width=1)
textFrame2.pack(fill=BOTH,side=RIGHT,expand=YES)
self.textFile2 = Text(textFrame2,wrap=None)
sbVer2 = Scrollbar(textFrame2,orient=VERTICAL,command=self.textFile2.yview)
sbHor2 = Scrollbar(textFrame2,orient=HORIZONTAL,command=self.textFile2.xview)
sbVer2.pack(side=RIGHT,fill=Y)
sbHor2.pack(side=BOTTOM,fill=X)
self.textFile2.config(yscrollcommand=sbVer2.set,xscrollcommand=sbHor2.set)
self.textFile2.pack()
I want to resize a frame (tkinter python) because it's too large and I want to make it smaller. If you read carefully, I put two frames in this code. The first frame has width=100
and the second width=1
. But, when I compile, the result still same. It looks as if the command width
doesn't work correctly.
Upvotes: 1
Views: 950
Reputation: 10532
Your text boxes have the default width of 80 characters, and the frames size to fit them. You should set the width and height of your text widgets if you want one of them larger than the other.
Another option, which I wouldn't recommend, is to use .pack_propagate(False)
on your root window to stop the frames from resizing to fit the widgets.
Upvotes: 1