<DIV>Hi Ian,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I had some trouble doing something like this when I was trying to write a balloon widget. I was using while, threading, etc... Try changing your act() method to this:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; def act(self):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ring = self.stringv.get()+self.stringv2.get()+":"\<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +self.stringv3.get()+self.stringv4.get()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.track = [None]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.c = self.clock()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv.set(self.c[0])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv2.set(self.c[1])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv3.set(self.c[3])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv4.set(self.c[4])<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.c = self.clock()&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.c !=
 self.ring:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.c == self.track[-1]: pass<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv.set(self.c[0])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv2.set(self.c[1])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv3.set(self.c[3])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.stringv4.set(self.c[4])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.track.append(self.c)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else: winsound.PlaySound("rooster.wav", winsound.SND_LOOP)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.master.after(1000, self.act)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Tk().after(milliseconds, method/function to call) is great for this sort of thing.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Good luck!</DIV>
<DIV>&nbsp;</DIV>
<DIV>Harlin Seritt</DIV>
<DIV><BR><BR><B><I>tkinter-discuss-request@python.org</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Send Tkinter-discuss mailing list submissions to<BR>tkinter-discuss@python.org<BR><BR>To subscribe or unsubscribe via the World Wide Web, visit<BR>http://mail.python.org/mailman/listinfo/tkinter-discuss<BR>or, via email, send a message with subject or body 'help' to<BR>tkinter-discuss-request@python.org<BR><BR>You can reach the person managing the list at<BR>tkinter-discuss-owner@python.org<BR><BR>When replying, please edit your Subject line so it is more specific<BR>than "Re: Contents of Tkinter-discuss digest..."<BR><BR><BR>Today's Topics:<BR><BR>1. Problem looping (Brill IanT)<BR>2. Re: Problem looping (Cameron Laird)<BR><BR><BR>----------------------------------------------------------------------<BR><BR>Message: 1<BR>Date: Mon, 2 May 2005 17:41:50 +0100 (BST)<BR>From: Brill IanT <WOSWWF@YAHOO.CO.UK><BR>Subject: [Tkinter-discuss] Problem looping<BR>To:
 tkinter-discuss@python.org<BR>Message-ID: &lt;20050502164151.17812.qmail@web26606.mail.ukl.yahoo.com&gt;<BR>Content-Type: text/plain; charset="iso-8859-1"<BR><BR>Hi all! <BR><BR>I was wondering if anyone could help me out. <BR>I wrote a little alarm clock program in Python, and now want to incorporate it into a Tkinter frame. It's all going quite well, but this is my first experience with Tk and I've hit a bit of a wall. One of the button's commands refers to a method (called 'act') which has a while loop within it (keeps track of the time and ought to display it in the Tk frame). But the problem is the while loop is interupting the root mainloop, so the labels will not update, and freezes until the while loop is over. <BR>Does anyone have any suggestions to get round this?<BR><BR>Here's the program:<BR><BR>import time, winsound<BR>from Tkinter import *<BR><BR>class App:<BR>def __init__(self,master):<BR>self.master = master<BR>frame =
 Frame(master,bd=6,relief=RIDGE)<BR>frame.pack()<BR>frame2 = Frame(master)<BR>frame2.pack()<BR><BR>self.list = ["9","8","7","6","5","4","3","2","1","0"]<BR>self.stringv = StringVar()<BR>self.stringv.set("0")<BR>self.stringv2 = StringVar()<BR>self.stringv2.set("0")<BR>self.stringv3 = StringVar()<BR>self.stringv3.set("0")<BR>self.stringv4 = StringVar()<BR>self.stringv4.set("0")<BR><BR>self.lab1 = Label(frame,font=("helvica",22),bg="red",<BR>textvariable=self.stringv).pack(side=LEFT)<BR>self.b1 = Button(frame2,text="H",width=3,command=self.change)<BR>self.b1.pack(side=LEFT)<BR><BR>self.lab2 = Label(frame,font=("helvica",22),bg="red",<BR>textvariable=self.stringv2).pack(side=LEFT)<BR>self.b2 = Button(frame2,text="h",width=3,command=self.change2)<BR>self.b2.pack(side=LEFT)<BR><BR>self.lab3 = Label(frame,text=":",font=("helvica",22),<BR>bg="red",).pack(side=LEFT)<BR><BR>self.lab4 = Label(frame,font=("helvica",22),bg="red",<BR>textvariable=self.stringv3).pack(side=LEFT)<BR>self.b3 =
 Button(frame2,text="M",width=3,command=self.change3)<BR>self.b3.pack(side=LEFT)<BR><BR>self.lab5 = Label(frame,font=("helvica",22),bg="red",<BR>textvariable=self.stringv4).pack(side=LEFT)<BR>self.b4 = Button(frame2,text="m",width=3,command=self.change4)<BR>self.b4.pack(side=LEFT)<BR><BR>self.set_button = Button(master,text="Set",width=20,<BR>command=self.act).pack()<BR><BR>def change(self):<BR>if int(self.stringv2.get()) &lt; 3:<BR>self.list1 = self.list[7:]<BR>i = self.list1.index(self.stringv.get())<BR>self.stringv.set(self.list1[i-1])<BR>else:<BR>self.list1 = self.list[8:]<BR>i = self.list1.index(self.stringv.get())<BR>self.stringv.set(self.list1[i-1])<BR><BR>def change2(self):<BR>self.list2 = self.list[6:]<BR>if self.stringv.get() == "2":<BR>i = self.list2.index(self.stringv2.get())<BR>self.stringv2.set(self.list2[i-1])<BR>else: <BR>i = self.list.index(self.stringv2.get())<BR>self.stringv2.set(self.list[i-1])<BR><BR>def change3(self):<BR>self.list3 = self.list[4:]<BR>i =
 self.list3.index(self.stringv3.get())<BR>self.stringv3.set(self.list3[i-1])<BR><BR>def change4(self):<BR>i = self.list.index(self.stringv4.get())<BR>self.stringv4.set(self.list[i-1])<BR><BR>def act(self):<BR>self.ring = self.stringv.get()+self.stringv2.get()+":"\<BR>+self.stringv3.get()+self.stringv4.get()<BR>self.track = [None]<BR>self.c = self.clock()<BR>self.stringv.set(self.c[0])<BR>self.stringv2.set(self.c[1])<BR>self.stringv3.set(self.c[3])<BR>self.stringv4.set(self.c[4])<BR><BR>while 1:<BR>self.c = self.clock() <BR>if self.c != self.ring:<BR>if self.c == self.track[-1]: pass<BR>else:<BR>self.stringv.set(self.c[0])<BR>self.stringv2.set(self.c[1])<BR>self.stringv3.set(self.c[3])<BR>self.stringv4.set(self.c[4])<BR>self.track.append(self.c)<BR>else: winsound.PlaySound("rooster.wav", winsound.SND_LOOP)<BR><BR>def clock(self):<BR>t1 = time.localtime()[3:5]<BR>if t1[0] in range(10): tm1 = '0'+ str(t1[0])<BR>else: tm1 = str(t1[0])<BR><BR>if t1[1] in range(10): tm2 = '0'+
 str(t1[1])<BR>else: tm2 = str(t1[1])<BR><BR>tm3 = tm1 + ":" + tm2<BR>return tm3<BR><BR>if __name__ == "__main__":<BR>root=Tk()<BR>root.title("")<BR>root.geometry("100x97+300+200")<BR>App(root)<BR>root.mainloop()<BR><BR><BR>Thanks in advance.<BR><BR><BR>Send instant messages to your online friends http://uk.messenger.yahoo.com <BR>-------------- next part --------------<BR>An HTML attachment was scrubbed...<BR>URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20050502/77610d5d/attachment.html<BR><BR>------------------------------<BR><BR>Message: 2<BR>Date: Mon, 2 May 2005 16:44:54 +0000<BR>From: Cameron Laird <CAMERON@PHASEIT.NET><BR>Subject: Re: [Tkinter-discuss] Problem looping<BR>To: Brill IanT <WOSWWF@YAHOO.CO.UK><BR>Cc: tkinter-discuss@python.org<BR>Message-ID: &lt;20050502164454.GA15435@lairds.us&gt;<BR>Content-Type: text/plain; charset=us-ascii<BR><BR>On Mon, May 02, 2005 at 05:41:50PM +0100, Brill IanT wrote:<BR>.<BR>.<BR>.<BR>&gt; I was wondering if anyone
 could help me out. <BR>&gt; I wrote a little alarm clock program in Python, and now want to incorporate it into a Tkinter frame. It's all going quite well, but this is my first experience with Tk and I've hit a bit of a wall. One of the button's commands refers to a method (called 'act') which has a while loop within it (keeps track of the time and ought to display it in the Tk frame). But the problem is the while loop is interupting the root mainloop, so the labels will not update, and freezes until the while loop is over. <BR>.<BR>.<BR>.<BR>Short answer: <URL: 1526 wiki.tcl.tk http:>.<BR><BR>Do you want help translating this into Tkinter?<BR><BR><BR>------------------------------<BR><BR>_______________________________________________<BR>Tkinter-discuss mailing list<BR>Tkinter-discuss@python.org<BR>http://mail.python.org/mailman/listinfo/tkinter-discuss<BR><BR><BR>End of Tkinter-discuss Digest, Vol 15, Issue
 1<BR>**********************************************<BR></BLOCKQUOTE><p>__________________________________________________<br>Do You Yahoo!?<br>Tired of spam?  Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com