Reputation: 47
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()
Upvotes: 1
Views: 80
Reputation: 13347
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()
Upvotes: 2