Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8791377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:50:05+00:00 2026-06-13T22:50:05+00:00

I would like to have an entry box for typing in dates so that

  • 0

I would like to have an entry box for typing in dates so that the user can only type it one way.

The entry box before typing would look like this (without the underscores) __/__/____, and the /‘s are not deleted when the user types the date.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:50:06+00:00Added an answer on June 13, 2026 at 10:50 pm

    Thanks to @Bryan Oakley’s major hint, I have come up with this working code.

    (Update: threw a few years of programming experience and some recent readers’ sharp eyes at improving the code.)

    from __future__ import print_function
    
    try:
        import Tkinter as tk
    except ImportError:
        import tkinter as tk
    
    
    class DateEntry(tk.Frame):
        def __init__(self, master, frame_look={}, **look):
            args = dict(relief=tk.SUNKEN, border=1)
            args.update(frame_look)
            tk.Frame.__init__(self, master, **args)
    
            args = {'relief': tk.FLAT}
            args.update(look)
    
            self.entry_1 = tk.Entry(self, width=2, **args)
            self.label_1 = tk.Label(self, text='/', **args)
            self.entry_2 = tk.Entry(self, width=2, **args)
            self.label_2 = tk.Label(self, text='/', **args)
            self.entry_3 = tk.Entry(self, width=4, **args)
    
            self.entry_1.pack(side=tk.LEFT)
            self.label_1.pack(side=tk.LEFT)
            self.entry_2.pack(side=tk.LEFT)
            self.label_2.pack(side=tk.LEFT)
            self.entry_3.pack(side=tk.LEFT)
    
            self.entries = [self.entry_1, self.entry_2, self.entry_3]
    
            self.entry_1.bind('<KeyRelease>', lambda e: self._check(0, 2))
            self.entry_2.bind('<KeyRelease>', lambda e: self._check(1, 2))
            self.entry_3.bind('<KeyRelease>', lambda e: self._check(2, 4))
    
        def _backspace(self, entry):
            cont = entry.get()
            entry.delete(0, tk.END)
            entry.insert(0, cont[:-1])
    
        def _check(self, index, size):
            entry = self.entries[index]
            next_index = index + 1
            next_entry = self.entries[next_index] if next_index < len(self.entries) else None
            data = entry.get()
    
            if len(data) > size or not data.isdigit():
                self._backspace(entry)
            if len(data) >= size and next_entry:
                next_entry.focus()
    
        def get(self):
            return [e.get() for e in self.entries]
    
    
    if __name__ == '__main__':        
        win = tk.Tk()
        win.title('DateEntry demo')
    
        dentry = DateEntry(win, font=('Helvetica', 40, tk.NORMAL), border=0)
        dentry.pack()
    
        win.bind('<Return>', lambda e: print(dentry.get()))
        win.mainloop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have an AppWidget that designed like this one . Image:
I would like my text entry to round off decimals and have the end
Hi I have a spinner for which I would like to change its entry.
So in my project i would like have a nice treeview that has images.
I would like to have a border that is 4px thick pink on the
Right now, I have a layout that looks like one of the two images
I have four packages in my program, among them i would like one and
I am creating a user control that I would like to be able to
If I have a combo box in pyGTK and would like to set a
I would like to have a more colorful Python prompt in the terminal, just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.