Python Forum
[Tkinter] Text window not properly sized - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] Text window not properly sized (/thread-19173.html)



Text window not properly sized - smabubakkar - Jun-16-2019

Hi I have created a python tool based on Tkinter GUI to compare two text files, i am facing a strange issue, which you might have already came across. I have two Scrollable text area which are not evenly sized when i run the program, why does it come like that? any solution for that? I have analyzed that issue comes with "grid_rowconfigure" and "grid_columnconfigure" but there is no proper documents available. kindly help attaching the code

import tkinter as tk

root = tk.Tk()

textContainer = tk.Frame(root, borderwidth=1, relief="sunken")

#First Text Window
text = tk.Text(textContainer, width=24, height=13, wrap="none", borderwidth=0)
textVsb = tk.Scrollbar(textContainer, orient="vertical", command=text.yview)
textHsb = tk.Scrollbar(textContainer, orient="horizontal", command=text.xview)
text.configure(yscrollcommand=textVsb.set, xscrollcommand=textHsb.set)
text.insert(tk.INSERT,"hi")
text.grid(row=0, column=0, sticky="nsew")
textVsb.grid(row=0, column=1, sticky="ns")
textHsb.grid(row=1, column=0, sticky="ew")

#Second Text Window
text1 = tk.Text(textContainer, width=24, height=13, wrap="none", borderwidth=0)
text1Vsb = tk.Scrollbar(textContainer, orient="vertical", command=text1.yview)
text1Hsb = tk.Scrollbar(textContainer, orient="horizontal", command=text1.xview)
text1.configure(yscrollcommand=text1Vsb.set, xscrollcommand=text1Hsb.set)
text1.insert(tk.INSERT,"hi")
text1.grid(row=0, column=2, sticky="nsew")
text1Vsb.grid(row=0, column=3, sticky="ns")
text1Hsb.grid(row=1, column=2, sticky="ew")

#Issue occur here
textContainer.grid_rowconfigure(0, weight=1)
textContainer.grid_columnconfigure(0, weight=1)


textContainer.pack(side="top", fill="both", expand=True)

root.mainloop()
[Image: c6gzrwf]


RE: Text window not properly sized - Yoriz - Jun-16-2019

#Issue occur here
textContainer.grid_rowconfigure(0, weight=1)
textContainer.grid_columnconfigure(0, weight=1)
set the weight of the other text control
#Issue occur here
textContainer.grid_rowconfigure(0, weight=1)
textContainer.grid_columnconfigure(0, weight=1)
textContainer.grid_columnconfigure(2, weight=1)