Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41562
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Python GUI questions |
| Date | 2013-03-19 23:21 -0400 |
| References | <4250fe44-c09c-48a8-aca2-51c1a8bc3a48@googlegroups.com> <e745739b-a9bb-49a3-8a06-1b4ae3f4d901@googlegroups.com> <262b7363-f980-4926-bb36-1f795769b359@googlegroups.com> <495e8e74-2211-4a82-a632-61e1cd16f854@l16g2000yqe.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3542.1363749686.2939.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 12:01 -0700
Re: Python GUI questions Chris Angelico <rosuav@gmail.com> - 2013-03-20 08:39 +1100
Re: Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 15:50 -0700
Re: Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 15:50 -0700
Re: Python GUI questions Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-19 17:57 -0700
Re: Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 18:25 -0700
Re: Python GUI questions Ranting Rick <rantingrickjohnson@gmail.com> - 2013-03-19 19:16 -0700
Re: Python GUI questions maiden129 <sengokubasarafever@gmail.com> - 2013-03-19 19:36 -0700
Re: Python GUI questions Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-19 20:06 -0700
Re: Python GUI questions Terry Reedy <tjreedy@udel.edu> - 2013-03-19 23:21 -0400
Re: Python GUI questions Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-20 10:37 -0700
Re: Python GUI questions Jason Swails <jason.swails@gmail.com> - 2013-03-19 22:14 -0400
Re: Python GUI questions Jan Riechers <janpeterr@freenet.de> - 2013-03-31 16:33 +0300
csiph-web