Click here to Skip to main content
Sign Up to vote bad
good
See more: Python
hi,
i m new in python coding. i got a problem while running my code.this is my code.
 
from Tkinter import *
class example3:
    def _init_(self, master):
        self.lbl=Label(master, text="press button below to exit")
        self.lbl.pack()
        self.btn=Button(master, text="quit", command= quit)
        self.btn.pack()
 
        root=Tk()
        ex3=example3(root)
        root.mainloop()
        def quit(self):
 
        import sys; sys.exit()
 

this is the error "TypeError: this constructor takes no arguments".
please help me out.
 
kudos
neaS
Posted 12 Jul '12 - 19:19
Edited 12 Jul '12 - 19:40

Comments
Sergey Alexandrovich Kryukov - 13 Jul '12 - 20:08
In what line? And what's unclear in the error message? Some constructor has no argument, but you supply some. --SA

1 solution

It looks like the __init__ method may not be overridden properly. You need two underscores before and after the word init, not just one.
 
Also, from the indentation, it looks like the instance is being created from with it's own __init__ method, or have you skipped some code somewhere?
 
More clarity, if possible please.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 8,356
1 OriginalGriff 6,571
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid