Click here to Skip to main content
11,705,753 members (45,476 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Python
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.btn=Button(master, text="quit", command= quit)
        def quit(self):
        import sys; sys.exit()

this is the error "TypeError: this constructor takes no arguments".
please help me out.

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

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 170
2 Inimicos 60
3 ProgramFOX 50
4 F-ES Sitecore 45
0 OriginalGriff 9,037
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 8 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100