MrEikono
MrEikono

Reputation: 25

Why won't my text box show up in the GUI?

I'm trying to make a text box appear in a window using Tkinter, but it won't work... I've tried lots of things but nothing's working.

(No, I'm not going to look at this question which basically duplicates my situation. I already did, and it didn't help me at all.)

This is my current code:

# tkinter
from tkinter import *

# class
class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()

        box = Text(width=90, height=50)
        self.pack()

# create the window
window = App()

# attributes
window.master.title("Text box")
window.master.minsize(800, 600)
window.master.maxsize(800, 600)

# start program
window.mainloop()

Thanks.

Upvotes: 0

Views: 72

Answers (1)

sshashank124
sshashank124

Reputation: 32189

You have to pack the box as well:

class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()

        box = Text(width=90, height=50)
        box.pack()     #instead of self.pack()

Upvotes: 1

Related Questions