[Tutor] Clock in tkinter?
waynejwerner at gmail.com
Tue Nov 15 22:14:11 CET 2011
On Tue, Nov 15, 2011 at 2:00 PM, Mic <o0MB0o at hotmail.se> wrote:
> I am new to programming and I hop this question isn’t stupid.
> 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.
> So as far as I am concerned both the clock and the are supposed to be
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.
> So how do I add this clock as a widget placed next to the button?
Tkinter doesn't have a native clock widget, so if you want to make a clock
you need to roll your own.
> Here is the code I have written so far, that only displays a GUI
> window, and a button:
> from tkinter import *
> import time
> class Window(Frame):
> def __init__(self,master):
> def create_widgets(self):
> self.test_button=Button(self, text="Hi")
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.
You can add text to the Label widget - and you can change the text on that
You're already importing the time module - for more information about what
it contains, you can run the interactive interpreter and do this:
>>> import time
Or you can look online for the commands that might help you.
If you get stuck, let us know what you're doing and where you're stuck at.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor