<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Hi!</DIV>
<DIV>It is no homework, in fact am I working ahead of class. I have now, after
five minutes thinking, solved my problem, but a new problem has risen.</DIV>
<DIV>But to begin with, here is how I solved the problem:</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>from tkinter import*</DIV>
<DIV>import time</DIV>
<DIV> </DIV>
<DIV>the_time=''</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>class Window(Frame):</DIV>
<DIV> def __init__(self,master):</DIV>
<DIV>
super(Window,self).__init__(master)</DIV>
<DIV> self.grid()</DIV>
<DIV> self.create_widgets()</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> def create_widgets(self):</DIV>
<DIV> </DIV>
<DIV> #Create a hello button:</DIV>
<DIV>
hej=self.hellobttn=Button(self,text="Hey")</DIV>
<DIV> self.hellobttn.grid(row=0,
column=0)</DIV>
<DIV> </DIV>
<DIV> #Create a label that displays
time:</DIV>
<DIV> self.display_time=Label(self,
text=the_time)</DIV>
<DIV> self.display_time.grid(row=0,
column=1)</DIV>
<DIV> </DIV>
<DIV> def
change_value_the_time():</DIV>
<DIV> global
the_time</DIV>
<DIV> newtime
= time.strftime('%H:%M:%S')</DIV>
<DIV> if
newtime != the_time:</DIV>
<DIV>
the_time= newtime</DIV>
<DIV>
self.display_time.config(text=the_time, font="40")</DIV>
<DIV>
self.display_time.after(20, change_value_the_time)</DIV>
<DIV> </DIV>
<DIV> change_value_the_time()</DIV>
<DIV> </DIV>
<DIV>root=Tk()</DIV>
<DIV>root.title("Test")</DIV>
<DIV>root.geometry("200x200")</DIV>
<DIV>app=Window(root)</DIV>
<DIV>root.mainloop()</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>I found some help on the internet about making a clock, although I had to
modify a lot of the code to fit my own code and window.</DIV>
<DIV>Now to my next question. Say that I want a text “Hi, how are you?” to be
printed when the time passes 15:00:00 each day. How do I do that?</DIV>
<DIV> </DIV>
<DIV>At first I thought that I could just write an if statement. Like:</DIV>
<DIV> </DIV>
<DIV>if the_time>15:00:00:</DIV>
<DIV> print (“Hi, how are you?”)</DIV>
<DIV> </DIV>
<DIV>But it is obviously not working.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Thank you for your help! Another question, am I supposed to add
tutor@python.org<A href="mailto:tutor@python.org">tutor@python.org</A>; as copy?
You did that, right?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Regards Mic</DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=waynejwerner@gmail.com
href="mailto:waynejwerner@gmail.com">Wayne Werner</A> </DIV>
<DIV><B>Sent:</B> Tuesday, November 15, 2011 10:14 PM</DIV>
<DIV><B>To:</B> <A title=o0MB0o@hotmail.se
href="mailto:o0MB0o@hotmail.se">Mic</A> </DIV>
<DIV><B>Cc:</B> <A title=tutor@python.org
href="mailto:tutor@python.org">tutor@python.org</A> </DIV>
<DIV><B>Subject:</B> Re: [Tutor] Clock in tkinter?</DIV></DIV></DIV>
<DIV> </DIV></DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV class=gmail_quote>On Tue, Nov 15, 2011 at 2:00 PM, Mic <SPAN dir=ltr><<A
href="mailto:o0MB0o@hotmail.se">o0MB0o@hotmail.se</A>></SPAN> wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Hi!</DIV>
<DIV>I am new to programming and I hop this question isn’t
stupid.</DIV></DIV></DIV></DIV></BLOCKQUOTE>
<DIV> </DIV>
<DIV>Welcome! </DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV><SPAN
style="BACKGROUND-COLOR: transparent; DIRECTION: ltr; FONT-SIZE: 12pt">I am
making a small GUI program. It is supposed to have a button and a clock in it
that displays the same time as it is according to the computer.</SPAN></DIV>
<DIV>So as far as I am concerned both the clock and the are supposed to be
widgets?</DIV></DIV></DIV></DIV></BLOCKQUOTE>
<DIV> </DIV>
<DIV>Is this a homework assignment, or just something that you're doing for fun?
It seems homework-ish. We don't mind pointing you in the right direction on
homework assignments, but we definitely won't do it for you.</DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV> <SPAN
style="BACKGROUND-COLOR: transparent; DIRECTION: ltr; FONT-SIZE: 12pt">So how
do I add this clock as a widget placed next to the button?</SPAN><SPAN
style="BACKGROUND-COLOR: transparent; DIRECTION: ltr; FONT-SIZE: 12pt"> </SPAN></DIV></DIV></DIV></DIV></BLOCKQUOTE>
<DIV> </DIV>
<DIV>Tkinter doesn't have a native clock widget, so if you want to make a clock
you need to roll your own.</DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV> <SPAN
style="BACKGROUND-COLOR: transparent; DIRECTION: ltr; FONT-SIZE: 12pt">Here is
the code I have written so far, that only displays a GUI window, and a
button:</SPAN></DIV>
<DIV> <SPAN
style="BACKGROUND-COLOR: transparent; DIRECTION: ltr; FONT-SIZE: 12pt"> </SPAN></DIV>
<DIV>from tkinter import *</DIV>
<DIV>import time</DIV>
<DIV> <SPAN
style="BACKGROUND-COLOR: transparent; DIRECTION: ltr; FONT-SIZE: 12pt"> </SPAN></DIV>
<DIV>class Window(Frame):</DIV>
<DIV> def __init__(self,master):</DIV>
<DIV>
super(Window,self).__init__(master)</DIV>
<DIV> self.grid()</DIV>
<DIV> self.create_widgets()</DIV>
<DIV> </DIV>
<DIV> def create_widgets(self):</DIV>
<DIV> self.test_button=Button(self,
text="Hi")</DIV>
<DIV>
self.test_button.grid(row=0,column=0)</DIV>
<DIV> <SPAN
style="BACKGROUND-COLOR: transparent; DIRECTION: ltr; FONT-SIZE: 12pt">
</SPAN></DIV>
<DIV>root=Tk()</DIV>
<DIV>root.title("Test")</DIV>
<DIV>root.geometry("200x200")</DIV>
<DIV>app=Window(root)</DIV>
<DIV>root.mainloop()</DIV></DIV></DIV></DIV></BLOCKQUOTE>
<DIV> </DIV>
<DIV>Giving us code (especially such a small amount) is exactly the right thing
to do when you ask a question - it shows that you've tried something, and if
it's broken it usually shows why it's broken.</DIV>
<DIV> </DIV>
<DIV>You can add text to the Label widget - and you can change the text on that
widget.</DIV>
<DIV> </DIV>
<DIV>You're already importing the time module - for more information about what
it contains, you can run the interactive interpreter and do this:</DIV>
<DIV> </DIV>
<DIV>>>> import time</DIV>
<DIV>>>> help(time)</DIV>
<DIV> </DIV>
<DIV>Or you can look online for the commands that might help you.</DIV>
<DIV> </DIV>
<DIV>If you get stuck, let us know what you're doing and where you're stuck
at.</DIV>
<DIV> </DIV>
<DIV>HTH,</DIV>
<DIV>Wayne</DIV></DIV></DIV></DIV></DIV></BODY></HTML>