Tobias von Arx
Tobias von Arx

Reputation: 13

Tkinter Option Menu doesn't show

I'm new to Python and I hope the Stackoverflow community can help me with a problem I have. I have the following code, and when I try to run the program, the Option Menu (Dropdown Menu) doesn't appear. Only an empty window appears. How can I fix this?

# Python 3.6
from tkinter import *

root = Tk()

class Application(Frame):
    def __init__(self):
        Frame.__init__(self)
        self.create_vars()
        self.create_widgets()

    def create_vars(self):
        self.tee_strvar = StringVar()
        self.tee_strvar.set("Select tee")

    def create_widgets(self):
        self.tee_dropdown = OptionMenu(self, self.tee_strvar, "yellow", "red")
        self.tee_dropdown.grid(row=1, column=1)

    def check_tee(self):
        pass


app = Application()

root.mainloop()

Thanks a lot for your help, please answer beginner-friendly if possible :)

Upvotes: 1

Views: 450

Answers (1)

Pythonista
Pythonista

Reputation: 11615

You didn't pack/grid/place the application... You didn't pass a master in either, so by default it is using the root window as the master, but the "Application" i.e. - a Frame object isn't being managed by a geometry manager.

Upvotes: 1

Related Questions