Click here to Skip to main content
15,867,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i'm a newbie and I to created a gui with 3 panels. One panel is at the bottom and the other two are splitted vertically. I want to put a text field into the right top panel but however I can't resize it. Can anyone help?

What I have tried:

from tkinter import *

root = Tk()
root.title("GUI")
root.geometry("700x400")


def getText(res):
    res = texte.get()
    print(res)


panel_1 = PanedWindow(bd=4, relief="raised")
panel_1.pack(fill=BOTH, expand=1)

panel_2 = PanedWindow(panel_1, orient=HORIZONTAL, bd=2, relief="raised")
panel_1.add(panel_2)

right_panel = PanedWindow(panel_2, orient=HORIZONTAL, bd=2, relief="raised")
panel_2.add(right_panel)
texte = Text(right_panel)
texte = Entry(right_panel)
texte.pack(expand=True)
texte.bind('<Return>', getText)

left_panel = PanedWindow(panel_2, orient=HORIZONTAL, bd=2, relief="raised")
panel_2.add(left_panel)

bottom_panel = PanedWindow(panel_1, orient=VERTICAL, bd=2, relief="raised", height= "100")
panel_1.add(bottom_panel)
bottom_panel.pack(fill= BOTH, side= BOTTOM)

root.mainloop()
Posted
Updated 8-May-22 3:53am

1 solution

Your code is somewhat confusing. You have the following two lines:
Python
texte = Text(right_panel)
texte = Entry(right_panel)

So you create a Text widget, and immediately replace it with an Entry widget. So remove the Entry line, and add a height value to the Text one:
Python
texte = Text(right_panel, height=5)

You should also remove all those extra panels until your basic code is working. Start with a single screen and build it up slowly. Add a single widget and run the code to see what it looks like. If it is correct then add the next item, and test that. You then have a much better chance of seeing any mistakes straight away.

You should also use more meaningful names, e.g left_panel, right_panel, etc.

See Python - GUI Programming (Tkinter)[^] for further information.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900