[Tutor] Clock in tkinter?

Mic o0MB0o at hotmail.se
Tue Nov 15 21:00:06 CET 2011


Hi!
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 widgets?


So how do I add this clock as a widget placed next to the button?


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):
        super(Window,self).__init__(master)
        self.grid()
        self.create_widgets()

    def create_widgets(self):
        self.test_button=Button(self, text="Hi")
        self.test_button.grid(row=0,column=0)


        
root=Tk()
root.title("Test")
root.geometry("200x200")
app=Window(root)
root.mainloop()
    


Thank you for your help!



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111115/0c8390fa/attachment.html>


More information about the Tutor mailing list