[Tkinter-discuss] Tkinter-discuss Digest, Vol 28, Issue 5

Harlin Seritt harlinseritt at yahoo.com
Wed Jun 7 12:40:37 CEST 2006


You can create a global or better: a class Flag that gets switched on whenever a toplevel windows becomes active.
   
  Harlin Seritt

tkinter-discuss-request at python.org wrote:
  Send Tkinter-discuss mailing list submissions to
tkinter-discuss at python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tkinter-discuss
or, via email, send a message with subject or body 'help' to
tkinter-discuss-request at python.org

You can reach the person managing the list at
tkinter-discuss-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tkinter-discuss digest..."


Today's Topics:

1. a question on the top level window (V H)
2. Re: a question on the top level window (Fredrik Lundh)
3. Re: update_idletasks problem (Russell Blau)
4. Re: a question on the top level window (Olivier Feys)
5. Re: a question on the top level window (Olivier Feys)


----------------------------------------------------------------------

Message: 1
Date: Tue, 06 Jun 2006 10:24:45 +0000
From: "V H" 
Subject: [Tkinter-discuss] a question on the top level window
To: tkinter-discuss at python.org
Message-ID: 
Content-Type: text/plain; format=flowed

Hi all,

I use a button to generate a toplevel window. I hope only one such window 
is existing before I close it manually. But now each time when I click the 
button a new window is created. How can I do?

How do I bind a function to the close of the window by clicking the cross in 
the up-right side?

Following is a example program. You solution or suggetstiong is very 
appreciated .

regards,
Vning



from Tkinter import *
root = Tk()
class App:
def __init__(self, master):
c = Button(master, text="Only one")
c.bind("", lambda e, s=self:s.cb(master))
c.pack()
def cb(self,master):#, event):
win = Toplevel(master)
win.title("one")
frame= Frame(win)
b=Button(frame, text='ok', command=win.quit)
b.pack()
frame.pack()
app=App(root)
root.mainloop()

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/



------------------------------

Message: 2
Date: Tue, 06 Jun 2006 12:52:26 +0200
From: Fredrik Lundh 
Subject: Re: [Tkinter-discuss] a question on the top level window
To: tkinter-discuss at python.org
Message-ID: 
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

V H wrote:
> Hi all,
> 
> I use a button to generate a toplevel window. I hope only one such window 
> is existing before I close it manually. But now each time when I click the 
> button a new window is created. How can I do?
> 
> How do I bind a function to the close of the window by clicking the cross in 
> the up-right side?

look for "WM_DELETE_WINDOW" on this page:

http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm





------------------------------

Message: 3
Date: Tue, 6 Jun 2006 08:09:04 -0400
From: "Russell Blau" 
Subject: Re: [Tkinter-discuss] update_idletasks problem
To: tkinter-discuss at python.org
Message-ID: 

Perhaps I should have called this "cursor problem." On further
investigation, I disabled the command button while the page is being
retrieved, and this works even though the cursor change does not. So now
I've got the following code:

class Application(Tkinter.Frame):
def __init__(self):
self.b = Button(self, text="Retrieve Page",
command=self.my_slow_method)
self.b.pack()

def my_slow_method(self):
self['cursor'] = 'watch'
self.b['state'] = DISABLED
self.update_idletasks()
retrieve_page_from_wiki() # placeholder function
self['cursor'] = '' # reset to default
self.b['state'] = NORMAL

While the page is being retrieved from the server, the button is disabled,
but the cursor remains normal. Is this a Windows problem, or is there
something I can do within Tkinter to get the
cursor to behave as desired?





------------------------------

Message: 4
Date: Tue, 06 Jun 2006 12:45:50 +0200
From: Olivier Feys 
Subject: Re: [Tkinter-discuss] a question on the top level window
To: V H 
Cc: tkinter-discuss at python.org
Message-ID: <44855CDE.5000501 at googlemail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

here is a solution :

from Tkinter import *
root = Tk()
def callback():
print 'clicked on cross'
class App:
def __init__(self, master):
c = Button(master, text="Only one")
c.bind("", lambda e, s=self:s.cb(master))
c.pack()

def cb(self,master):#, event):
win = Toplevel(master)
win.protocol('WM_DELETE_WINDOW',callback)
win.title("one")
frame= Frame(win)
b=Button(frame, text='ok', command=win.quit)
b.pack()
frame.pack()
app=App(root)
root.mainloop()


Olivier



V H wrote:

>Hi all,
>
>I use a button to generate a toplevel window. I hope only one such window 
>is existing before I close it manually. But now each time when I click the 
>button a new window is created. How can I do?
>
>How do I bind a function to the close of the window by clicking the cross in 
>the up-right side?
>
>Following is a example program. You solution or suggetstiong is very 
>appreciated .
>
>regards,
>Vning
>
>
>
>from Tkinter import *
>root = Tk()
>class App:
> def __init__(self, master):
> c = Button(master, text="Only one")
> c.bind("", lambda e, s=self:s.cb(master))
> c.pack()
> def cb(self,master):#, event):
> win = Toplevel(master)
> win.title("one")
> frame= Frame(win)
> b=Button(frame, text='ok', command=win.quit)
> b.pack()
> frame.pack()
>app=App(root)
>root.mainloop()
>
>_________________________________________________________________
>Don't just search. Find. Check out the new MSN Search! 
>http://search.msn.com/
>
>_______________________________________________
>Tkinter-discuss mailing list
>Tkinter-discuss at python.org
>http://mail.python.org/mailman/listinfo/tkinter-discuss
>
> 
>



------------------------------

Message: 5
Date: Wed, 07 Jun 2006 08:48:33 +0200
From: Olivier Feys 
Subject: Re: [Tkinter-discuss] a question on the top level window
To: V H 
Cc: tkinter-discuss at python.org
Message-ID: <448676C1.4080907 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

here is a solution :

from Tkinter import *
root = Tk()
def callback():
print 'clicked on cross'
class App:
def __init__(self, master):
c = Button(master, text="Only one")
c.bind("", lambda e, s=self:s.cb(master))
c.pack()

def cb(self,master):#, event):
win = Toplevel(master)
win.protocol('WM_DELETE_WINDOW',callback)
win.title("one")
frame= Frame(win)
b=Button(frame, text='ok', command=win.quit)
b.pack()
frame.pack()
app=App(root)
root.mainloop()


Olivier



V H wrote:

>Hi all,
>
>I use a button to generate a toplevel window. I hope only one such window 
>is existing before I close it manually. But now each time when I click the 
>button a new window is created. How can I do?
>
>How do I bind a function to the close of the window by clicking the cross in 
>the up-right side?
>
>Following is a example program. You solution or suggetstiong is very 
>appreciated .
>
>regards,
>Vning
>
>
>
>from Tkinter import *
>root = Tk()
>class App:
> def __init__(self, master):
> c = Button(master, text="Only one")
> c.bind("", lambda e, s=self:s.cb(master))
> c.pack()
> def cb(self,master):#, event):
> win = Toplevel(master)
> win.title("one")
> frame= Frame(win)
> b=Button(frame, text='ok', command=win.quit)
> b.pack()
> frame.pack()
>app=App(root)
>root.mainloop()
>
>_________________________________________________________________
>Don't just search. Find. Check out the new MSN Search! 
>http://search.msn.com/
>
>_______________________________________________
>Tkinter-discuss mailing list
>Tkinter-discuss at python.org
>http://mail.python.org/mailman/listinfo/tkinter-discuss
>
> 
>




------------------------------

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


End of Tkinter-discuss Digest, Vol 28, Issue 5
**********************************************


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060607/55d955d1/attachment.html 


More information about the Tkinter-discuss mailing list