Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!goblin1!goblin.stu.neva.ru!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'root': 0.04; 'subject:Python': 0.05; 'tkinter': 0.07; 'argument:': 0.09; 'callback': 0.09; 'happens.': 0.09; 'positional': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'typeerror:': 0.09; 'def': 0.10; 'presume': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'return,': 0.16; 'subject:GUI': 0.16; 'subject:questions': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'skip:" 40': 0.20; 'import': 0.21; 'button,': 0.22; 'example': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'file': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'entry': 0.33; 'expected': 0.35; 'pm,': 0.35; 'something': 0.35; 'received:org': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'nothing': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'remove': 0.61; 'click': 0.76; 'here!': 0.84; 'received:fios.verizon.net': 0.84; 'rick': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Python GUI questions Date: Tue, 19 Mar 2013 23:21:06 -0400 References: <4250fe44-c09c-48a8-aca2-51c1a8bc3a48@googlegroups.com> <262b7363-f980-4926-bb36-1f795769b359@googlegroups.com> <495e8e74-2211-4a82-a632-61e1cd16f854@l16g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 In-Reply-To: <495e8e74-2211-4a82-a632-61e1cd16f854@l16g2000yqe.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363749686 news.xs4all.nl 6892 [2001:888:2000:d::a6]:58217 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41562 On 3/19/2013 10:16 PM, Ranting Rick wrote: > import tkinter as tk > from tkinter.constants import LEFT > > def cbButton(self): > print('I should do something here!') > > root = tk.Tk() > root.title("Window") > w=tk.Label(root, text="Enter a string") > w.pack(side=LEFT) > e1 = tk.Entry(root, bd=5) > e1.pack(side=LEFT) > b=tk.Button(root, text="Count", command=cbButton) > b.pack(padx=5, pady=5) > root.mainloop() when I run this, and click the button, I get Exception in Tkinter callback Traceback (most recent call last): File "C:\Programs\Python33\lib\tkinter\__init__.py", line 1442, in __call__ return self.func(*args) TypeError: cbButton() missing 1 required positional argument: 'self' when I remove 'self' from cbButton, I get the expected I should do something here! When I enter something in the Entry box and hit return, nothing happens. I presume that is because the example is not complete. -- Terry Jan Reedy