n0trad3an
n0trad3an

Reputation: 21

I think I made a mistake with this tkinter widget

So till now I want to make a simple button but it gives me an error screen, what am I doing wrong? Here's my code:

import tkinter as tk
import math
import time

tk = tk.Tk()
tk.geometry()
tk.attributes("-fullscreen", True)

exit_button = tk.Button(tk, text = "Exit", height = 2, width = 2, command = tk.destroy)
exit_button.place(x=1506, y=0)





tk.mainloop()

Upvotes: -1

Views: 51

Answers (2)

Delrius Euphoria
Delrius Euphoria

Reputation: 15088

You cannot use tk = tk.Tk(), because you are also referring to tkinter as tk. So either:

Change your imports(not recommended):

import tkinter as _tk

tk = _tk.Tk() # And so on..

or change your variable name(recommended):

root = tk.Tk() # And change tk.geometry to root.geometry() and so on

Upvotes: 2

Pietro
Pietro

Reputation: 1110

You are shadowing tk with something else:

import tkinter as tk

root = tk.Tk()
root.geometry()
root.attributes("-fullscreen", True)

exit_button = tk.Button(root, text="Exit", height=2, width=2, command=root.destroy)
exit_button.place(x=1506, y=0)


tk.mainloop()

Upvotes: 3

Related Questions