Python Forum

Full Version: program doesn't run.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Was watching a tutorial on youtube on how to use OOP in building GUI, but can not run identical code myself.
Error: "in line 27 app = Application() TypeError: __init__() missing 1 required positional argument: 'master'"
anybody could explain? Thank you!

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, text ="1")
        self.button1.grid()

        self.button2 = Button(self)
        self.button2.grid()
        self.button2.configure(text = "This will show up text")

        self.button3 = Button(self)
        self.button3.grid()
        self.button3["text"] = "This will also show text"
        
root = Tk()
root.title("Lazy Buttons")
root.geometry("200x85")

app = Application()
app.create_widgets()

root.mainloop()
You need to supply a master window reference
app = Application(root)
(Jan-15-2017, 07:41 PM)Larz60+ Wrote: [ -> ][Tkinter] program doesn't run.
(Jan-15-2017, 07:41 PM)Larz60+ Wrote: [ -> ]You need to supply a master window reference
 app = Application(root) 
It is working now! Many thanks!