Python Forum
[Tkinter] Text window not properly sized
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Text window not properly sized
#1
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]
Reply
#2
#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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Transparent window background, but not text on it muzicman0 8 6,809 Feb-13-2025, 06:16 AM
Last Post: elonnmusk
  [Tkinter] Pixel sized button does not work associated method TheTiger 7 1,744 Dec-22-2024, 01:10 AM
Last Post: deanhystad
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 2,500 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 2,912 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  [Tkinter] How to show text in window? wxnerd 4 6,015 Jun-20-2020, 04:16 PM
Last Post: wxnerd
  tkinter window and turtle window error 1885 3 8,209 Nov-02-2019, 12:18 PM
Last Post: 1885
  [WxPython] Dynamically Sized Widget CanadaGuy 3 5,012 Nov-12-2018, 02:55 AM
Last Post: Larz60+
  update a variable in parent window after closing its toplevel window gray 5 11,046 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020