Python Forum
[Tkinter] program doesn't run.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] program doesn't run.
#1
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()
Reply
#2
You need to supply a master window reference
app = Application(root)
Reply
#3
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Program strange behavior ( windows doesn't close) adam2020 2 2,161 May-12-2019, 09:19 PM
Last Post: adam2020

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020