1

I'm currently learning Python through videos online. I was working on this piece of code when I encountered a problem: no buttons show up. It seems to work fine for the guy in the video so I'm wondering what I'm doing wrong.

Please keep in mind that this is from a video tutorial and hence the code may not be that great.

I'm using PyCharm Community Edition 2017.2.

from tkinter import *


class Application(Frame):
    def ___init___(self, master):
        Frame.__init__(self, master)
        self.grid()
        self.create_widgets()

    def create_widgets(self):
        self.button1 = Button(self)
        self.button1.grid()
        self.button1.configure(text="Button1")
        self.button2 = Button(self, text="Button 2")
        self.button2.grid()
        self.button3 = Button(self, text="Button 3")
        self.button3.grid()

root = Tk()
root.title("Something")
root.geometry("200x100")

app = Application(root)

root.mainloop()

1 Answer 1

2

You are using a wrong __init__ function, it takes only 2 underscores before/after :

class Application(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.grid()
        self.create_widgets()
Sign up to request clarification or add additional context in comments.

1 Comment

@IbrahimPelja Please Accept His Answer By Pressing the Little Tick Next to It. This Way He Can Get Reputation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.