Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make tkinter text widget fit to window

I'm making a text editor whose main widget is a Text widget for the user to actually enter text. I need to make the text widget fit to the window when the user resizes the pane. I kind of cheated by making the widget huge, but that's just a makeshift solution to let me work on other parts while I look for a solution. How can I make the Text widget automatically resize to fit the window?

like image 592
Ecko Avatar asked Jan 09 '23 13:01

Ecko


1 Answers

Use pack to place the widget, with expand set to True and fill set to BOTH. Ex:

    from tkinter import *
    root=Tk()

    text=Text(root)
    text.pack(expand=True, fill=BOTH)

    root.mainloop
like image 82
Ecko Avatar answered Jan 11 '23 01:01

Ecko