[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-28 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

For whatever reason, the 3.9 backport, PR-27911, was closed.  In any case, we 
will not edit the code we have replaced.

Lyndon, when responding by email, please delete the old text as it is redundant 
and noisy when your email is added to the web page.

--
nosy: +terry.reedy
resolution:  -> out of date
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-28 Thread miss-islington


Change by miss-islington :


--
keywords: +patch
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +26458
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27911

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-27 Thread E. Paine


E. Paine  added the comment:

Thanks for reporting this issue. This was (very) recently fixed in issue42560 / 
PR27842. These changes include a new hello world example and can be seen in the 
3.10 / 3.11 docs 
(https://docs.python.org/3.10/library/tkinter.html#a-hello-world-program). This 
change was backported to 3.9 docs, but the build bots have yet to rebuild the 
version hosted on docs.python.org.

--
nosy: +epaine

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-27 Thread Lyndon D'Arcy


Lyndon D'Arcy  added the comment:

Apologies, my original post was unclear.

The help(app.quit) which I posted is what we should get when the method
isn't clobbered.

What Serhiy has posted is what you get after running the example as-is.  It
shows that after running the example self.quit refers to a button object
instead of the quit method.

On Fri, 27 Aug 2021 at 7:38 pm, Serhiy Storchaka 
wrote:

>
> Serhiy Storchaka  added the comment:
>
> I get different result:
>
> >>> app.quit
> 
> >>> help(app.quit)
> Help on Button in module tkinter object:
>
> class Button(Widget)
>  |  Button(master=None, cnf={}, **kw)
>  |
>  |  Button widget.
>  |
> ...
>
> --
> nosy: +serhiy.storchaka
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I get different result:

>>> app.quit

>>> help(app.quit)
Help on Button in module tkinter object:

class Button(Widget)
 |  Button(master=None, cnf={}, **kw)
 |  
 |  Button widget.
 |  
...

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45029] tkinter doc, hello world example - quit button clobbers method

2021-08-27 Thread Lyndon D'Arcy


New submission from Lyndon D'Arcy :

Below is the example as it is.  Currently self.quit clobbers a built-in method 
of the same name.  I would suggest renaming self.quit to self.quit_button or 
similar.

---

import tkinter as tk

class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
self.create_widgets()

def create_widgets(self):
self.hi_there = tk.Button(self)
self.hi_there["text"] = "Hello World\n(click me)"
self.hi_there["command"] = self.say_hi
self.hi_there.pack(side="top")

self.quit = tk.Button(self, text="QUIT", fg="red",
  command=self.master.destroy)
self.quit.pack(side="bottom")

def say_hi(self):
print("hi there, everyone!")

root = tk.Tk()
app = Application(master=root)
app.mainloop()

---

>>> help(app.quit)
Help on method quit in module tkinter:

quit() method of __main__.Application instance
Quit the Tcl interpreter. All widgets will be destroyed.

--
assignee: docs@python
components: Documentation, Tkinter
messages: 400403
nosy: docs@python, lyndon.darcy
priority: normal
severity: normal
status: open
title: tkinter doc, hello world example - quit button clobbers method
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue45029>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: quit button

2009-10-26 Thread Gabriel Genellina
En Sat, 24 Oct 2009 23:59:06 -0300, linda.s samrobertsm...@gmail.com  
escribió:



When I click quit button, why the following code has problem?

[...]

if __name__ == '__main__':
root = Tk()
gridbox(Toplevel())
packbox(Toplevel())
Button(root, text='Quit', command=root.quit).pack()
mainloop()


If you run the code from inside IDLE, you'll have to add this line at the  
end:


root.destroy()

as explained here:

http://www.effbot.org/tkinterbook/tkinter-hello-again.htm

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: quit button

2009-10-25 Thread John Posner

linda.s wrote:


When I click quit button, why the following code has problem?

from Tkinter import *
colors = ['red', 'green', 'yellow', 'orange', 'blue', 'navy']

def gridbox(parent):
r = 0
for c in colors:
l = Label(parent, text=c, relief=RIDGE,  width=25)
e = Entry(parent, bg=c,   relief=SUNKEN, width=50)
l.grid(row=r, column=0)
e.grid(row=r, column=1)
r = r+1

def packbox(parent):
for c in colors:
f = Frame(parent)
l = Label(f, text=c, relief=RIDGE,  width=25)
e = Entry(f, bg=c,   relief=SUNKEN, width=50)
f.pack(side=TOP)
l.pack(side=LEFT)
e.pack(side=RIGHT)

if __name__ == '__main__':
root = Tk()
gridbox(Toplevel())
packbox(Toplevel())
Button(root, text='Quit', command=root.quit).pack()
mainloop()
  
Please describe the problem in more detail. Including the exact error 
message, if any, would be very helpful. When I ran this code on Python 
2.6.3rc1 / Windows XP, clicking Quit closed all three windows and 
ended the program. (BTW, nice use of both LEFT and RIGHT packing!)


-John

--
http://mail.python.org/mailman/listinfo/python-list


Re: quit button

2009-10-25 Thread Grant Edwards
On 2009-10-25, linda.s samrobertsm...@gmail.com wrote:

 When I click quit button, why the following code has problem?

It works fine for me (running Gentoo Linux on IA32).

-- 
Grant

-- 
http://mail.python.org/mailman/listinfo/python-list


quit button

2009-10-24 Thread linda.s
When I click quit button, why the following code has problem?

from Tkinter import *
colors = ['red', 'green', 'yellow', 'orange', 'blue', 'navy']

def gridbox(parent):
r = 0
for c in colors:
l = Label(parent, text=c, relief=RIDGE,  width=25)
e = Entry(parent, bg=c,   relief=SUNKEN, width=50)
l.grid(row=r, column=0)
e.grid(row=r, column=1)
r = r+1

def packbox(parent):
for c in colors:
f = Frame(parent)
l = Label(f, text=c, relief=RIDGE,  width=25)
e = Entry(f, bg=c,   relief=SUNKEN, width=50)
f.pack(side=TOP)
l.pack(side=LEFT)
e.pack(side=RIGHT)

if __name__ == '__main__':
root = Tk()
gridbox(Toplevel())
packbox(Toplevel())
Button(root, text='Quit', command=root.quit).pack()
mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


newbie:this program stops responding after pressing quit button

2007-12-04 Thread Boris
I am using windows vista and python 2.5 .This program stops responding
after pressing quit button. I am not able to figure the problem out.
please help.

from Tkinter import *

def greeting( ):
print 'Hello stdout world!...'

win = Frame(
 )
win.pack( )
Label(win,  text='Hello container world').pack(side=TOP)
Button(win, text='Hello', command=greeting).pack(side=LEFT)
Button(win, text='Quit',  command=win.quit).pack(side=RIGHT)

win.mainloop( )

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie:this program stops responding after pressing quit button

2007-12-04 Thread Michael Speer
On Dec 4, 2007 8:32 AM, Boris [EMAIL PROTECTED] wrote:
 I am using windows vista and python 2.5 .This program stops responding
 after pressing quit button. I am not able to figure the problem out.
 please help.

 from Tkinter import *

 def greeting( ):
 print 'Hello stdout world!...'

 win = Frame(
  )
 win.pack( )
 Label(win,  text='Hello container world').pack(side=TOP)
 Button(win, text='Hello', command=greeting).pack(side=LEFT)
 Button(win, text='Quit',  command=win.quit).pack(side=RIGHT)

 win.mainloop( )

 --
 http://mail.python.org/mailman/listinfo/python-list


While unfamiliar with the package, I loaded it up to see if I could
help you out.

I loaded Tkinter and ran your code under ubuntu in the interactive
prompt and saw the same result.

The doc for the win.quit function states Quit the Tcl interpreter.
All widgets will be destroyed. but I certainly don't see that
happening here.  If you really want to quit, try setting the command
for the quit button to sys.exit perhaps?  This left my terminal in a
state I had to `reset` out of but it did kill the program.

Hmm.  Further testing seems to show that it may be a simple matter of
Tkinter only getting rid of windows and things if there are no
references left to them from the python runtime.

Your win.quit won't destroy the window as long as the variable win refers to it.

Load up your interpreter and play with it interactively.  Remember the
dir( object ) command will give a full listing of the attributes of
any given object.  Looking at object.__doc__ will give you the
documentation.  There's probably something in there to hide the window
if that is all you want.

Good luck solving your problem.

Michael Speer
http://michaelspeer.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie:this program stops responding after pressing quit button

2007-12-04 Thread Eric Brunel
On Tue, 04 Dec 2007 14:32:34 +0100, Boris [EMAIL PROTECTED] wrote:
 I am using windows vista and python 2.5 .This program stops responding
 after pressing quit button. I am not able to figure the problem out.
 please help.

 from Tkinter import *

 def greeting( ):
 print 'Hello stdout world!...'

 win = Frame(
  )
 win.pack( )

While I can't reproduce the problem you have since I'm on an older  
Python/Tkinter version, I'd say these last two lines are the problem: in  
Tkinter, Frame instances are not windows, but generic containers. Creating  
a Frame instance without having a window implicitly creates one, but you  
have to use some Tkinter internals to manipulate it, which is never a good  
idea. I'd replace these two lines with this one:

win = Tk()

which actually create the main window for the application as well as the  
underlying tcl interpreter, required by Tkinter.

Please note this must be done only for the main window, i.e exactly once  
in your application; other ones must be created as Toplevel instances, not  
Tk ones.

 Label(win,  text='Hello container world').pack(side=TOP)
 Button(win, text='Hello', command=greeting).pack(side=LEFT)
 Button(win, text='Quit',  command=win.quit).pack(side=RIGHT)

 win.mainloop( )

HTH
-- 
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list