#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Can timer coding possible in text widget


    Is it possible to code timer (HH:MM:SS) using text widget with Tkinter. I know we can do this with label widget. My code deals with text widget and want to display time at any corner of the window. any suggestions..
    thanks.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480

    Change the user interface plan


    You want the time to be part of the text during editing?
    The Text widget does not allow insertions beyond the end of current text. Let t be a new Text widget.

    t = tkinter.Text()
    t.pack()
    t.insert('7.32', time.asctime())

    places the time in the top left corner. To place initially place the text anywhere in the window you'd need to fill the window with some combination of new lines and horizontal white space, creating new problems.
    • The user can access more of the text box unless you actively and carefully manage every every character entered.
    • Do you want the Text box to behave as a normal Text widget? You'd need to understand normal behavior. This problem stopped me from implementing code.
    • You'll need to adjust the content of the displayed portion of text during scrolling as well.
    • When the text is extracted via copy, save or send you'll need to remove the time stamp and additional white space.
    These troubles discourage me. There's other space on the display the time.

    I favor the "keep the entry point visible" concept. Follow this link to mouse-avoidance-mode for an easier and more reusable idea for preventing occlusion. To compute coordinates of a time label widget I'd solve a system of equations with force inversely proportional to separation, boundaries of the text box, coefficients of sliding and of static friction, contained within an underlying canvas.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0
    Thank you.
    My code is with text widget, can i change my code to label widget, label widget had the default option of anchor= CENTER. This options controls where the text is positioned if the widget has more space than the text needs. The default is anchor=CENTER, which center's the text in the available space.And more over i think it is easy to code timer in label widget, if i change my code to label widget.

IMN logo majestic logo threadwatch logo seochat tools logo