[Tutor] Clock in tkinter?
Wayne Werner
waynejwerner at gmail.com
Wed Nov 16 18:27:04 CET 2011
On Wed, Nov 16, 2011 at 10:59 AM, Mic <o0MB0o at hotmail.se> wrote:
> Thanks for your quick answer. Hmm, I never thought that didn’t have to
> use a global variable.
>
That's often the point of using classes - you want to collect related data
and functions in one place. In this case, you're creating a clock widget,
so you want all of your clock data and methods inside your class.
> When you mentioned time.localtime() method, did you mean that I should
> convert the time to numbers and then write an if statement?
> Like, say that I make 1 hour equivalent to the integear clock= 1. Then I
> write an if statement that says that the computer should print “Hi”
> if clock>1:
> print (“hi”)
>
Take a look at what's available from the localtime:
>>> help(time.localtime)
and
>>> help(time.localtime())
You should be able to figure out a way to make it work pretty much like
what your initial thought was.
As an aside, you've been top-posting, which can cause a lot of problems for
people who want to follow the thread of the conversation - all they see is
what you've written with no context. The appropriate thing to do is reply
inline, removing any irrelevant material and (usually) indicating that
you've done so with a <snip> or [...] or something similiar.
HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111116/7be29d81/attachment.html>
More information about the Tutor
mailing list