Tkinter error on re-entry

Asked

Viewed 22 times

0

Was using tkinter, I made the code normally, and when I ran the same, everything was working normally, but when I left the program and entered again it gave error:

my code:

from tkinter import *
from random import randint

def meu_jogo():
    computador = randint(1, 10)
    texto_ganhador['text'] = 'O computador pensou no número {}'.format(computador)

janela = Tk()
janela.title('meu primeiro teste')

label = Label(janela, text='O computador irá sortea um número para você entre 0 a 10')
label.grid(column=0,row=0, padx=10, pady=10)

button = Button(janela, text='clique aqui para começar', command=meu_jogo)
button.grid(column=0, row=1, padx=10, pady=10)

texto_ganhador = Label(janela, text='')
texto_ganhador.grid(column=0,row=2)

janela.mainloop()

error:

Traceback (most recent call last):
  File "/storage/emulated/0/qpython/PySimpleGUI/tkinter.py", line 1, in <module>
    from tkinter import *
  File "/storage/emulated/0/qpython/PySimpleGUI/tkinter.py", line 8, in <module>
    janela = Tk()
NameError: name 'Tk' is not defined

I don’t understand why this is happening, The first time it ran as expected. I wanted to solve this mistake, but, I don’t know how.

  • 1

    Some solution of Soen help you?

  • 1

    Yes, my problem has been solved, thank you very much!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.