0
I’m a beginner in Python and I’m developing my first program. It’s like this:
from tkinter import *
from tkinter import font
class Application(Frame):
def __init__(self, master=None):
pass
self.msg = Label(self, text="Bem vindos a GUIDA!!", fg = 'blue', font = 'Candara')
self.msg.place(x=50,y=70)
self.bye = Button (self, text="Bye", command=self.quit)
self.bye.pack ()
self.pack()
self.msg_2 = Label(self, text="Selecione os tópicos e exclareça suas dúvidas!", fg = 'black', font = 'Candara')
self.msg_2.place(x=80,y=100)
self.view = Button (self, text="Ver Tópicos", font = "Algerian", command = comando, fg = 'black', bg = 'white', activebackground = 'white', activeforeground = 'yellow')
self.view.place(x=400,y=100)
root = Tk()
root["bg"] = "green"
root.title('GUIDA')
root.geometry('750x700')
app = Application()
mainloop()
But when I run, it opens like this:
I wanted to know how to solve this mistake.
Avoid posting your codes in image, edit your question and place them here
– Luiz Augusto
Please, do not post your code as image, the site has support for formatting it; you can get more information by doing the [tour], reading the [Ask] tab and accessing [help]. The error in question is because you are switching to the initializer of
Label
a variableself
that does not exist and it seems to be wrong even if it existed. The parameterself
is implicitly defined by language when you instantiate a class, you hardly need to define it directly.– Woss
I do @Andersoncarloswoss?
– Lima Brothers
Start by studying and understanding what is and how
self
. In the link I marked there is a good material for you to start studies.– Woss
Lima, Cara by what it looks like here is just your identation, when you use the self it is not inside the method block init Try correcting the identation and see if it works. According to PEP8 python works with 4 indentation spaces, and if you do not respect indentation your code will fail.
– Robson Silva