Train departures board ticker Tkinter
Question: I have created a full screen departures board for my local train station using
python and the Tkinter GUI and I have hooked it up to a raspberry pi.

I have limited the number of characters for the display of the train's
destination to 13 to save space. I would like to make this scroll in a ticker
style in order to read destinations that are longer than 13 characters.

Please let me know if you have any ideas to make the train destinations scroll
along?

I have blanked out my API key for the national rail database on the code
below. If you would like it to test the program, please ask.

    
    
    import Tkinter as tk
    from nredarwin.webservice import DarwinLdbSession
    from datetime import datetime
    
    
    top = tk.Tk()
    top.title("Departure Board for Harringay Station")
    top.configure(background='black')
    
    def callback():
        darwin_session = DarwinLdbSession(wsdl='https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2015-05-14', api_key = 'xxxxx-xxxxx-xxxxxx-xxxxxxx')
        crs_code = "HGY"
        board = darwin_session.get_station_board(crs_code)
        tex.delete(1.0, tk.END)
    
        s = "\nNext departures for %s" % (board.location_name)
        t = """
    -------------------------------
    |P| DEST         |SCHED|  DUE  |
    ------------------------------- \n"""
        tex.insert(tk.END, s + t, 'tag-center')
        tex.see(tk.END)
    
        for service in board.train_services:
            u = ("|%1s|%14s|%5s|%7s|\n" %(service.platform or "", service.destination_text[:13], service.std, service.etd[:7]))
            tex.insert(tk.END, u, 'tag-center')   
    
        v = "--------------------------------\n"
        tex.insert(tk.END, v, 'tag-center')
    
        tex.after(10000, callback)
    
    def tick():
        tex2.delete(1.0, tk.END)
        now = datetime.now()
        tex2.insert(tk.END, "%s %s %s %s %s:%s" %(now.strftime('%A'), now.strftime('%d'), now.strftime('%b'), now.strftime('%Y'), now.strftime('%H'), now.strftime('%M')), 'tag-center')
        tex2.after(1000, tick)
    
    
    def close_window (): 
        top.destroy()
    
    button = tk.Button(top, text = "Exit", highlightthickness=0, command = close_window, bg = "black", fg = "orange")
    button.pack(side = tk.TOP, anchor = tk.NE)
    
    
    
    tex2 = tk.Text(master=top, font = "Courier 28 bold", highlightthickness=0, cursor = 'none', insertwidth=0, height = 1, bg = "black", fg = "orange", borderwidth = 0)
    tex2.pack(side = tk.TOP)
    tex2.tag_configure('tag-center', justify='center')
    
    tex = tk.Text(master=top, font = "Courier 25 bold", highlightthickness=0, cursor = 'none', bg = "black", fg = "orange", borderwidth = 0)
    tex.pack()
    tex.tag_configure('tag-center', justify='center')
    
    w, h = top.winfo_screenwidth(), top.winfo_screenheight()
    top.overrideredirect(1)
    top.geometry("%dx%d+0+0" % (w, h))
    
    callback()
    tick()
    
    top.mainloop()
    

This produces the following output (click below for picture):

[Tkinter train departures board](http://i.stack.imgur.com/6cVK3.jpg)

As you can see, "Hertford North" and "Welwyn Garden City" do not fit in the
space provided. I want these names to tick across in a continuous loop within
the current text widget.

Apologies for the messy script, I'm a bit of a noob


Answer: Here is an example of how to make a ticker from Dani Web:

    
    
    ''' Tk_Text_ticker102.py
    using Tkinter to create a marquee/ticker
    uses a display width of 20 characters
    not superbly smooth but good enough to read
    tested with Python27 and Python33  by  vegaseat  04oct2013
    '''
    import time
    try:
        # Python2
        import Tkinter as tk
    except ImportError:
        # Python3
        import tkinter as tk
    root = tk.Tk()
    # width --> width in chars, height --> lines of text
    text_width = 20
    text = tk.Text(root, width=text_width, height=1, bg='yellow')
    text.pack()
    # use a proportional font to handle spaces correctly
    text.config(font=('courier', 48, 'bold'))
    s1 = "We don't really care why the chicken crossed the road.  "
    s2 = "We just want to know if the chicken is on our side of the "
    s3 = "road or not. The chicken is either for us or against us.  "
    s4 = "There is no middle ground here.  (George W. Bush)"
    # pad front and end of text with spaces
    s5 = ' ' * text_width
    # concatenate it all
    s = s5 + s1 + s2 + s3 + s4 + s5
    for k in range(len(s)):
        # use string slicing to do the trick
        ticker_text = s[k:k+text_width]
        text.insert("1.1", ticker_text)
        root.update()
        # delay by 0.22 seconds
        time.sleep(0.22)
    root.mainloop()
    

P.S This is not my code it is
[vegaseat's](https://www.daniweb.com/members/19440/vegaseat) code

