我已经用python和tkintergui为我的本地火车站创建了一个全屏的离港板,并将其连接到了一个覆盆子pi上。在
为了节省空间,我把显示列车目的地的字符数限制在13个以内。我想使这个滚动在一个股票风格,以便阅读目的地超过13个字符。在
请告诉我,如果你有任何想法,使火车目的地滚动?在
我已经在下面的代码中为国家铁路数据库清空了API密钥。如果你想让它测试程序,请问。在
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()
这将产生以下输出(单击下面的图片):
Tkinter train departures board
正如你所见,“赫特福德北”和“威尔温花园城市”不适合提供的空间。我希望这些名称在当前文本小部件中连续循环。在
抱歉,我的剧本太乱了,我有点傻了
以下是如何从Dani Web制作股票行情的示例:
这不是我的代码,这是vegaseat's代码
相关问题 更多 >
编程相关推荐