1
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.

5
  • Your code is not complete (and probably not minimal). Commented Apr 10, 2015 at 13:40
  • I recommend you read the book "Python and TKinter programming". Very good book, thorough. You can probably find them on eBay for lower prices. That's assuming you really want to use TKinter. I do recommend Qt instead of Tkinter though Commented Jul 2, 2017 at 4:33
  • @frankliuao good points. thanks for the book. i would look for it. but btw, why you choose Qt that Tkinter? Commented Jul 3, 2017 at 14:24
  • @mbdrian wider application, easier, more useful. Commented Jul 3, 2017 at 18:10
  • @frankliuao Qt, then. thankyou. Commented Jul 4, 2017 at 6:11

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.