0

Why are my Buttons not appearing?

from tkinter import *
from tkinter import ttk

window = Tk()
window.title("window title")
frame = ttk.Frame(window)

btnTest = Button(frame, text = 'test').grid(row = 0, column = 0)
btnExit = Button(frame, text = 'exit', command = exit).grid(row = 0, column = 1)

window.mainloop()
martineau
  • 119,623
  • 25
  • 170
  • 301
rippon
  • 31
  • 2
  • Off-topic: See accepted answer to the question [Tkinter: AttributeError: NoneType object has no attribute ](https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-attribute-name) _before_ you encounter the other problem with your code. – martineau Apr 17 '21 at 23:34

1 Answers1

3

You created the buttons inside a frame, and you're placing them with the grid() geometry manager, that's fine. But you haven't placed the frame itself, try this:

frame = ttk.Frame(window)
frame.grid()

Actually, the frame is the widget that's not appearing.

joao
  • 2,220
  • 2
  • 11
  • 15