[问题]请问,有大大能帮我看一吗?(已稍作修改)

楼主: aeronan (aeron)   2014-05-15 15:41:35
我做了一些更改顺便加上apua大的“把连结看起来比较简单”
这是我目前写的, 不知道哪里出问题~按了按钮可是跑不出来资讯
想要变成一个可以按了就能看到的即时气象资讯
像是这个图一样 http://ppt.cc/Q~m1
有大大能帮忙一下吗???
谢谢!!!
from urllib import urlopen
from Tkinter import *
from re import findall
the_window = Tk()
the_window.title('The Weather Report')
the_window.geometry('600x500+10+10')
radiobutton = ['Brisbane', 'Sydney', 'Melbourne', 'Adelade', 'Darwin', '
Habart', 'Perth', 'Canberra']
the_label = Label(the_window, text = 'Current Weather', fg ='black',
font = ('Arial', 20)).grid(row = 0, column = 0, padx = 2,
pady = 2)
text_box = Text(the_window, width = 50, height = 20, wrap = WORD,
bg = 'light yellow',font =('Arial', 12), borderwidth = 3,
relief = 'groove', takefocus = False)
the_label = Label(the_window, text = 'Current Weather', fg ='black', font =
('Arial', 20)).grid(row = 0, column = 0, padx = 2, pady = 2)
text_box = Text(the_window, width = 50, height = 20, wrap = WORD,
bg = 'light yellow',font =('Arial', 12), borderwidth = 3,
relief = 'groove',takefocus = False).grid(row = 1,
column = 0, padx =10, pady = 10,rowspan = 6, columnspan = 4)
Locations = {
'Brisbane': 9388,
'Sydney': 624,
'Melbourne':5594,
'Adelade': 12495,
'Darwin': 11,
'Habart': 15465,
'Perth': 13896,
'Canberra': 3928,}
url_template = 'http://rss.weatherzone.com.au/?u=12994-1285&lt=aploc&lc={}&obs=1&fc=1&warn=1'
def open_url(i, url):
url['locations'] = locations[i]
def open_url(event = None):
weather_page = urlopen(url_template)
html_code = weather_page.read()
weather_page.close()
text_box.delete(0.0, END)
page_date = FINDALL('<lastBuildDate>(.+)</lastBuildDate>', html_code)
if len(page_date) != 1:
text_box.insert(END,'Erroe: Unable to find unique modification date')
else:
text_box.insert(END, page_date[0].upper()+'\n\n')
title_name = find('<title>(.-)</title>', html_code)
for i in range(8):
Radiobutton(the_window, text = radiobutton[i], value = i,
command = lambda i= i, locations =locations:
open_url(i, url)).grid(row= 7, column =i)
the_window.mainloop()
作者: apua (Apua)   2014-05-15 21:43:00
有点乱, 先稍微整理了一下: http://goo.gl/Y6qUyJ
楼主: aeronan (aeron)   2014-05-15 22:18:00
apua大,可以请问你地区后面的数字是???
作者: apua (Apua)   2014-05-21 14:35:00
the id of "lc" in those urls

Links booklink

Contact Us: admin [ a t ] ucptt.com